I want to add reflection but need an advice

Here we go …

I’d like to add reflection in my engine. I know hot to do that but I need your advice, dear readers …

Basically, we must write the reflection zone into the stencil buffer, next, add the scene who must be reflected into the stencil buffer and after we display the relfection zone and the object.

My question is for the reflected zone :

I think that it’s more powerful if I only add the reflected polygons into the stencil buffer instead of adding ALL zone into the stencil buffer. Right ?

But, how do you do for sorting the only reflected polygons. I need to determine wich polygons who will be reflected but now f… idea …

Thanks a lot.

(Sounds like an exam) but here’s an idea:
Calculate a frustum defined by the viewer’s position and the bounding rectangle of the mirror. You get five plane equations for near, left, right, bottom, top. Do a frustum intersection test with the bounding boxes of you objects transformed by the mirrored matrix and draw all objects which intersect the mirror frustum.
You could also build the frustum with the mirrored viewer position in case you have the trasnformed bounding boxes for the real scene already. The rest is for homework… :wink:

So, in 2 words, I need to reflect only the viewed polygons ???

It’s not a bad ideai, I’m gona try that.