Shader chunks: Overriding "texture2DBias()"

Hei,

Currently doing a lot of shader chunk editing, and I had this idea:
“What if I were able to override the texture2DBias() function?”

It’s used in basically all the different shader chunks to sample the different texture maps. Its also clearly a custom function since its not part of standard glsl. So being able to re-write this would allow for a consistent change to how all the texture maps of the materials are read. Meaning lots less work if say, you wanna do some funky changes to the texture tiling or something similar.

So I had a look through the PlayCanvas engine code and sure enough it looks like it’s defined in these three scripts:

I tried treating these as shader chunks overriding material.chunks.gles2PS, material.chunks.gles3PS and material.chunks.webgpuPS. The compiler does not complain about these not being shader chunks, but neither does it seem to actually react to any changes I make to them.

Anyone got any ideas?

Yeah, you can’t treat them as chunks. The engine imports them directly, so not sure there is an easy way to override. Maybe @mvaligursky has an idea.

Nothing comes to my mind, other than a custom engine build. These are not chunks, but a platform (WebGL1, 2, WebGPU) compatibility macros and similar to allow us to compile a single shader to all those platforms.

Ic… that makes sense.

Thank’s anyways :slight_smile: