Skip to content

Fix logic errors and exception in SpecGloss pipeline #2387

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

Merged
merged 3 commits into from
Mar 8, 2025

Conversation

yaRnMcDonuts
Copy link
Member

@yaRnMcDonuts yaRnMcDonuts commented Mar 6, 2025

This PR addresses this issue:
#2386
And then I also found another critical logic error in the spec gloss pipeline that was likely there even before riccardo adapted the shader to use structs:

It looks like the specular and glossiness value taken from specularMaps was being totally ignored and the glossiness value was not being accounted for in the final roughness calculation. The code further down in the shader was calculating the roughness solely based on m_Glossiness with no regard for the glossiness scalar read from texture maps, which is incorrect.

The logic error and exception should all be fixed in this PR now, but it will need testing from a spec gloss model with packed specularGlossinesMap as well as a model with seperate specular and glossiness maps in order to ensure everything works properly now.

This PR addresses this issue: 
#2386 
And then I also found another critical logic error in the spec gloss pipeline that was likely there even before riccardo adapted the shader to use structs:

It looks like the specular value taken from specularMaps was being totally ignored and not used in the roughness calculation. The code further down in the shader was calculating the roughness solely based on m_Glossiness with no regard for the glossiness texture maps, which is incorrect.

The logic error and exception should all be fixed in this PR now, but it will need testing from a spec gloss model with packed specularGlossinesMap as well as a model with seperate specular and glossiness maps in order to ensure everything works properly now.
@yaRnMcDonuts
Copy link
Member Author

I also condensed and cleaned up the code.

Some lines of code were repeating in the packed and non packed specular and glossiness texture reads, and as a result past editors ended up applying changes to one spot and not the other, leading to inconsistent functionality when using packed vs non packed maps.

@yaRnMcDonuts yaRnMcDonuts added this to the v3.8.0 milestone Mar 6, 2025
@yaRnMcDonuts yaRnMcDonuts linked an issue Mar 6, 2025 that may be closed by this pull request
@stephengold stephengold added the bug Something that is supposed to work, but doesn't. More severe than a "defect". label Mar 6, 2025
@stephengold
Copy link
Member

I built a local snapshot of JME at Git hash 154022e and re-ran the test that uncovered issue #2386.
There was no crash, and the rendered model matched my expectations, so I believe this PR will solve the issue.

@yaRnMcDonuts
Copy link
Member Author

I also tested a model with a packed specGloss map and it renders properly now too. So I will merge this in the next 24 hours

@yaRnMcDonuts yaRnMcDonuts merged commit e9049b5 into master Mar 8, 2025
15 checks passed
@yaRnMcDonuts yaRnMcDonuts deleted the yaRnMcDonuts-patch-2 branch March 8, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to work, but doesn't. More severe than a "defect".
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implicit cast from "vec4" to "vec3" in PBRLighting.frag
2 participants