3D Texture Gradient computation on the fly

Started by
1 comment, last by funkeejeffounet 19 years ago
Hi, I've been wondering if given a 3D texture and a shader pointing to one of its voxel, I could compute the gradient on the fly(most likely I'll be using a central difference). After looking at the GLSL spec, I found out the noise an backward/forward differences functions but I cannot apply them here. Someone told me it could be done but couldn't say how... Does anyone knows about this technique? Thanks, Jeff.
Advertisement
Just query the surrounding pixels and compute it yourself inside the pixel shader. Thats the best I can think of. I shall look into it and get back t you later.
Well that is what I actually do but I was hoping for an optimised built in function.

When fetching my neighbors in a central difference, the differential steps are proportionnal to the texture size.
Like if I have a 128*64*32 3D texture the steps would be :
1/128, 1/64 and 1/32

Thats is what annoys me as the code should be general, and using a uniform vec3(GLSL convention) doesn't suit me as my shaders are already "heavy".
Any ideas would be welcome :-)

Cheers, Jeff.

This topic is closed to new replies.

Advertisement