How to use sRGB texture encoding with ShaderMaterial / glsl?

I am trying to port a shader effect where the texture is expected to be sRGB, it is a threshold effect and I have noticed that the filtered pixels are what I would get if the texture was encoded as Linear(default).

I have tried to update encoding via JS to THREE.sRGBEncoding, like the docs describe, but this doesn’t seem to have an effect on ShaderMaterial/glsl?

maybe if you do mapTexelToLinear (texture2D (imageTexture, coordinates)) you will get the conversion you want?

That does not appear to do anything. I will try put together a small reproduction of the issue to share and better demonstration the problem.

Using LinearTosRGB() appears to solve the issue for me. Are these listed/documented somewhere, or must source code for ShaderChunks be inspected for them?

I had heard we were meant to #include these but that doesn’t seem to work, at least for ShaderMaterial, methods like this and the one you mention are available by default.

Unfortunately no, the shaders have a lot of convenience functions that only live in the chunks. Another caveat is that the shader code is not always enough to inspect, as somelogic is created dynamically based on how encoding is set on various textures.

But not with ShaderMaterial? Texture encoding parameter seems to have no effect, instead you need to know about this beforehand and stumble across those undocumented shader chunks.