- Home /
Problem with overlapping objects, same shader
I'm having troubles with getting this object shader to work. I want the closer larger objects to cover the underlying ones.
As it might be possible to see, the large sphere is the closest to my camera, and the smaller spheres are much farther away. But the smaller ones are still being shown through the larger sphere. They are all using the same shader.
Here is the shader I'm trying to use:
Shader "Custom/RimFresnel"
{
Properties {
_InnerColor ("Inner Color", Color) = (1.0, 1.0, 1.0, 1.0)
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
_RimPower ("Rim Power", Range(0.1,8.0)) = 3.0
//_AlphaLimit ("Alpha Cutoff", Range (0.0, 1.0)) = 1.0
}
SubShader {
Tags {
//"Queue" = "Transparent" "IgnoreProjector" = "True"
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Lighting Off
Cull Back
//Blend SrcAlpha OneMinusSrcAlpha
//Blend OneMinusDstColor One
Blend One One
//Blend One DstColor
ZWrite Off
Stencil {
Ref 2
Comp NotEqual
Pass Replace
}
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float3 viewDir;
};
float4 _InnerColor;
float4 _RimColor;
float _RimPower;
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = _InnerColor.rgb;
//o.Alpha = 1.0;
o.Alpha = _InnerColor.a;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * pow (rim, _RimPower);
}
ENDCG
}
//Fallback "Diffuse"
Fallback "Transparent/VertexLit"
}
Thank you!
screenshot-25.png
(61.4 kB)
Comment
Your answer

Follow this Question
Related Questions
Revealing invisible objects with a projector 0 Answers
Can't select shader help! 1 Answer
Rune glow effect on stones? 1 Answer
Blender object with volume shader to unity (.fbx) 0 Answers
draw mesh on top 2 Answers