OK, first off: I am a complete shader noob. I am not looking to learn shading, but was trying to hack some stuff editing shaders I found in the forum and wikis. My goal was to get two shaders with a rim highlight, one of them with no transparency. I sort of got what I want, but they dont seem to play well together.
Here is an example of what I expected (imagine the rocky features and eyes to have a white rim)
As you can see, part of the rock and eyes are inside the green ooze, and part is outside.
Now, this is what I’m actually getting:
Here everything seems to show as if it was either inside or behind the ooze.
Here is the code for the transparent shader:
Shader "Rim/Light Specular With Alpha" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Cube ("Cubemap", CUBE) = "" {}
_ReflColor ("Relection Color", Color) = (0.26,0.19,0.16,0.0)
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
_RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
_AlphPower ("Alpha Rim Power", Range(0.0,8.0)) = 3.0
_AlphaMin ("Alpha Minimum", Range(0.0,1.0)) = 0.5
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite On
Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
Fog{}
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float2 uv_MainTex;
float3 worldRefl;
float3 viewDir;
INTERNAL_DATA
};
sampler2D _MainTex;
samplerCUBE _Cube;
float4 _RimColor;
float4 _ReflColor;
float _RimPower;
float _AlphPower;
float _AlphaMin;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * pow (rim, _RimPower) + texCUBE(_Cube, WorldReflectionVector (IN, o.Normal)).rgb*_ReflColor*2 ;
o.Alpha = (pow (rim, _AlphPower)*(1-_AlphaMin))+_AlphaMin ;
}
ENDCG
}
Fallback "VertexLit"
}
And here is the code for the opaque shader:
Shader "Rim/Light Specular" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Cube ("Cubemap", CUBE) = "" {}
_ReflColor ("Relection Color", Color) = (0.26,0.19,0.16,0.0)
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
_RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
}
SubShader {
Tags {"Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque"}
ZWrite On
Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
Fog{}
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float2 uv_MainTex;
float3 worldRefl;
float3 viewDir;
INTERNAL_DATA
};
sampler2D _MainTex;
samplerCUBE _Cube;
float4 _RimColor;
float4 _ReflColor;
float _RimPower;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * pow (rim, _RimPower) + texCUBE(_Cube, WorldReflectionVector (IN, o.Normal)).rgb*_ReflColor*2 ;
o.Alpha = 1.0;
}
ENDCG
}
Fallback "VertexLit"
}
I have no clue if this is an easy fix or something that would involve lots of code, as I said: I am an entire noob as far as shaders go and was hoping I was able to just hack some stuff together (or at least find a direction to where I can find something like what I want.)
Thanks in advance!