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

Handle shader-decoded texture alpha correctly #4440

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented Jul 15, 2022

This PR fixes a shader compile error resulting from user choosing the alpha channel of a decoded texture. (This is because the decoding step takes a vec4 and returns a vec3 so alpha doesn't exist).

Since there is never actual decoding of texture alpha (i.e. gamma textures don't correct alpha and RGBM/P/E textures use alpha channel to reconstruct RGB) we just add a passthrough for this case instead.

Also move textureSample.js chunk to the correct location.

@slimbuck slimbuck added bug area: graphics Graphics related issue labels Jul 15, 2022
@slimbuck slimbuck requested a review from a team July 15, 2022 08:10
@slimbuck slimbuck self-assigned this Jul 15, 2022
@mvaligursky
Copy link
Contributor

I just wonder - how come textures stored in sRGB don't gamma correct the alpha channel? If I'm reading this right.

@slimbuck
Copy link
Member Author

if I'm reading this right.

Yep you are: alpha is just never stored in gamma space (presumably because it's not a color value).

@mvaligursky
Copy link
Contributor

Ah, looking online, it certainly seems to be the case!

@slimbuck slimbuck merged commit ed0ccb0 into playcanvas:main Jul 15, 2022
@slimbuck slimbuck deleted the decode-alpha-fix branch July 15, 2022 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants