elm-explorations / elm-explorations/webgl

Texture colors altered on some browsers

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
123
Forks
17
PR merge metrics
No merged PRs in 30d

Description

I've noticed that on two occasions (once in someone's Firefox browser and I don't recall which browser the other person was using), textures would have some kind of color correction applied. This would cause problems for this app I'm working on https://town-collab.app where certain texture colors (such as FF00FF) get replaced with user chosen colors at runtime. The color correction causes the game to look like this
![image](https://github.com/elm-explorations/webgl/assets/5068391/0afc3057-3edc-4fac-b737-695084e6652d)

The fix was to add `gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, false);`. Ideally the webgl package should do this automatically though?

Perhaps also `gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);` should be used. I haven't encountered any problems with premultiplication but I suspect some browsers are going to randomly have different default values here too.

Edit: For reference, I got the two lines of code from here https://stackoverflow.com/questions/31500597/fragment-shader-wrong-color-value-from-texture

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.