Both reading and writing depth through shaders
Hey everybody,
Some time ago, I posted the problem of a fragment shader I was working on;
i could either read from an FBO-attached texture resembling the depth,
or write to gl_FragColor with values indirectly received from sampling
another FBO-attached texture.
Doing both things in one go didn't seem possible (ex. Multiplying the depth value with the other values, then writing them to the fragment.)
I managed to convert the depth into a nice 0.0 - 1.0 scale, for test/eyecandy reasons, so that part's probably ok.
If you have any experience with this, please let me know. It's been bothering me for weeks, and i haven't been able to figure out a solution.
Also, I would like to know how, if it's possible, to write to a depth buffer,
and for the next primitive, be able to access the new depth values from a texture.
I don't know if a texture attached to an FBO will just update to the actual depth buffer values that fast.
Hope you can and will help, -thanks in advance!
You can't bind a texture to read into a shader and have the same texture bound as part of an FBO that you're using for output. You can write to a depth buffer just by writing to gl_Depth in your fragment shader.
It sounds like what you need to do is set up two depth buffers and use them in a ping-pong fashion using one as input and the other as output and then swapping.
It sounds like what you need to do is set up two depth buffers and use them in a ping-pong fashion using one as input and the other as output and then swapping.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement