Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Unlit/SCPE_TransparentWithFog"
- {
- SubShader
- {
- Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" }
- Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
- Cull Back
- Zwrite Off
- Pass
- {
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- //Uncomment to disable features that definitely aren't used for a performance gain
- //#define DISABLE_FOG_GRADIENT
- //#define DISABLE_FOG_SKYBOXCOLOR
- //#define DISABLE_FOG_HEIGHTNOISE
- //#define DISABLE_FOG_DIRECTIONAL_COLOR
- //Source for the "ComputeFog" function and all its dependencies
- #include "Assets/SC Post Effects/Runtime/Fog/Fog.hlsl"
- struct appdata
- {
- float4 vertex : POSITION;
- };
- struct v2f
- {
- float4 vertex : SV_POSITION;
- float3 positionWS: TEXCOORD1;
- float4 screenPos : TEXCOORD2;
- };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.positionWS = mul(unity_ObjectToWorld, v.vertex).xyz;
- o.screenPos = ComputeScreenPos(v.vertex);
- return o;
- }
- float4 frag (v2f i) : SV_Target
- {
- float4 col = float4(0,0,0,1);
- //The screen position input is used when the fog color source is set to "Skybox". If never in use, you can set it to 0
- float4 fogColor = ComputeTransparentFog(i.positionWS, i.screenPos);
- //The alpha channel will hold the density of the fog, use it as a lerp factor
- col.rgb = lerp(fogColor.rgb, col.rgb, fogColor.a);
- //Alternatively, apply this function also does the lerp operation
- //ApplyTransparencyFog(i.positionWS, i.screenPos, col.rgb);
- return col;
- }
- ENDHLSL
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement