Question by
h-galaxy948 · Jul 27, 2018 at 08:33 PM ·
shadertransparentblendingstencilintersection
how to hide intersections between meshes
found this transparent inner glow shader on web:
Shader "Cell/MainTransparentFresnel" {
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.5,8.0)) = 3.0
}
SubShader {
Tags { "Queue" = "Transparent" }
Blend one one
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;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * pow (rim, _RimPower);
}
ENDCG
}
Fallback "Diffuse"
this is the result when i blend two meshes from this shader:result1
i tried stencil buffer to hide intersections:
stencil {
ref 2
comp notequal
pass replace
}
and this is the result:result2
my wish is to hide both intersections
something like this
Comment