Jump to content
  • Advertisement
Sign in to follow this  
JohnnyCode

ddx ddy with a sampler returned value

This topic is 1160 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

I wonder if it is possible to use partial derivates, namely ddx and ddy, in GLSL, with a value returned by texture2D function.

 

Since ddx and ddy can operate only on interpolated fragment function inputs (true?), what would be most apropriate way to retrieve the texture samples at neighboiring pixels, is the only solution to fire multiple sampling functions with derived texture coordinates?

 

I do not want GPU to perform this:

 

sample bottom closest mipmap 1 texel- travel to upper closest mipmap for 1 texel - weight- repeat four times

 

rather pefrom this

 

sample bottom closest mipmap 4 neigbouring texels- travel to upper closest mipmap for other 4 texels- weight- done

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

dfdx and dfdy operate on any value you give it, it doesn't matter where it comes from, and it's not limited to the fragment shader inputs. The only thing you are not allowed to do is to assemble higher order statements of some kind (e.g. dfdx(dfdy(val))).

 

When you call the function, your GPU has information on the value given to the function in all invocations of the fragment shader in a certain neighborhood (e.g. 2x2 fragment grid). This information is what the GPU uses to give you a derivate using differencing in the pixel neighborhood.

Edited by agleed

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!