Render in a specific window

Started by kelmer, January 19, 2013, 11:43:51 AM

Previous topic - Next topic

kelmer

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?

EgonOlsen

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...

kelmer

Those sound like promising approaches. I will try them, thanks!

kelmer

Quote from: EgonOlsen on January 19, 2013, 02:58:57 PM
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?

EgonOlsen

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.