- Home /
Transparent Fresnel Shader Sometimes Obscuring Objects
I'm working to make a transparent shader with a glowing rim around the outside. The goal is to be able to see everything behind my transparent object. As can be seen in my attachments, objects behind my capsule are sometimes obscured in odd ways.
I started with the rim lighting shader from here: http://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html
Here's where I'm at now:
Shader "Custom/TransparentFresnel"
{
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" }
Cull Back
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"
}
I've tried fiddling with different culling, using Blend SrcAlpha OneMinusSrcAlpha, using ZTest with just about every setting but none of that has worked so far. I'm no expert at shaders, but I've read through most of Unity's documentation and used Strumpy Shader Editor a lot so I'm familiar with the language and concepts. Any pointers would be greatly appreciated.
I tried using this shader but there's no glow. Are you achieving that through some fullscreen effect? @cjacobwade
Answer by tanoshimi · Jul 02, 2014 at 05:44 AM
Assuming you want objects further away to be drawn behind objects in the foreground, try adding:
ZWrite Off
This improves my situation a bit, thanks! Now I'm having a problem where the object is obscured by the floor plane.
Your answer
Follow this Question
Related Questions
Transparency and blending issues with custom-made shader 1 Answer
Change blend mode from outside shader? 3 Answers
Silhouette overlay shader 0 Answers
GameObject not receiving shadows 0 Answers
Transparent shader for Android 1 Answer