Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ALX

Curved reflectors

This topic is 5399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Trying to do some reflections on curved surfaces. Unfortunately, not too successfull... The problem is how to find the reflection normal (or tangent) needed to reflect a vertex from an object outside of the reflector. My objects are fairly tesselated, so the distortions due to the curved reflection should be captured quite well. But I just can''t find a good way to determine the normal of reflection on the reflector surface in a hardware friendly way. Planar reflections are trivial: just flip the vertex around the plane. On arbitrary meshed reflectors, the usual way seems to be an explosion map. The reflection ray is computed (easy), intersected with the explosion map (also easy), and the resulting value from the map (readback: hard !) used as triangle index to interpolate the normal/tangent using barycentric coordinates (easy). The problem is the readback from a map in a vertex shader. AFAIK, that is only possible using the omnious Uberbuffers, that are not yet widely available on consumer level hardware. One could do it on the CPU, but I don''t want to touch every vertex (they are usually streamed directly to the GPU). I''m stuck. I thought about loading a very low res version of a reflector normal map into the constant registers, and use the addressing operator in a vertex shader to simulate a lowres texture map lookup. But I''m not sure if the number of registers is enough to accurately represent an explosion map. It will probably be too lowres ? I also tried simple environment mapping, but this doesn''t cut it, as the reflector is rather large and reflects lots of local objects. Any ideas ?

Share this post


Link to post
Share on other sites
Advertisement
If you're willing to mess with pixel shaders, you could calculate the map coords in a vertex shader, and store them in the texture coordinates of another texture unit. These will then be interpolated across the face, and will be easily accesible in the pixel shader. You then use the pixel shader to access the map using the interpolated coordinates.

Note that it might be possible to store the corodinates elsewhere - I don't know all the possibilities. The only requirement is that they get interpolated accorss the face and are accesible in the pixel shader.

EDIT: It might also be possible to combine the vertex program with standard fixed-function (or similar) environment mapping (without a pixel shader)...

Michael K.,
Co-designer and Graphics Programmer of "The Keepers"



We come in peace... surrender or die!

[edited by - technobot on March 1, 2004 10:35:34 AM]

Share this post


Link to post
Share on other sites
Thanks for your reply.

quote:
Original post by technobot
If you''re willing to mess with pixel shaders, you could calculate the map coords in a vertex shader, and store them in the texture coordinates of another texture unit. These will then be interpolated across the face, and will be easily accesible in the pixel shader. You then use the pixel shader to access the map using the interpolated coordinates.


Unfortunately, this won''t work. The map readback is used to displace a vertex/pixel pre-projective position, so that it will get in the right spot to create the reflected image. But pixelshaders cannot change a fragments x,y position, only the post-projective depth value can be modified. The displacement needs to be performed per-vertex, there is no other possibility.

I guess that currently, I only have two options:

*) wait for uberbuffers to be commonly available (could take another year or so)

*) until then, stick with curved reflector surfaces that can be analytically evaluated in a vertex shader (spheres, arcs, cylinders, Bezier patches).

Damn, why are curved reflectors so much harder than the trivial planar reflectors... They look so much cooler than the later ones

Share this post


Link to post
Share on other sites


This will certainly kill your frame rate but just treat each poly like its own mirror.

Lots of stencil clears though

Or maybe you could render each poly to the stencil at a differnt number

Then render the scene for each poly and only accept each number for what poly your reflecting of.

That only solves the clearing problem, not the rendinger the same scene 100 times.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!