tags:

views:

76

answers:

1

The question is fairly self explanatory. I'm asking in terms of using texture coordinates that could have come from anywhere (a uniform, a varying, another texture fetch).

Say for example I do a texture fetch on a mipmapped (or anisotropically filtered) texture, and I use the square of a varying which was set in the vertex shader. I assume that glsl cannot determine the derivative of an arbitrarily complex function like this, so how does it know which mip level to use?

Thanks.

+3  A: 

it is usually using spacial coherence. it computes the same value on a block of at least 2x2 pixels, and computes the discrete difference between the neighbors. That's enough of an approximation for the derivative.

Bahbar
Thanks. I added spacial coherence to my Google searches (didn't occur to me before) and it turned up this...http://developer.amd.com/media/gpu_assets/03_Clever_Shader_Tricks.pdf. Confirms what you say and comes with some advice on how to deal with branching difficulties relating to this.
DaedalusFall