Created
March 16, 2015 19:15
-
-
Save bazhenovc/e53295d52e1f4372ca99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float CalcMipLevel(float2 inUV) | |
{ | |
float2 uv = inUV * kAtlasedTextureSize; | |
float2 du = ddx(uv0); | |
float2 dv = ddy(uv0); | |
float d = max(dot(du, du), dot(dv, dv)); | |
const float r = pow(2, (kMipCount - 1) * 2); | |
d = clamp(d, 1.0, r); | |
return floor(0.5 * log2(d)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment