hologram shader, Pass, colormask, transparent
This shader creates a fresnel style inner rim glow on an object. It uses the dot product between the surface normal and the view direction vector. To give it a transparent/ghostly feel we set the alpha to the rim-glow effect.
In order to actually get it transparent, we add "alpha:fade" to our #pragma and also assign the Transparent Queue tag.
A "problem" that arises is that we can see the internal faces of an object when it has a complex shape -eg the inside of the mouth cavity. This *might* be desirable in a true x-ray shader?
However, if you wanted to have the outer surface occlude the inner parts, then we must add a Pass.
This will take place before the pass that occurs within the CGPROGRAM. We add a Zwrite On within the pass, which enables writing to the depth buffer and set the ColorMask to 0, so we don't write any colour data - only the Z info.
Shader "Dave/Hologram"{
Properties{
_RimColor("Rim Color", color)=(1,1,1,1)
_RimPower("Rim Power",Range(0.5,8))=3
}
SubShader{
Tags{"Queue"="Transparent"}
Pass {
Zwrite On //enables writing depth
ColorMask 0 //doesn't write color data to the frame buffer
}
CGPROGRAM
#pragma surface surf Lambert alpha:fade
struct Input {
float3 viewDir;
};
float4 _RimColor;
float _RimPower;
void surf(Input IN, inout SurfaceOutput o) {
half rim = 1-saturate(dot(normalize(IN.viewDir), o.Normal));
o.Emission = pow(rim,_RimPower) * _RimColor.rgb*10;
o.Alpha = pow(rim, _RimPower);
}
ENDCG
}
Fallback "Diffuse"
}
Comments
Post a Comment