tags:

views:

59

answers:

1

Hi,
I was wondering what is the best way to go about comparing a pixel that is currently being rendered (and accessed using a fragment shader) to a pixel with the same location in a previously stored unbound texture (both textures are the same size)?

+1  A: 

Now that the question is more clear, it's possible to give an answer.

The main issue is that the framebuffer contents and the fragment parameters (position) are not available in the fragment shader. Indeed, you can't execute the "compare" operation while rendering.

You have to render the model in a texture (search for render to texture, using frame buffer objects), and then run a fragment shader (maybe using GL_texture_rectangle) on a otho view with a viewport of the same size of the texture.

The fragment shader shall have two textures as input: the first texture (containing detected edges) and the texture-rendered wireframe model. Then, it's easy to perform complex computation in the fragment shader once you can access to each textel of both textures.

Hope this can help you.

Luca
Is it possible to do this by projecting the texture onto the model using projective texture mapping?
Brett
I cannot naswer: all depends on the the specific texturing paramateres (values, coords...).I would suggest for your task (comparing pixels) the http://en.wikipedia.org/wiki/Cross-correlation: i've used to search volumes in 3d images. THe main advantage is that it search for pixel variations, instead of pixel values (indeed is pixel intesity independent).
Luca