Recently I’ve been toying around with shaders again and noticed that in quite a lot of cases I have to copy paste stock shaders. Let’s say for example, a low poly water shader. It needs a custom vertex shader, but a stock PBR frag shader would do just fine. Now what I would probably end up doing is copy pasting PBRLighting.frag and throwing out the parts I don’t need, but that feels like a lot of work for just trying to reuse a shader.
Is there a way to properly reuse stock frag/vert shaders?
I think you may be looking for shader nodes.
I put commonly used chunks into a glsllib file.
What the Toucher says: The Engine already has some glslibs for instance for animation it seems, so you can use them. For PBR you might need shader nodes otherwise though I guess.
Or would it be possible to move PBR into glsllibs so everyone can “DIY” his PBR Shaders? @nehon
Given the level of complexity involved in working with a PBR shader, I think duplicating the existing PBRLighting is simple enough. Pulling out all the functionality to a lib would still require a bare bones shader to duplicate anyway.
I still have to push a shader node version of the PBR shader.
I have an uncomplete one locally, but it needs more work. In the mean time, duplicating the shader doesn’t seem like that much work.
I found subdividing every shader in different shader nodes really comfortable. Also, it is useful to store common procedures in glsllibs like toucher said.