Hi, I’m trying to get multi_compiled materials working. I’m having trouble figuring out why it doesn’t seem to be executing the code within my #if block. First, here’s my shader:
Here’s what the ‘shaderKeywords’ property of my material looks like: http://screencast.com/t/Qx1wDMdmvdP
(Note “OCCLUSION_ON” as the sole entry in the list)
However, the code inside my OCCLUSION_ON block doesn’t appear to be executing ( my alpha is at full 1.0). However, if I comment OUT the #if/#endif directives, my meshes look properly faded out. Does anyone see anything obviously wrong with my shader, or how I’m using the #if directive? I’ve tried:
I dont know, it looks right, try switching it on and off with this:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class ShaderManager : MonoBehaviour {
// Store the camera
public Camera cam;
public Texture2D tex;
// Before the object gets rendered
public void OnWillRenderObject ( ) {
cam = Camera.current;
if( !cam )
return;
Shader shader = renderer.sharedMaterial.shader;
}
void OnEnable() {
Shader.EnableKeyword("IS_SIMPLE"); // My custom keyword
}
void OnDisable() {
Shader.DisableKeyword("IS_SIMPLE"); // My custom keyword
}
}
i am running this:
#pragma multi_compile VERSION_ONE VERSION_TWO
#ifdef VERSION_ONE
some maths
#endif
#ifdef VERSION_TWO
some other maths
#endif