Author Topic: Render in a specific window  (Read 773 times)

Offline kelmer

  • byte
  • *
  • Posts: 43
    • View Profile
Render in a specific window
« on: January 19, 2013, 11:43:51 am »
I was thinking of doing something similar to this:

https://www.youtube.com/watch?v=dUBxHd3bMhg (from 1:25)

And maybe this is a very stupid and simple question, but how would you restrict the rendering to that specific area? I know Portal rendering has something to do with this but I think it isn't included in JPCT-AE and it's not really that used anymore.

Is it possible to achieve something like this with jpct-ae?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Render in a specific window
« Reply #1 on: January 19, 2013, 02:58:57 pm »
One idea (untested): Render the scene in an npot-texture, render the window in another texture, then render a quad textured with both textures and write a shader that makes everything transparent except for the window.
Another idea: Render the window object with walls around the window and write a shader that sets the wall fragments to transparent but still writes their depth values into the depth buffer. Then clean the color buffer and render the scene.
These are just brain farts of mine...i may have overlooked a lot of things...

Offline kelmer

  • byte
  • *
  • Posts: 43
    • View Profile
Re: Render in a specific window
« Reply #2 on: January 20, 2013, 01:03:00 pm »
Those sound like promising approaches. I will try them, thanks!

Offline kelmer

  • byte
  • *
  • Posts: 43
    • View Profile
Re: Render in a specific window
« Reply #3 on: February 04, 2013, 12:47:39 am »
Another idea: Render the window object with walls around the window and write a shader that sets the wall fragments to transparent but still writes their depth values into the depth buffer. Then clean the color buffer and render the scene.

One question on this, wouldn't this also prevent the background image (i.e. the camera stream) from drawing? Since the walls have to be closer than the video stream, drawing them into the depth buffer would prevent the image to be seen as well, wouldn't it?

Also, I can understand how to make a shader that paints the walls transparent, but how do I still draw them into the depth buffer?

Wouldn't all this require several rendering passes?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Render in a specific window
« Reply #4 on: February 04, 2013, 07:20:30 am »
My idea was to set the wall to full alpha IIRC. But then again, if you clear the color buffer anyway, it doesn't matter at all. I don't see how this affect the background. It shouldn't care about the values in the depth buffer IMHO.