So I found that by putting a reverse gradient map into the xray shader it can produce a pseudo-glow effect
The only problem is, if you notice around the rim, there is a very thin 1 pixel outline of the sphere. This 1 pixel outline kinda jumps and pops around the sphere depending on the angle you look at it. It seems like at the .0001 facing ratio, some quirk in the calculation happens and it makes it fully red at the very very edge.
I don’t know how to get rid of this. Does anyone know how to correct this?
Here is the code
Shader "XRay" {
Properties {
_Color ("Tint (RGB)", Color) = (1,1,1,1)
_RampTex ("Facing Ratio Ramp (RGB)", 2D) = "white" {}
}
SubShader {
ZWrite Off
Cull Back
Blend One One
Pass {
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
struct appdata {
float4 vertex;
float3 normal;
float4 texcoord;
};
struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
float fog : FOGC;
float4 uv : TEXCOORD0;
};
v2f vert (appdata v) {
v2f o;
o.pos = mul( glstate.matrix.mvp, v.vertex );
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
o.uv = float4( dot(viewDir,v.normal), 0.5, 0.0, 1.0 );
return o;
}
ENDCG
SetTexture [_RampTex] {constantColor[_Color] combine texture * constant}
}
}
Fallback Off
}