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

[rmodels] Separate GLTF roughness and metallic channels on load #4739

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

Not-Nik
Copy link
Contributor

@Not-Nik Not-Nik commented Jan 29, 2025

Create separate textures for roughness and metallic values when loading GLTF/GLB files. No one interjected, so I just did the implementation of my proposal.

This doesn't break any examples, because the only GLTF+PBR example we have, loads its own texture files manually. I did test this with my own setup, where this creates the same behaviour as if doing the separation in an image editing tool before running, and then loading the textures, after loading the image.

For more info see #4715

for (int y = 0; y < imRoughness.height; y++) {
Color color = GetImageColor(imMetallicRoughness, x, y);

Color roughness = (Color) {color.g};

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable roughness is not used.
Color color = GetImageColor(imMetallicRoughness, x, y);

Color roughness = (Color) {color.g};
Color metallic = (Color) {color.b};

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable metallic is not used.
@raysan5 raysan5 merged commit bddb5df into raysan5:master Feb 2, 2025
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Feb 2, 2025

@Not-Nik Nice redesign, I think it's more consistent with raylib this way and will avoid confusions, despite the performance penalty involved...

Just a side note, format is not following raylib code conventions, I'm just reviewing it myself now.

raysan5 added a commit that referenced this pull request Feb 2, 2025
@raysan5
Copy link
Owner

raysan5 commented Feb 2, 2025

@Not-Nik While reviewing the function I got a doubt about the channels used by imMetallicRoughness, why are they G and B? Why not RG? It's always that way by GLTF specs? Also, I think GetImageColor() call can be avoided...

@Not-Nik
Copy link
Contributor Author

Not-Nik commented Feb 2, 2025

Just a side note, format is not following raylib code conventions, I'm just reviewing it myself now.

Ah, dammit. I always try to adhere, but my formatter is configured differently, and it messes is up sometimes.

It's always that way by GLTF specs?

Yes, the spec defines the values to be in these channels. I use the GetImageColor() in case of different formats (8/16/32 bit colors, un/compressed).

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_material_pbrmetallicroughness_metallicroughnesstexture

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.

2 participants