Question

I want to make a couple of GPU textures using perlin noise and whatnot, so I have this big shader that have all those perlin, simplex, voronoi noises functions and then just make a new shader that extends the big one having just one function with stuff like:

color = perlin(x, y, z) + perlin(x*10, y*10, z*10) / voronoi(x,y,z);

Is it possible? What is the best approach? I will end up making one shader per texture, so it will be a lot of shaders and I would prefer to avoid having to copy/paste all of these functions, especially if I ever need to remake one of them

Was it helpful?

Solution

Move the common code into .cginc or .glslinc files and include them with the #include statement. Also see this question on answers.unity3d.com.

Another approach is to use the UsePass command.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top