Shader "Glass" { Properties { _MainTex("Base (RGB) Gloss (A)", 2D) = "white" {} _ReflColor("Reflection Color", Color) = (0.26, 0.19, 0.16, 0.0) _RimColor("Rim Color", Color) = (0.26, 0.19, 0.16, 0.0) _RimPower("Rim Strength", Range(0.5, 8.0)) = 3.0 _AlphaMin("Alpha Minimum", Range(0.0, 1.0)) = 0.5 _SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess("Shininess", Range(0.01, 1)) = 0.078125 } SubShader { Tags { "RenderType" = "Transparent" "Queue" = "Overlay" } Pass { Name "FORWARD" Tags { "LightMode" = "ForwardBase" } HLSLPROGRAM #pragma multi_compile_fog #pragma vertex vert #pragma fragment frag #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" // Properties float4 _ReflColor; float4 _RimColor; float _RimPower; float _AlphaMin; float4 _SpecColor; float _Shininess; Texture2D _MainTex; sampler2D _MainTex_sampler; struct Attributes { float4 position : POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0; }; struct Varyings { float4 position : POSITION; float3 worldPos : TEXCOORD0; float3 normal : TEXCOORD1; float2 uv : TEXCOORD2; }; Varyings vert(Attributes v) { Varyings o; o.position = TransformObjectToHClip(v.position); o.worldPos = mul(unity_ObjectToWorld, v.position).xyz; o.normal = mul((float3x3)unity_ObjectToWorld, v.normal); o.uv = v.uv; return o; } float4 frag(Varyings i) : SV_Target { float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - i.worldPos); float3 normal = normalize(i.normal); // Fetch main texture and gloss float4 tex = tex2D(_MainTex_sampler, i.uv); float gloss = tex.a; // Rim lighting calculation half rim = 1.0 - saturate(dot(viewDir, normal)); float4 rimEmission = _RimColor * pow(rim, _RimPower); // Final color (ensure it's float4) float4 finalColor = float4(tex.rgb + _ReflColor.rgb, 1.0); // Default alpha to 1.0 // Calculate the final alpha value float alpha = (pow(rim, _RimPower)*(1 - _AlphaMin)) + _AlphaMin * tex.a; // Specular reflection float3 specular = _SpecColor.rgb * pow(max(0, dot(normal, viewDir)), _Shininess * 128); // Combine all components return float4(finalColor.rgb + rimEmission.rgb + specular, alpha); } ENDHLSL } } Fallback "Universal Forward" }