We SERIOUSLY need Shader Chunk System Docs


#1

Delving in the dark magic of Shaders and trying to modify the Standard Material Shader I’ve seen that there’s zero documentation regarding the shader chunk system.

There is some (enough) to get you introduced to how GLSL works but for example. Yesterday I finished a nice grass shader with a slight sway animation, all was good, but I figured that it’d be cooler with PBR rendering on it, shadows, etc.

So I started delving into the shader chunk system and I encountered a lot of problems (some because of super old forum threads). Anyway, I achieved modifying the Vertex Shader correctly and it works as I want but now I see that for absolutely no reason, the Fragment Shader isn’t even applying the scene ambient color, no shadows, no nothing.

I haven’t applied any modification to the fragment shader, yet it ends up like this:

Now I have to figure out why the heck isn’t it using the Standard Fragment Shader which is the main reason I switched to modifying existing chunks… because I want all of the other features in.

This wouldn’t happen if there was documentation about shader chunks, how they work, simple examples on how to use, etc.

Please, whoever is in charge of the Shader Chunk System in the PlayCanvas team, save me of some frustration by explaining how it works so I can stop tweaking blind-mode.


#2

So I found this project: https://playcanvas.com/project/489836/overview/toon-shader-with-skinning

Which luckily is pretty new and works with the current shader chunk system.

In it, you can see how to implement custom parts of your own shaders both Vertex and Fragment ones without breaking other features up.

Sharing just in case someone gets stuck like I was, the key is to not override the main shader functions but key functions that won’t break up the other features, like getPosition for Vertex Shaders and getAlbedo for Fragment Shaders.

This is the result: https://twitter.com/devMidgard/status/1096504763364061184


#3

Any plans to release that grass shader :smiley:
Looks awesome, id pay for it as im sure others would too. unless you have a guide or tutorial you followed?


#4

The grass shader itself is super simple, literally a few lines of GLSL code, so I wouldn’t sell it.

It’s just grabbing the top 2 vertices of the grass mesh and moving them with math sin() multiplied by a timer that goes from -1 to 1 and 1 to -1.