I need to use custom keywords in my cg shader, but so far I can't get them working. I looked at the Water4 shader and scripts - since it uses custom keywords - and tried to setup my files the same way, but so far I can't get it to work.
Here's my shader( my custom keyword is in the "surf" function ):
And here's my script:
I should mention that the script is NOT in the same folder as the shader, and that I am not using Unity Pro. I'm using Unity 3.5 iPhone basic.
I can't find any documentation on this issue, so I need a shader guru's help hehe :)
asked Mar 16 '12 at 05:36 PM
Hi you will notice that the water shader does this at the start:
What this is saying is that the compiler needs to generate a permutation of the shader for each of those defines. There will be 3 combinations generated. One each for WATER_REFLECTIVE, WATER_REFRACTIVE, and WATER_SIMPLE.
The shader compiler is very explicit about the permutations it generates. So if you have multiple flags that you want on / off use multiple multi_compile pragmas.
Will generate these permutations:
You do not need to use a given flag.
In your example you would do:
This would generate two permutations, one with IS_SIMPLE set one with IS_ADVANCED set. You don't need to use IS_ADVANCED.
Let me know if you have any further troubles.