Single multi-purpose shader or multiple shaders using ShaderGraph for particles?

Hi,

wanted some input from anyone that has more in-depth knowledge in this regard.

Should I create a large shader or multiple shaders, specifically for use in particle system in this case. I’m mentioning particle system because I intend to utilize custom vertex streaming through the shaders.

Here is the problem that I run into and still in a dilemma as to how I should proceed with more shader creation. Initially, I used custom1.x and custom1.y to pan in the x and y respectively. Then I wanted to add depth detection, so I just included that in the original shader. Next feature was dissolve, and then fresnel. You get the idea, the shader started getting larger and larger and even though I was utilizing branch, can’t help but think it might be a waste of computing to have unused nodes/exposed values in the shader. But breaking them up and creating multiple permutations of combined features don’t really seem feasible as well.

I’ve did some reading up on whether to create a God shader or multiple smaller ones, but most of them are addressing shaders in hlsl with the include features.

For more context, on top of the features I mentioned, I have masking, dissolve edge glow, twirl and polar coordinates now, and they are controlled using a bool value.


This is currently how the shader looks like (yay or nay?), hope to get some enlightenment on this issue. Thanks!

You 100% absolutely need to look into shader funtions. Those will give you the best of both worlds. They’re nodes that contain chunks of logic that will propogate changes to other shader functions. They exist in shader graph, but from my experience using them is kinda wonky.

I use these shader funcitons for all kinds of stuff so that I can have propogating logic to various shader types. This way you aren’t really managing tons and tons of shaders, just key bits of logic you use in several shaders.

If you’re big into shaders, I suggest you look into amplify shader as well as IMO it’s a superior solution especially in regards to shader functions.