Created
January 8, 2019 13:39
-
-
Save kronnect/d1aee5baa317dbe4d3fc6ff60810e6d8 to your computer and use it in GitHub Desktop.
Weird Glitch
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 "Hidden/Custom/Grayscale" | |
{ | |
HLSLINCLUDE | |
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl" | |
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex); | |
float _Blend; | |
struct VaryingsExtra | |
{ | |
float4 vertex : SV_POSITION; | |
float2 texcoord : TEXCOORD0; | |
float2 texcoordStereo : TEXCOORD1; | |
float2 texcoordStereo2 : TEXCOORD2; | |
}; | |
VaryingsExtra Vert(AttributesDefault v) | |
{ | |
VaryingsExtra o; | |
o.vertex = float4(v.vertex.xy, 0.0, 1.0); | |
o.texcoord = TransformTriangleVertexToUV(v.vertex.xy); | |
#if UNITY_UV_STARTS_AT_TOP | |
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0); | |
#endif | |
o.texcoordStereo = TransformStereoScreenSpaceTex(o.texcoord, 1.0); | |
o.texcoordStereo2 = o.texcoordStereo; | |
return o; | |
} | |
float4 Frag(VaryingsExtra i) : SV_Target | |
{ | |
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo2); | |
float luminance = dot(color.rgb, float3(0.2126729, 0.7151522, 0.0721750)); | |
color.rgb = lerp(color.rgb, luminance.xxx, _Blend.xxx); | |
return color; | |
} | |
ENDHLSL | |
SubShader | |
{ | |
Cull Off ZWrite Off ZTest Always | |
Pass | |
{ | |
HLSLPROGRAM | |
#pragma vertex Vert | |
#pragma fragment Frag | |
ENDHLSL | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment