Last active
December 7, 2023 09:20
-
-
Save nickludlam/8d3daae3049de91905339f04f4372516 to your computer and use it in GitHub Desktop.
XRay Shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/XRayTransparency" | |
{ | |
Properties | |
{ | |
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0) | |
_RimPower ("Rim Power", Range(0.5,8.0)) = 3.0 | |
} | |
SubShader | |
{ | |
Tags { "Queue"="Transparent" "RenderType"="Transparent" } | |
LOD 200 | |
ZTest Always | |
Blend SrcAlpha OneMinusSrcAlpha | |
CGPROGRAM | |
#pragma surface surf Standard alpha vertex:vert | |
#pragma target 3.0 | |
float4 _RimColor; | |
float _RimPower; | |
struct Input { | |
float2 uv_MainTex; | |
float3 viewDir; | |
float3 worldPos; | |
}; | |
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. | |
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. | |
// #pragma instancing_options assumeuniformscaling | |
UNITY_INSTANCING_BUFFER_START(Props) | |
// put more per-instance properties here | |
UNITY_INSTANCING_BUFFER_END(Props) | |
void vert (inout appdata_full v, out Input o) { | |
UNITY_INITIALIZE_OUTPUT(Input,o); | |
} | |
void surf (Input IN, inout SurfaceOutputStandard o) { | |
float3 dpdx = ddx(IN.worldPos.xyz); | |
float3 dpdy = ddy(IN.worldPos.xyz); | |
//o.Normal = normalize(cross(dpdy, dpdx)); // Simulate flat shading | |
half rim = 0.8 - saturate(dot (normalize(IN.viewDir), o.Normal)); | |
o.Albedo = _RimColor.rgb * rim; | |
o.Emission = _RimColor.rgb * pow (rim, _RimPower); | |
} | |
ENDCG | |
} | |
Fallback "Transparent/VertexLit" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment