PDA

View Full Version : relief texture mapping in fragment shader



thinks
03-16-2005, 01:34 PM
What I want to do is pretty simple. I want to warp a texture based on depth information for that texture. These two textures are simultaniously(?) available in the fragment shader thanks to multitexturing (is there a better way?). My output texture (which will be mapped normaly on to a GL_QUAD) will have values from the original texture, but these values will be in different texture coords, thanks to the depth-based warping. The problem is I don't have enough writing abilities from the fragment shader, since I am dealing with one fragment at a time. I would want to take a depth + color-value, warp it, assign the color to the warped texture coordinate in an image (optimally to the right fragment but this is not possible). I suspect this cannot be done using a fragment shader by itself, is this correct? This has lead me to look into GL_EXT_framebuffer_object and I am wondering if I could have access from my fragment shader to write to any position in the framebuffer (or are screen coordinates already decided in fragments? I suspect this), which can be retrieved, and mapped to geometry.

Am I clear enough? =)

A quite different approach is inverse relief texture mapping, where I for every fragment, look through the whole depth texture to see if any texels should be mapped to this fragment, a rather ineffective approach, but probably do-able.

Is GL_EXT_framebuffer_object even available from within a shader?

Comments and suggestions are much appreciated! =)

def
03-31-2005, 07:29 AM
If I understand your question correctly, you should think of the process in a different perspective.
Lookup the depth texture values for each fragment and depending on that value do a texture dependent lookup (most all current graphic card support this) in your texture you want to warp.
This way you would just do two texture lookups per fragment for the warped fragment.

thinks
04-03-2005, 07:48 AM
The only possible approach is the inverse relief texturing. The reason for this is that we cannot write to other fragments than the current one. However, this does not mean that the whole depth texture has to be search for every fragment. There are several shortcuts that make the algorithm much more effective! (I will not discuss them here)

/ T