Help with shaders chunks

Where I can read about all chunks from material.chunks?

Hi @KpoKec,

Shader chunks are still an unofficial API, so for the moment you can find information mostly by studying the engine code and looking around at the forum.

You can check the following example project on how to override a shader chunk with your own GLSL code:

https://developer.playcanvas.com/en/tutorials/tutorial-plasma-shader-chunk/

And here is the full list of all shader chunks available to override:

Diffuse and emissive chunks works. I need opacity chunk name because diffuse not using alpha.

It shouldn’t be any different, here is an example that overrides the opacity channel:

https://developer.playcanvas.com/en/tutorials/warp-a-sprite-with-glsl/

src\graphics\program-lib\standard.js
starts from 90 line

Sorry, what do you mean?

Description of all chunks in source from github

I don’t think there is something like that right now, since it’s an unofficial API for the moment.

It’s a good suggestion for the future.

When I need to change some chunks, I’ll set up material properties to get me as close as possible. Then I capture the frame using Spector JS, and look at the shader that is used to render that material. I then identity what part of shader code I would need to change, and find that code in the chunks here:
https://github.com/playcanvas/engine/tree/master/src/graphics/program-lib/chunks, and then work on replacement chunk.

4 Likes

I find material.chunks.opacityPS
Line 120 at https://github.com/playcanvas/engine/blob/master/src/graphics/program-lib/standard.js

Use workaround instead engine features - not good solution.