Hi guys i need some help. I used a vertexlit shader found on the internet that enable another material to section the object itself. My question is, how could i add the proprieties of another shader(compiled-Illumin-VertexLit.shader)??
The basic clip shader:
Shader "VertexLit Clipped" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
LOD 100
Tags { "RenderType"="Opaque" }
Pass {
Cull Off
Name "BASE"
Tags {"LightMode" = "Vertex"}
Material {
Shininess [_Shininess]
Specular [_SpecColor]
}
CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
#pragma vertex vert
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float4 uv[2] : TEXCOORD0;
float4 color : COLOR0;
};
uniform float4x4 _ClipTextureMatrix;
uniform float4 _Color;
uniform float4 _Illum;
v2f vert( appdata_base v ) {
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv[0] = v.texcoord;
float4 c = mul( _Object2World, v.vertex );
c = mul( _ClipTextureMatrix, c );
o.uv[1] = c;
// lighting from single directional light + ambient
float4 color = UNITY_LIGHTMODEL_AMBIENT;
float3 lightDir = mul( glstate.light[0].position.xyz, (float3x3)UNITY_MATRIX_IT_MV );
float ndotl = max( 0, dot( lightDir, v.normal ) );
color.xyz += glstate.light[0].diffuse * _Color * ndotl;
o.color = color;
return o;
}
ENDCG
AlphaTest Greater 0.1
SeparateSpecular On
Lighting On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
SetTexture [_ClipTexture] { Combine previous, texture }
}
Pass {
Cull Front
CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
#pragma vertex vert
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float4 uv[1] : TEXCOORD0;
float4 color : COLOR0;
};
uniform float4x4 _ClipTextureMatrix;
uniform float4 _SpecColor;
v2f vert( appdata_base v ) {
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
float4 c = mul( _Object2World, v.vertex );
c = mul( _ClipTextureMatrix, c );
o.uv[0] = c;
float4 zdir = float4(1, 0, 0, 0);
float4 faceN = mul( _ClipTextureMatrix, zdir );
// lighting from single directional light + ambient
float4 color = UNITY_LIGHTMODEL_AMBIENT;
float3 lightDir = mul( glstate.light[0].position.xyz, (float3x3)UNITY_MATRIX_IT_MV );
float ndotl = max( 0, dot( lightDir, normalize(faceN) ) );
color.xyz += glstate.light[0].diffuse * _SpecColor * ndotl;
o.color = color;
return o;
}
ENDCG
AlphaTest Greater 0.1
SetTexture [_ClipTexture] { Combine primary, texture }
}
}
Fallback "VertexLit"
}
Shader who i need to integrate with the previous one:
Shader "Self-Illumin/VertexLit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_EmissionLM ("Emission (Lightmapper)", Float) = 0
}
// ------------------------------------------------------------------
// Dual texture cards
SubShader {
LOD 100
Tags { "RenderType"="Opaque" }
Pass {
Name "BASE"
Tags {"LightMode" = "Vertex"}
Material {
Diffuse [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
}
SeparateSpecular On
Lighting On
SetTexture [_Illum] {
constantColor [_Color]
combine constant lerp (texture) previous
}
SetTexture [_MainTex] {
Combine texture * previous, texture*primary
}
}
}
Fallback "VertexLit"
}
My problem is that when i add SetTexture _Illum my material become grey without texture