Hi everyone, tks for your time.
Im working in a Iphone project with Unity, and I´ll need a shader that have.
Diffuse + Reflection (im trying a simple 2d and not a cubemap) + SelfIllum. I want to use the Diffuse Alpha to modulate the reflection and i want to use a RGB color to control the selfIllum (so i can in real time, make it turn on and off smooth).
The problem is im pretty much a noob with shaders (or coding) , and what I did was to change the default Mobile/Legacy/Lightmap/Reflective to fit my porpouses… and that works in windows… but already inside the Mac preview it dosen´t.
What I´m missing, and what from that can be optimized… and what would be a good fallback for lower then 3gs devices (SelfIllum is a must)
Thanks alot.
Shader "MyShader/SelfIllum Reflective"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_IllumColor ("Illum Color", Color) = (1,1,1,1)
_Illum ("Illumin (A)", 2D) = "white" {}
_Reflect ("Reflection", 2D) = "black" { TexGen SphereMap }
}
SubShader
{
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
float4 _Color;
float4 _IllumColor;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 tex = tex2D(_MainTex, IN.uv_MainTex);
half4 c = tex * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb * (tex2D(_Illum, IN.uv_Illum).a * _IllumColor);
o.Alpha = c.a;
}
ENDCG
Pass
{
Name "BASE"
Material{
Diffuse [_Color]
}
Lighting On
Fog { Mode Off }
SetTexture [_MainTex] {
combine texture * previous
}
}
// Use this pass, if you want to fetch alpha from main texture instead
Pass
{
Name "REFLECT"
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord", texcoord0 // main uses 1st uv
}
SetTexture [_MainTex] {
combine texture
}
SetTexture [_Reflect] {
combine texture, previous
}
}
}
}