Where is the light Chunk?

I want to modify the light chunk to have a tone shaded material, but I don’t seem to be able to find it.
combineDiffusePS didn’t work, diffusePS only changes the color with no light effect.

help

You can take a look at the full list of chunks here:

To find which chunks are included in your shader you can study the complete shader generated for your material. From there you can search the relevant method in the engine repo and find the chunk name.

Here are instructions on how to find the full shader definition:

You can also always do pc.shaderChunks in the console for a quick reference.

1 Like

Does this example help? http://playcanvas.github.io/#graphics/shader-toon.html

1 Like

I learned a lot. Yet, my goal seems far to reach.
I thought I could just multiply my color with an already calculated light vector and get away with it. Never thought I have to go very low level calculating light vector against normal and all that stuff :sweat_smile:

Blender shaders look like child’s play compared to this :sweat_smile:

@yaustar I managed after copying all of your code :laughing:
Guess now I can play around with it. :+1:

Actually, I figured out the chunk that needs to be modified.

Instead of modifying the combineDiffusePS, I should be modifying combineDiffuseSpecularPS for physical material, and combineDiffuseSpecularNoReflPS for phong material.

And thanks @Chris for the pc.shaderChunks trick. I could just do

combineDiffuseSpecularPS =
 pc.shaderChunks.combineDiffusePS.replace(
    "return dAlbedo * dDiffuseLight;",
     "WHATEVER I LIKE 8D"
 );

I finally understood what @Leonidas meant :laughing:

1 Like

That’s good! Just note that way you will be replacing that chunk for all materials in your app.

If you would like to update one or some materials only do this:

myMaterial.chunks.combineDiffusePS = pc.shaderChunks.combineDiffusePS.slice().replace(
    "return dAlbedo * dDiffuseLight;",
     "WHATEVER I LIKE 8D"
 );
myMaterial.update();

:+1: