Using textureGrad for anisotropic integration approximation

Posted by Amxx on Game Development See other posts from Game Development or by Amxx
Published on 2014-04-29T12:39:29Z Indexed on 2014/05/29 22:05 UTC
Read the original article Hit count: 438

Filed under:
|
|
|

I'm trying to develop a real time rendering method using real time acquired envmap (cubemap) for lightning.

This implies that my envmap can change as often as every frame and I therefore cannot use any method base on precomputation of the envmap (such as convolution with BRDF...)

So far my method worked well with Phong BRDF. For specular contribution I direclty read the value in my sampleCube and I use mipmap levels + linear filter for simulating the roughtness of the material considered:

int size                = textureSize(envmap, 0).x;
float specular_level    = log2(size * sqrt(3.0)) - 0.5 * log2(ns + 1);
vec3 env_specular       = ks * specular_color * textureLod(envmap, l_g, specular_level);

From this method I would like to upgrade to a microfacet based BRDF. I already have algorithm for evaluating the shape (including anisotropic direction) of the reflection but I cannot manage to read the values I want in my sampleCube.

I believe I have to use

textureGrad(envmap, l_g, X, Y);

with l_g being the reflection direction in global space but I cannot manage to find which values to give to X and Y in order to correctly specify the area I want to consider.

What value should I give to X and Y in orther for

textureGrad(envmap, l_g, X, Y);

to give the same result as

textureLod(envmap, l_g, specular_level);

© Game Development or respective owner

Related posts about opengl

Related posts about cubemap