-
Notifications
You must be signed in to change notification settings - Fork 243
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
Specular color and diffuse transmission color textures should be non-linear #596
Specular color and diffuse transmission color textures should be non-linear #596
Comments
I do not think that this issue is related to texture encoding. |
@UX3D-haertl in the attached file, the KHR_pbrSpecularGlossiness extension was already removed and replaced with metallic roughness, specular, and IOR. I believe the problem is in the support for KHR_materials_specular here: The gltfTextureInfo class has linear=true as its default, which I assume should be overridden for specularColorTexture as is done for the baseColorTexture: |
We already set linear to false for specularColorTexture in specularTexture should be linear from the spec. When I convert the asset with Gestaltor, I do not have any issues: |
I just tested the conversion with gltf.report and it seems to be indeed a bug on their end. |
@UX3D-haertl I've made this choice intentionally in glTF Report and glTF Transform, and will not be splitting the two textures (doubling VRAM). I'm not aware of a viewer other than the sample renderer that fails on this case. |
You're right. In this case we need to change the sampler format based on the material property and not the texture. |
I opened a PR which now checks all TextureInfos to determine the final format of the texture. |
Thank you @UX3D-haertl, that was fast!
I have seen other cases. For example, baseColor (sRGB) and occlusion (linear) both using the RGB channels of the same texture. But — in my opinion — that is user error and not something engines must handle at runtime. Thoughts welcome on this though, the discussion is still open: |
I noticed that a particular .glb was rendering differently from all the other engines (three.js, babylon, playcanvas) - see attached glb:
SpecGlossVsMetalRough-converted.glb.zip
This is the SpecGlossVsMetalRough model dropped into gltf.report which converts the specular-glossiness material to metallic-roughness.
The rendered result of these should be the same but the converted material renders differently because of incorrect texture encoding (thanks @donmccurdy for pinpointing that):
One solution is to set linear to false on the specular color texture (and diffuse transmission color texture). But I think both the specular color and the specular texture needs to be set to
linear = false
for this to take effect because this model uses the same image resource (and the same webgl texture) for these 2 texture slots, andSRGB8_ALPHA8_EXT
internalFormat is not going to be used if specular texture is not set tolinear = false
.Another approach is to switch to decoding in the shader but that would be a bigger refactor.
The text was updated successfully, but these errors were encountered: