Mipmap level in prefiltered cubemap for interior

Hi guys,

I just want to know is there any way to select the mipmap level for the prefiltered cubemap for interior (not for the skybox in the rendering settings)

What I want to achieve is to set different mipmap levels for different materials (mirror refection with highest level, or floor reflection with low level, etc) I hope I make my point clear.


Hi @Trong_Hieu_Nguyen,

From what I know that isn’t possible using the engine API but you may be able to do so by updating a shader chunk.

Here is how the shader program for the prefiltered skyboxes is written (note the mipmapIndex param):


And here is the generic reflectionCube shader chunk:

It uses a plain version of the fixSeams method, but there is an overloaded method that takes as a second parameter the mipmapIndex:

I haven’t tried it myself but I am thinking potentially you can add a custom uniform to inject your desired mimapIndex to the reflectionCube shader chunk and update the fixSeams() method to use it.


Hi, thanks for your suggestion. I follow your tips but it doesnt seem to work.
Here is the shader code

uniform float mipmapIndex;
vec4 calcReflection(vec3 tReflDirW, float tGlossiness, float tmaterial_reflectivity, float mipmapIndex) {
    vec3 lookupVec = fixSeams(cubeMapProject(tReflDirW), mipmapIndex);
    lookupVec.x *= -1.0;
    return vec4($textureCubeSAMPLE(texture_cubeMap, lookupVec).rgb, tmaterial_reflectivity);

And here is where I pass the parameter in:

var ShaderManager = pc.createScript('shaderManager');

ShaderManager.attributes.add('mipmapIndexProp', { type: 'number', default:3 });

// initialize code called once per entity
ShaderManager.prototype.initialize = function() {
    var mipmapShader = this.app.assets.find("SetMipMap").resource;
    var meshes = this.entity.model.model.meshInstances;
    var dinnerTableMesh = meshes[23];
    var mat = dinnerTableMesh.material;
    mat.chunks.reflectionCube = mipmapShader;
    mat.setParameter("mipmapIndex", this.mipmapIndexProp);

There is no error in the debugger console. But upon changing to any mipmapIndexProp value, the result doesnt create the correct type of blurry or clear cubemap, unlike the setting for skybox.

Hi @Trong_Hieu_Nguyen,

Not sure what’s wrong here, I haven’t tried this myself.

Try submitting an issue about this in the engine repo, if it’s a missing shader feature that’s causing this it may be a good feature request.