Reflections with stencil buffer

I have been emplimenting what whas discribed in the NVidia white paper on using the stencil buffer for reflections and was wondering if anyone had come up with some optimizations for the code. I am using multiple mirrors and things are slowing down quite quickly as the mirror count goes up. Let me know.

Thanks
B

A way to improve speed (but not quality) is to use a lower LOD object for the reflection.
And to disable all the modes that can’t be really needed, for example you can render the real object and then use a “non textured flat shaded lower LOD object” to fill the stencil values for the shape of the mirror, then render the reflected object using a “lower LOD, linear texture filtered object”.

rIO
http://www.spinningkids.org/umine

I have been tryng stencil buffer mirrors too, but i’m rather disapointed with the speed, as you are. I believe that with blending we could achieve a much bigger speed than with stencil buffers…, i still have to try it.,

Bruno

I have actually made my program move in near real-time with upwards of 250 mirrors, but the model is very simple (1000 or so quads). I am also not to concerned about nice texturing, just solid shading which helps with speed…I think. The one thing I was going to implament, but havent yet is a viewing frustum to see if anything is going to show up in the mirror at all so your not drawing a whole bunch of things that are just tossed by the stencil buffer.

B

How can u do reflections without stenciling ?
Say we have an heart shaped mirror ? (yes, yesterday was valentine’s day )

rIO http://www.spinningkids.org/umine

If you can do a portal engine without stencil buffer, you can make a mirror without it as well. This is, because sectors need to be convex, and if they are, simply draw the sector behind the mirror, clear the depth buffer if you want and draw the completely transparent poly of the portal to where the mirror is.

That seems as though it would only work in very simple cases. Once you get many mirrors and complex orientations.

B

BBrown: 250 mirrors? Could we see a screenshot of that?

Bruno:
> with blending we could achieve a much bigger speed
Could you explain how you would do that?

Well, it works in any case, where the mirror is a portal of a convex sector. You find the least visible mirror in a mirror and draw it first. Then draw the others back->front.
I would also like to see that 250 mirrors demo…

Well, using blending, i would only need to invert the “room” that i’m drawing, and place just a blended texture over it, and there you have a mirror.
With the stencil buffer, i do exactly the same, but with the stencil test, and i think what is slowing down the stencil mirrors is the extra stencil cleaning.
BBrown --> 250 visible mirrors ?

Bruno

rIO, you can make complex shape mirrors without a stencil buffer by first drawing the mirror shape (alpha testing on of course) to the depth buffer only while the depth range is (0,0). This clears the depth buffer where the inside of the mirror is. Then draw it again to the depth buffer only, but with the range set to (1,1) and the alpha test reversed. Next determine the smallest screen aligned box that surrounds the mirror shape and set the scissor test to that region. Now you can draw the image in the mirror. And then finally, blend in the texture of the mirror itself.

Yes 250 mirrors, although they are not mirrors in the sense of mirrors on the wall. I am trying to model what a reflector looks like, so they are actually facets of a reflector. I can’t really show the picture to you guys because of legality issues, sorry. It moves kind of slow…except now I think I did somethiig bad to my graphics card or somethiing. Everything was fine and moving smoothly in real time…then I changed some code, but then changed it back because I decided I didn’t need it, and when I went to run it again it moves extremely slow! There were also visual artifacts on the screen (single incorrectly drawn pixels) and my reflections disapeared. I restarted the machine a couple of time and the same proble is still there. The other thing I tryed was to run Quake3 to see if it would run. The first time I ran it is was jumpy in the menu screen and I didn’t even start a game. After restarting the machine again I started Quake and when I tryed to start a single player game it just froze everything. I’ve done this three times. Any ideas??

B