PDA

View Full Version : simple reflection question

ugluk
12-18-2010, 09:14 AM
I wonder if it might be possible to adapt the simple shadow matrix algorithm (from the Blinn's article) to cast reflections also. I know, I know I shouldn't have asked without trying it out myself first, but, if I am wrong, are what are the other simple algorithms for reflection?

aqnuep
12-18-2010, 09:32 AM
Yes, in fact you can use a similarly constructed matrix to create reflections on a planar surface.

ugluk
12-18-2010, 11:04 AM
But how about the depthbuffer? Things will overlap on the planar surface I suppose. References?

You probably had RTT in mind and projective texturing. But I had something else in mind. Is the stencil buffer approach really the simplest one?

aqnuep
12-19-2010, 11:24 AM
No, I'm not talking about RTT+projective texturing. You have to properly configure your depth and stencil test to make things working.

There is the good old dinosaur sample which shows planar shadows and reflection. If you haven't checked it out then it's about time:

ugluk
12-20-2010, 05:34 AM
Yeah, I know the dino tut, but, he just flips the dino below the reflecting rect, doesn't do anything else. Not only this, he does not support arbitrary plane reflection, only the infinite z plane, I believe. The matrix is not similar either, it is a reflection transformation matrix, but Blinn's is a projection transformation matrix.

I am hunting for a projection example, if it exists, but I suppose the depth buffer prohibits it, fragments get bumped on one another. I was thinking of "mostly" projecting vertices onto a plane, with a slight offset, so the depth buffer would be pleased and only the closer fragments would show.

aqnuep
12-20-2010, 06:04 AM
Ah, now I know what you mean. Actually Don't really understand why you want to go with a projective solution if a simple reflection to arbitrary plane would just work fine.
Projection in fact introduce the problem of Z fighting so you definitely cannot 1-to-1 map shadow projection for reflection.

ugluk
12-20-2010, 01:10 PM
I want to know, because I don't know and I want to experiment. Reflection is fascinating, even though the RTT approach implementation is different than the stencil approach, they are in a way similar. I can't believe there are no other solutions.