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

PBRLighting.j3md: annotate LightMap as being a LINEAR texture #2139

Closed
wants to merge 1 commit into from

Conversation

stephengold
Copy link
Member

This PR should eliminate the distracting/confusing warnings currently generated when the same texture is specified for both LightMap and another PBR map.

@stephengold stephengold marked this pull request as draft November 1, 2023 16:44
@stephengold
Copy link
Member Author

This change eliminates some runtime diagnostics like this one:

Nov 04, 2023 11:44:39 PM com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Models/Tank/Tank_Occ_Rough_Metal.png has linear color space, but the material parameter LightMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().

@stephengold stephengold marked this pull request as ready for review November 5, 2023 06:47
@riccardobl
Copy link
Member

Is the light map supposed to be linear? It is sampled as color, so i would say it should be sRGB, but i genuinely don't know what is the consensus for light maps.

@stephengold
Copy link
Member Author

The only evidence I have one way or the other is that it's common to specify the same texture for both "LightMap" and "MetallicRoughnessMap" (with "LightMapAsAOMap" set to true). Since "MetallicRoughnessMap" specifies -LINEAR it makes sense that "LightMap" should also.

@riccardobl
Copy link
Member

It seems that when LightMapAsAOMap is true the lightmap is used as ao map that is a grayscale linear texture that can be specified as -LINEAR.
But when it is used as an actual lightmap, it contains colors and so it should be sampled as sRGB.

@stephengold
Copy link
Member Author

@riccardobl How inconvenient!
Perhaps a better solution would be to have distinct material parameters for the light map and the AO map.
What do you think?

@riccardobl
Copy link
Member

We have so many possible combinations in our PBR shader at this point, but my understanding is that if the AO map is the R component of MetallicRoughnessMap, it should be used by setting AoPackedInMRMap.
While LightMapAsAOMap should be used when the AO map is standalone and provided using the LightMap field.

@stephengold
Copy link
Member Author

PBRLighting.j3md does seem needlessly complex.

So if "AoPackedInMRMap" is true then the AO map is linear, but if "LightMapAsAOMap" is true then the AO map is sRGB?

@riccardobl
Copy link
Member

AO is always linear, but the lightmap is linear if it contains only AO or sRGB if it is a full lightmap

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