Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheen E LUT is not properly initialized #606

Open
taylor-santos opened this issue Feb 23, 2025 · 1 comment · May be fixed by KhronosGroup/glTF-Sample-Renderer#22
Open

Sheen E LUT is not properly initialized #606

taylor-santos opened this issue Feb 23, 2025 · 1 comment · May be fixed by KhronosGroup/glTF-Sample-Renderer#22

Comments

@taylor-santos
Copy link

I was examining the sample viewer's output in RenderDoc and noticed that the Sheen E LUT texture is just a single 1x1 black pixel:

Image

The expected texture is included in the glTF-Sample-Renderer repo under assets/images/lut_sheen_E.png and looks like this:

Image

The texture is sampled by the fragment shader in the albedoSheenScalingLUT function:
source/Renderer/shaders/material_info.glsl:431

float albedoSheenScalingLUT(float NdotV, float sheenRoughnessFactor)
{
    return texture(u_SheenELUT, vec2(NdotV, sheenRoughnessFactor)).r;
}

And examining the disassembled version of this line in RenderDoc's debugger we can see the sampled value (r0.z) is 0.00:

Image

The texture is supposed to be initialized here:
source/ResourceLoader/resource_loader.js:379:

environment.images.push(new gltfImage(luts.lut_sheen_E_file, GL.TEXTURE_2D, 0, undefined, undefined, ImageMimeType.PNG));
const sheenELut = new gltfTexture(lutSamplerIdx, [imageIdx++], GL.TEXTURE_2D);
sheenELut.initialized = true; // iblsampler has already initialized the texture
environment.textures.push(sheenELut);

Possible Solution:

Setting sheenELut.initialized = false instead, I can see that the texture is now loaded properly in RenderDoc:

Image

And we now see a non-zero sample in the debugger:

Image

With this fix applied, we see a very slight change in the appearance of materials using KHR_materials_sheen. Here are some side-by-side comparisons, ranging from most obvious to least:

Image

Image

Image

Image

Image

@andrewvarga
Copy link

I can verify this with babylon.js's Spector (webgl inspector), charlieLUT texture seems initialized but sheenELUT seems not:

Image

Somewhat related, but this line is also confusing a bit:
https://github.com/KhronosGroup/glTF-Sample-Renderer/blob/95ad8b4d2067e53337d34089c0ee06159c2ab4d3/source/ResourceLoader/resource_loader.js#L384

sheenLUT and ggx lut texture infos explicitly set the linear parameter to true a few lines above:

environment.lut = new gltfTextureInfo(environment.textures.length - 1, 0 , true);

but sheenELUT doesn't. The default is true so it's the same result but I think they should all either explicitly set it or none of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants