Manually fetching mipmaps in a fragment shader using the three.js function

I am writing a physically based shader using glsl es in three.js. To add mirrored global lighting, I use the dmp cubemap texture with the internal mipmap network (precomputed using CubeMapGen, as he explained here ). I need to access this texture in the fragment shader, and I would like to manually select the mipmap index. The right function for this is

vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod)

but it is only available in the vertex shader. In my fragment shader I use a similar function

vec4 textureCube(samplerCube sampler, vec3 coord, float bias)

but it does not work because the offset parameter is simply added to the automatically calculated level of detail. Therefore, when I increase or decrease the scale of the scene, the LOD mipmap changes, but for my shader it should be the same (it should depend only on rough parameters, as described in the link above).

I would like to manually select the mipmap level in the fragment shader only depending on the roughness of the material (for example, using the formula mipMapIndex = roughness*numMipMap), so it should be restrained with distance and not automatically change when scaling. How can i solve this?

+4
source share
1 answer

webGL atm, . textureLOD, -, . :

-

WebGL textureCube,

+1

All Articles