- Home /
asign surface shader to material
Thanks people, i learned a lot by following questions & answers around here! But one point i have been somehow missing (also in unity reference) was how to get a surface shader script onto the material i want it for... how to attach / assign it. Its a cull of diffuse shader script i got from here, for my curtain simulation to be double sided visible.. if (youcanhelpme) {Thx = a lot;]
Shader "Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "VertexLit"
}
Answer by Bunny83 · Jun 08, 2011 at 07:10 PM
Just give it a proper name, then you can select it like all shaders...
Shader "MyShaders/Diffuse"
{
[...]
}
Answer by jooki-2 · Jun 08, 2011 at 08:00 PM
man, i am too stupid for shading! Could somebody please tell me where to add the cull off command in the shader script above?!?
Don't post questions as answers....
Anyway, You can put it either in the subshader or inside a pass. since you don't have a pass add it below your LOD.
Don't add it to the cg-section because there you can only use cg of course.
Oh and watch your code highlighting... i've fixed it two times now ;) Just select the code and press the 010101 button. It will indent every line by 4 spaces and will insert a empty line before and after the block. That's how this page "marks" the text as code.