How to merge two shaders

Here is the situation:
i have a shader and want to write another shader that is a slight modification of previous one - it takes result from first shader applies some modifications and outputs result.

For example: i have a shader that implements simple diffuse lightning and i want to a have shader that implements diffuse lighting and inverts colors(for example) but i don’t want to reimplement diffuse lightning one more time.

Is there a way for such thing?

Actually, your question title tells you exactly what you need to do. You cannot feed data from one shader to another, but you can combine the work that is done from multiple shaders into one.

Computers don’t care what you do or don’t want to do. :slight_smile:

But think of it this way; you don’t need to reimplement your diffuse shader; just copy paste it into the new one!