Yet another thread about shader chunks

I’ve been trying to texture a generated mesh but need to get to grips with understanding how shader chunks work.

From trawling the forums I know two things:

Shader chunks are not documented yet due to the rapidly changing API.

Shader chunks are better to use than vertex/fragment shaders as they take into account lighting and shadow information automatically.

I know some of the examples out there are good(3d earth) and provide a template for certain situations but there isn’t much info on the basic steps to building shader chunks and it’s various uses.

i want to blend 3 colours according to height on a mesh. Where should i start with that ?

Cheers

First you need to identify which shaderChunk you want to override.
Then you need to get it’s source. Pretty much all chunks are here: https://github.com/playcanvas/engine/tree/master/src/graphics/program-lib/chunks
Then you need to modify it and set to material.

We thinking of improving some shaderChunks API work, but bear in mind again: they do change, and things might break.

1 Like