Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualskytiger

Posted 06 December 2012 - 04:57 PM

I see now!

float2 dx = ddx(uv.xy);

ddx() is returning a vector in texture space

The original code was calculating a lod level manually to allow for sampling neighbouring pixels (in DX9)
[source lang="cpp"]float MipMapLevel(in float2 uv, in float2 textureSize) { float2 dx = ddx(uv * textureSize.x); float2 dy = ddy(uv * textureSize.y); float d = max(dot(dx, dx), dot(dy, dy)); return log2(sqrt(d)); }//function// then I can use tex2Dlod() with correct pixel offsets for manual interpolation[/source]
also, from my testing on an ATI3870, fractional LOD levels seem to cause blending between mip levels
so I need to round or truncate my lod level before calculating the pixel offsets

thanks MJP (edit: and Matias, good point)

#2skytiger

Posted 06 December 2012 - 04:57 PM

I see now!

float2 dx = ddx(uv.xy);

ddx() is returning a vector in texture space

The original code was calculating a lod level manually to allow for sampling neighbouring pixels (in DX9)
[source lang="cpp"]float MipMapLevel(in float2 uv, in float2 textureSize) { float2 dx = ddx(uv * textureSize.x); float2 dy = ddy(uv * textureSize.y); float d = max(dot(dx, dx), dot(dy, dy)); return log2(sqrt(d)); }//function// then I can use tex2Dlod() with correct pixel offsets for manual interpolation[/source]
also, from my testing on an ATI3870, fractional LOD levels seem to cause blending between mip levels
so I need to round or truncate my lod level before calculating the pixel offsets

thanks MJP (edit: and Matias, good point)

#1skytiger

Posted 06 December 2012 - 04:55 PM

I see now!

float2 dx = ddx(uv.xy);

ddx() is returning a vector in texture space

The original code was calculating a lod level manually to allow for sampling neighbouring pixels (in DX9)
[source lang="cpp"]float MipMapLevel(in float2 uv, in float2 textureSize) { float2 dx = ddx(uv * textureSize.x); float2 dy = ddy(uv * textureSize.y); float d = max(dot(dx, dx), dot(dy, dy)); return log2(sqrt(d)); }//function// then I can use tex2Dlod() with correct pixel offsets for manual interpolation[/source]
also, from my testing on an ATI3870, fractional LOD levels seem to cause blending between mip levels
so I need to round or truncate my lod level before calculating the pixel offsets

thanks MJP

PARTNERS