Ambient Fog Light leaves Zone Brushes (root object, same pose) and Sector Tint.mat moves from PowerBrush to Brushes/Ambient Brush: brightness falls as exp(-x^2 ln(1/_EdgeBrightness)), x in units of Zone.PopulatedRadius. ZoneRenderer.FitAmbientLight, called by LoadZone, is the one writer of the quad's size and _Reach (the radius where it is 1e-5 of the centre). AmbientEdgeVerify renders the real scene object through that call. Builds in Unity 6000.3.24f1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
1.5 KiB
Text
61 lines
1.5 KiB
Text
Shader "Brushes/Ambient Brush" {
|
|
Properties {
|
|
_Color ("Color", Color) = (1,1,1,1)
|
|
_Depth ("Depth", Float) = 0.5
|
|
// The brightness at the populated edge relative to the centre: the shape of the fall, never an extent.
|
|
_EdgeBrightness ("Edge Brightness", Range(0.0001, 0.9999)) = .12
|
|
// The quad's radius in units of the populated radius. Written by ZoneRenderer.FitAmbientLight, never authored.
|
|
_Reach ("Reach", Float) = 1
|
|
}
|
|
|
|
// A gaussian: log-brightness is quadratic in distance from the centre, so the fall is smooth everywhere and
|
|
// never reaches an edge or a cliff. x is the distance in units of the zone's populated radius.
|
|
Category {
|
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
|
Blend One One
|
|
ColorMask RGB
|
|
Cull Off Lighting Off ZWrite Off
|
|
|
|
SubShader {
|
|
Pass {
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 2.0
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
float4 _Color;
|
|
float _Depth;
|
|
float _EdgeBrightness;
|
|
float _Reach;
|
|
|
|
struct appdata_t {
|
|
float4 vertex : POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
struct v2f {
|
|
float4 vertex : SV_POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
};
|
|
|
|
v2f vert (appdata_t v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.texcoord = v.texcoord;
|
|
return o;
|
|
}
|
|
|
|
float4 frag (v2f i) : SV_Target
|
|
{
|
|
float x = length(i.texcoord - float2(.5, .5)) * 2 * _Reach;
|
|
return _Depth * _Color * exp(-x * x * log(1 / _EdgeBrightness));
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|
|
}
|