This question is for curiosity.
I have a simple transparent shader (code below), and I have made a property “_Alpha” for it.
If I set the alpha channel to extremely high values, like e.g -1e+15 or 1e+15, I see visual artifacts like the following:
What causes this? Why does it not just stop at the highest value of white that there is? (if that even makes sense).
I’m interested in what goes on under the hood of the GPU or Unity game engine that causes a large orange outline to appear on the object, when the fragment shader returns -1e+15 for the alpha channel.
The shader:
Shader "Unlit/OverflowShader"
{
Properties
{
_Color ("Color",Color) = (1,1,1,1)
_Alpha("Alpha", Float) = 0
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 100
// Enable blending for transparency
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
float4 _Color;
float _Alpha;
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = _Color;
col.a = _Alpha;
return col;
}
ENDCG
}
}
}