Hi,
I am trying to create a material by using a string for the shader parameter as described here: http://unity3d.com/support/documentation/ScriptReference/Material.Material.html (the first constructor).
This works for shaders that are very simple and have no lighting, but slightly more complex shader can not be loaded this way. I have looked through all the documentation and have not been able to find a description of what is and what isn't allowed in materials created from string.
This is the shader I am trying to load (taken from the shader lab documentation):
Shader "Testshader" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#include "UnityCG.cginc"
struct v2f {
V2F_POS_FOG;
float3 color : COLOR0;
};
v2f vert (appdata_base v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.color = v.normal * 0.5 + 0.5;
return o;
}
half4 frag (v2f i) : COLOR
{
return half4( i.color, 1 );
}
ENDCG
}
}
Fallback "VertexLit"
}
And I am loading it this way:
renderMat = new Material( File.ReadAllText( Application.dataPath + "/Data/Temp/Resources/testshader.shader" ) );
It is very important that I be able to load a shader from a string for the work I am currently doing.