Sign in to follow this  
Luzzy

OpenGL dFdx issue

Recommended Posts

Hi,

I haven't usel GLSL for a while. And now I have a problem with dFdx/dFdy.

I need the derivative of the texturecoordinates in order to implement an algorithm.

I use the OpenGL shader builder, which comes with Mac os x; however for the plane and torus example the results are pretty good for the teapot and the sphere the results are very poor. I think it is because the latter examples have a very low resolution.

Now my question:
I thought for a varying variable dFdx/y should give the interpolated values (like figure 17.5 http://www.yaldex.com/open-gl/ch17lev1sec4.html). But, If I have a look only at the absolute value of the dFdx funktion output, this doesn't seem interpolated.

Did I missunderstand something? Or is there an error in the use of the dFdx funktion.

Sorry, I had had a look in the internet but couldn't find a solution and it is a very tiny code snipet maybe someone can help me.

Fragmentshader:

int texSizeX = 256;

void main()
{
float dsx = abs(dFdx(gl_TexCoord[0].s * float(texSizeX)));
gl_FragColor = vec4(dsx,0.0,0.0,1.0);
}



Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this