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

Add Roughness float values to MetalRoughMap.cs #407

Merged
merged 1 commit into from
Apr 22, 2019

Conversation

rferrese
Copy link
Contributor

If the GLTF has a float value for the roughness, set it in the texture

{
get { return _material.GetFloat("_Glossiness"); }
set { _material.SetFloat("_Glossiness", (float)value); }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this render correctly? Glossiness is the inverse of roughness. I do see that MetallicRoughnessTexture in the cs files refers to MetallicGlossMap in the shaders. Is this an optimization to use the same variable to hold different values for the different shader variants? It seems odd to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very odd. Im not sure exactly what the deal is. In the PbrMetallicRoughness.shader file, it has
_Glossiness("Roughness Factor", Range(0.0, 1.0)) = 1.0
as the shader parameter. I tested in babylonjs (see pictures) and it renders the same in the editor with the change.

Best I can tell, is that PbrMetallicRoughness.shader and PbrSpecularGlossiness.shader both use UnityStandardInput.cginc, which uses _Glossiness. These shaders also use a couple unity internal cginc files, which I assume require the _Glossiness parameter as well. Though without digging through it, I can only speculate.

But, like I said, it works.

babylonjs (left) vs Unity (right)
image

@sbtron sbtron merged commit 15eaedd into KhronosGroup:master Apr 22, 2019
github-actions bot pushed a commit to Rhinox-Training/UnityGLTF that referenced this pull request Nov 9, 2022
Add Roughness float values to MetalRoughMap.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants