Files
bioDome/Assets/DomeShift/Resources/DomeGlass.shader
2026-12-04 18:19:26 -05:00

62 lines
1.9 KiB
Plaintext

Shader "DomeShift/Glass"
{
Properties
{
_Color ("Glazing tint and opacity", Color) = (0.59, 0.78, 0.75, 0.16)
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True" }
Pass
{
Cull Back
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "UnityCG.cginc"
fixed4 _Color;
struct SurfaceVertex
{
float4 position : POSITION;
float3 normal : NORMAL;
};
struct GlassVertex
{
float4 position : SV_POSITION;
float3 worldPosition : TEXCOORD0;
half3 worldNormal : TEXCOORD1;
};
GlassVertex Vert(SurfaceVertex vertex)
{
GlassVertex result;
result.position = UnityObjectToClipPos(vertex.position);
result.worldPosition = mul(unity_ObjectToWorld, vertex.position).xyz;
result.worldNormal = UnityObjectToWorldNormal(vertex.normal);
return result;
}
fixed4 Frag(GlassVertex vertex) : SV_Target
{
half3 perspective = normalize(_WorldSpaceCameraPos.xyz - vertex.worldPosition);
half3 sightline = lerp(perspective, UNITY_MATRIX_V[2].xyz, unity_OrthoParams.w);
half grazing = 1.0h - saturate(abs(dot(normalize(vertex.worldNormal), sightline)));
half sheen = grazing * grazing;
fixed3 tint = lerp(_Color.rgb, fixed3(0.9, 0.96, 0.93), sheen * 0.4h);
fixed opacity = saturate(_Color.a * (0.82h + sheen * 0.7h));
return fixed4(tint, opacity);
}
ENDCG
}
}
Fallback Off
}