Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Unlit/ColorVignette"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- Tags { "RenderType"="Opaque" }
- Cull Front
- ZTest Always
- ZWrite Off
- GrabPass{ "_GrabAss" }
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- // make fog work
- #pragma multi_compile_fog
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float4 uv : TEXCOORD0;
- float4 vertexColor : COLOR;
- };
- struct v2f
- {
- float4 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- float4 screenCoord : TEXCOORD1;
- float4 vertexColor : COLOR;
- };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.screenCoord = ComputeGrabScreenPos(o.vertex);
- o.vertexColor = v.vertexColor;
- o.uv = v.uv;
- return o;
- }
- sampler2D _GrabAss;
- fixed4 frag (v2f i) : SV_Target
- {
- {
- float OuterVig = 1.0; // Position for the Outer vignette
- float InnerVig = 0.05; // Position for the inner Vignette Ring
- float2 uv = i.screenCoord.xy / i.screenCoord.w;
- float4 color = tex2D(_GrabAss, uv);
- float2 center = float2(0.5,.5); // Center of Screen
- float dist = distance(center,uv )*1.414213; // Distance between center and the current Uv. Multiplyed by 1.414213 to fit in the range of 0.0 to 1.0
- float vig = clamp((OuterVig-dist) / (OuterVig-InnerVig),0.0,1.0); // Generate the Vignette with Clamp which go from outer Viggnet ring to inner vignette ring with smooth steps
- color *= vig; // Multiply the Vignette with the texture color
- return color;
- }
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement