Shader "Mimimi/Unlit/YUV to RGB GAMMA" { Properties { _MainTex ("Texture", 2D) = "grey" {} } SubShader { Tags { "RenderType"="Opaque" } Lighting Off ZWrite On Fog { Mode Off } Pass { Name "BASE" CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; sampler2D _MainTex; uniform float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); return o; } float4 frag (v2f i) : COLOR { float4 yuv = tex2D(_MainTex, i.texcoord); float y = yuv.b *255; float u = yuv.g *255; float v = yuv.r *255; float r = clamp((1904000*y + 2609823*v - 363703744) / 1635200.0, 0, 255); float g = clamp((3827562*y - 1287801*u - 2672387*v+447306710) / 3287200.0, 0, 255); float b = clamp(( 952000.0*y + 1649289.0*u - 225932192.0) / 817600.0, 0, 255); r = clamp( r/255.0, 0.0, 1.0); g = clamp( g/255.0, 0.0, 1.0); b = clamp( b/255.0, 0.0, 1.0); return float4(r, g, b, 1); } ENDCG } } }