changes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
fixed4 SampleYCbCr ( half2 Yuv, half2 CbCruv)
|
||||
{
|
||||
#ifdef UNITY_COMPILER_CG
|
||||
fixed4 YCrCb = fixed4(tex2D (_YTex, Yuv).a + 0.001, tex2D (_CrTex, CbCruv).a + 0.001, tex2D (_CbTex, CbCruv).a + 0.001, 1.0);
|
||||
#else
|
||||
fixed4 YCrCb = fixed4(tex2D (_YTex, Yuv).a, tex2D (_CrTex, CbCruv).a, tex2D (_CbTex, CbCruv).a, 1.0);
|
||||
#endif
|
||||
|
||||
return YCrCb;
|
||||
}
|
||||
|
||||
|
||||
half4 YCbCrToRGB( half4 YCbCr )
|
||||
{
|
||||
//Spent ages on these
|
||||
//www.theora.org/doc/Theora.pdf
|
||||
//R = ((Y - (16.0/255.0)) * (255.0/219.0)) + (2*(1 - 0.299)*((Cr - (128.0/255.0)) * (255.0/244.0)))
|
||||
//G = ((Y - (16.0/255.0)) * (255.0/219.0)) - (2 * (((1 - 0.114)*0.114)/(1 - 0.114 - 0.299)) * ((Cb - (128.0/255.0)) * (255.0/244.0))) - (2 * (((1 - 0.299)*0.299)/(1 - 0.114 - 0.299)) * ((Cr - (128.0/255.0)) * (255.0/244.0)))
|
||||
//B = ((Y - (16.0/255.0)) * (255.0/219.0)) + (2*(1 - 0.114)*((Cb - (128.0/255.0)) * (255.0/244.0)))
|
||||
|
||||
//half4 YCbCr2R = half4(1.16438, 1.4652, 0, -0.808535);
|
||||
//half4 YCbCr2G = half4(1.16438, -0.714136, -0.359651, 0.46594);
|
||||
//half4 YCbCr2B = half4(1.16438, 0,1.85189, -1.00263);
|
||||
|
||||
//However the original ones are more accurate with a colour bar test video
|
||||
half4 YCbCr2R = half4(1.1643828125, 1.59602734375, 0, -.87078515625);
|
||||
half4 YCbCr2G = half4(1.1643828125, -.81296875, -.39176171875, .52959375);
|
||||
half4 YCbCr2B = half4(1.1643828125, 0, 2.017234375, -1.081390625);
|
||||
|
||||
half4 rgbVec;
|
||||
|
||||
rgbVec.x = dot(YCbCr2R, YCbCr);
|
||||
rgbVec.y = dot(YCbCr2G, YCbCr);
|
||||
rgbVec.z = dot(YCbCr2B, YCbCr);
|
||||
rgbVec.w = 1.0f;
|
||||
|
||||
return rgbVec;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
Shader "Color Space/YCrCbtoRGB Add" {
|
||||
Properties {
|
||||
_YTex ("Y (RGB)", 2D) = "white" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "white" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "QUEUE"="Overlay" "RenderType"="Opaque" }
|
||||
Pass {
|
||||
Tags { "QUEUE"="Overlay" "RenderType"="Opaque" }
|
||||
Fog {
|
||||
Color (0,0,0,0)
|
||||
}
|
||||
Blend One One
|
||||
ColorMask RGB
|
||||
Program "vp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES
|
||||
|
||||
|
||||
#ifdef VERTEX
|
||||
|
||||
varying highp vec2 xlv_TEXCOORD0;
|
||||
uniform highp vec4 _YTex_ST;
|
||||
uniform highp mat4 glstate_matrix_mvp;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
attribute vec4 _glesVertex;
|
||||
void main ()
|
||||
{
|
||||
gl_Position = (glstate_matrix_mvp * _glesVertex);
|
||||
xlv_TEXCOORD0 = ((_glesMultiTexCoord0.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
|
||||
varying highp vec2 xlv_TEXCOORD0;
|
||||
uniform sampler2D _CrTex;
|
||||
uniform sampler2D _CbTex;
|
||||
uniform sampler2D _YTex;
|
||||
void main ()
|
||||
{
|
||||
mediump vec4 rgbVec_1;
|
||||
mediump vec4 yuvVec_2;
|
||||
lowp vec4 tmpvar_3;
|
||||
tmpvar_3.w = 1.0;
|
||||
tmpvar_3.x = texture2D (_YTex, xlv_TEXCOORD0).x;
|
||||
tmpvar_3.y = texture2D (_CbTex, xlv_TEXCOORD0).y;
|
||||
tmpvar_3.z = texture2D (_CrTex, xlv_TEXCOORD0).z;
|
||||
yuvVec_2 = tmpvar_3;
|
||||
rgbVec_1.x = dot (vec4(1.16438, 0.0, 1.59603, -0.870785), yuvVec_2);
|
||||
rgbVec_1.y = dot (vec4(1.16438, -0.391762, -0.812969, 0.529594), yuvVec_2);
|
||||
rgbVec_1.z = dot (vec4(1.16438, 2.01723, 0.0, -1.08139), yuvVec_2);
|
||||
rgbVec_1.w = 0.3;
|
||||
gl_FragData[0] = rgbVec_1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif"
|
||||
}
|
||||
}
|
||||
Program "fp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fallback "VertexLit"
|
||||
}
|
||||
@@ -1,81 +1,59 @@
|
||||
Shader "Color Space/YCrCbtoRGB" {
|
||||
Properties {
|
||||
_YTex ("Y (RGB)", 2D) = "white" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "white" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "white" {}
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Color Space/YCbCrtoRGB"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_YTex ("Y (RGB)", 2D) = "black" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "gray" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "gray" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
Pass
|
||||
{
|
||||
ColorMask RGB
|
||||
Lighting Off Fog { Color (0,0,0,0) }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _YTex;
|
||||
sampler2D _CbTex;
|
||||
sampler2D _CrTex;
|
||||
|
||||
#include "YCbCrtoRGB.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uvY : TEXCOORD0;
|
||||
half2 uvCbCr : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 _YTex_ST;
|
||||
float4 _CbTex_ST;
|
||||
|
||||
v2f vert (appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos (v.vertex);
|
||||
o.uvY = TRANSFORM_TEX (v.texcoord, _YTex);
|
||||
o.uvCbCr = TRANSFORM_TEX (v.texcoord, _CbTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
return YCbCrToRGB(SampleYCbCr( i.uvY, i.uvCbCr));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
Pass {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
Fog {
|
||||
Color (0,0,0,0)
|
||||
}
|
||||
ColorMask RGB
|
||||
Program "vp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES
|
||||
#define SHADER_API_GLES 1
|
||||
#define tex2D texture2D
|
||||
|
||||
|
||||
#ifdef VERTEX
|
||||
#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
|
||||
uniform mat4 glstate_matrix_mvp;
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
|
||||
uniform highp vec4 _YTex_ST;
|
||||
uniform highp vec4 _CbTex_ST;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
attribute vec4 _glesVertex;
|
||||
void main ()
|
||||
{
|
||||
mediump vec2 tmpvar_1;
|
||||
mediump vec2 tmpvar_2;
|
||||
highp vec2 tmpvar_3;
|
||||
tmpvar_3 = ((_glesMultiTexCoord0.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
tmpvar_1 = tmpvar_3;
|
||||
highp vec2 tmpvar_4;
|
||||
tmpvar_4 = ((_glesMultiTexCoord0.xy * _CbTex_ST.xy) + _CbTex_ST.zw);
|
||||
tmpvar_2 = tmpvar_4;
|
||||
gl_Position = (gl_ModelViewProjectionMatrix * _glesVertex);
|
||||
xlv_TEXCOORD0 = tmpvar_1;
|
||||
xlv_TEXCOORD1 = tmpvar_2;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
uniform sampler2D _YTex;
|
||||
uniform sampler2D _CrTex;
|
||||
uniform sampler2D _CbTex;
|
||||
void main ()
|
||||
{
|
||||
lowp vec4 rgbVec;
|
||||
lowp vec4 tmpvar_1;
|
||||
tmpvar_1.w = 1.0;
|
||||
tmpvar_1.x = texture2D (_YTex, xlv_TEXCOORD0).x;
|
||||
tmpvar_1.y = texture2D (_CrTex, xlv_TEXCOORD1).y;
|
||||
tmpvar_1.z = texture2D (_CbTex, xlv_TEXCOORD1).z;
|
||||
rgbVec.x = dot (vec4(1.16438, 0.0, 1.59603, -0.870785), tmpvar_1);
|
||||
rgbVec.y = dot (vec4(1.16438, -0.391762, -0.812969, 0.529594), tmpvar_1);
|
||||
rgbVec.z = dot (vec4(1.16438, 2.01723, 0.0, -1.08139), tmpvar_1);
|
||||
rgbVec.w = 1.0;
|
||||
gl_FragData[0] = rgbVec;
|
||||
}
|
||||
|
||||
#endif"
|
||||
}
|
||||
}
|
||||
Program "fp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,92 @@
|
||||
Shader "Color Space/YCrCbtoRGB Chroma Key" {
|
||||
Properties {
|
||||
_YTex ("Y (RGB)", 2D) = "white" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "white" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "white" {}
|
||||
_KeyYCrCb ("Key Color YCrCb", Vector) = (0,0,0,-0.6)
|
||||
_KeyScale ("Comparison Scale", Vector) = (0.2,1,1,4.5)
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Color Space/YCbCrtoRGB Chroma Key"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_YTex ("Y (RGB)", 2D) = "black" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "gray" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "gray" {}
|
||||
|
||||
[YCbCr] _KeyYCbCr ("Chroma Key Color", Vector) = (0,0,0,-0.6)
|
||||
[YCbCrPriority] _YCbCRDeltaScale ("YCbCr priority", Vector) = (0.1,1,1) //Different CbCr means a more different color than a different Y
|
||||
_LowThreshold ("Low threashold", Range(0.0, 1.0)) = 0.2
|
||||
_HighThreshold ("High threashold", Range(0.0, 1.0)) = 0.25
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
Pass
|
||||
{
|
||||
Lighting Off Fog { Color (0,0,0,0) }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _YTex;
|
||||
sampler2D _CbTex;
|
||||
sampler2D _CrTex;
|
||||
|
||||
#include "YCbCrtoRGB.cginc"
|
||||
|
||||
half3 _KeyYCbCr;
|
||||
half4 _YCbCRDeltaScale;
|
||||
half _LowThreshold;
|
||||
half _HighThreshold;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uvY : TEXCOORD0;
|
||||
half4 uvCbCr : TEXCOORD1; // u,v,offset,normalise
|
||||
};
|
||||
|
||||
float4 _YTex_ST;
|
||||
float4 _CbTex_ST;
|
||||
|
||||
v2f vert (appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos (v.vertex);
|
||||
o.uvY = TRANSFORM_TEX (v.texcoord, _YTex);
|
||||
o.uvCbCr.xy = TRANSFORM_TEX (v.texcoord, _CbTex);
|
||||
|
||||
//Work out the threasholds in the vertex shader
|
||||
//float scaleLength = length(_YCbCRDeltaScale);
|
||||
float scaleLength = _YCbCRDeltaScale.w;
|
||||
|
||||
float bottom = _LowThreshold * scaleLength;
|
||||
float top = _HighThreshold * scaleLength;
|
||||
|
||||
float range = top - bottom;
|
||||
float offset = -bottom;
|
||||
|
||||
float normalise = 1.0/range;
|
||||
|
||||
o.uvCbCr.z = offset;
|
||||
o.uvCbCr.w = normalise;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
fixed4 YCbCr = SampleYCbCr( i.uvY, i.uvCbCr);
|
||||
fixed4 rgbVec = YCbCrToRGB(YCbCr);
|
||||
|
||||
half3 deltaVec = (YCbCr.xyz - _KeyYCbCr.xyz) * _YCbCRDeltaScale.xyz;
|
||||
|
||||
rgbVec.w = (length(deltaVec) + i.uvCbCr.z)* i.uvCbCr.w;
|
||||
|
||||
return rgbVec;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
Pass {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
ZWrite Off
|
||||
Fog {
|
||||
Color (0,0,0,0)
|
||||
}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Program "vp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES
|
||||
#define SHADER_API_GLES 1
|
||||
#define tex2D texture2D
|
||||
|
||||
|
||||
#ifdef VERTEX
|
||||
#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
|
||||
uniform mat4 glstate_matrix_mvp;
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
|
||||
uniform highp vec4 _YTex_ST;
|
||||
uniform highp vec4 _CbTex_ST;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
attribute vec4 _glesVertex;
|
||||
void main ()
|
||||
{
|
||||
mediump vec2 tmpvar_1;
|
||||
mediump vec2 tmpvar_2;
|
||||
highp vec2 tmpvar_3;
|
||||
tmpvar_3 = ((_glesMultiTexCoord0.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
tmpvar_1 = tmpvar_3;
|
||||
highp vec2 tmpvar_4;
|
||||
tmpvar_4 = ((_glesMultiTexCoord0.xy * _CbTex_ST.xy) + _CbTex_ST.zw);
|
||||
tmpvar_2 = tmpvar_4;
|
||||
gl_Position = (gl_ModelViewProjectionMatrix * _glesVertex);
|
||||
xlv_TEXCOORD0 = tmpvar_1;
|
||||
xlv_TEXCOORD1 = tmpvar_2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
uniform sampler2D _YTex;
|
||||
uniform mediump vec4 _KeyYCrCb;
|
||||
uniform mediump vec4 _KeyScale;
|
||||
uniform sampler2D _CrTex;
|
||||
uniform sampler2D _CbTex;
|
||||
void main ()
|
||||
{
|
||||
lowp vec4 rgbVec;
|
||||
lowp vec4 tmpvar_1;
|
||||
tmpvar_1.w = 1.0;
|
||||
tmpvar_1.x = texture2D (_YTex, xlv_TEXCOORD0).x;
|
||||
tmpvar_1.y = texture2D (_CrTex, xlv_TEXCOORD1).y;
|
||||
tmpvar_1.z = texture2D (_CbTex, xlv_TEXCOORD1).z;
|
||||
rgbVec.x = dot (vec4(1.16438, 0.0, 1.59603, -0.870785), tmpvar_1);
|
||||
rgbVec.y = dot (vec4(1.16438, -0.391762, -0.812969, 0.529594), tmpvar_1);
|
||||
rgbVec.z = dot (vec4(1.16438, 2.01723, 0.0, -1.08139), tmpvar_1);
|
||||
mediump float tmpvar_2;
|
||||
tmpvar_2 = ((length (((tmpvar_1.xyz - _KeyYCrCb.xyz) * _KeyScale.xyz)) + _KeyYCrCb.w) * _KeyScale.w);
|
||||
rgbVec.w = tmpvar_2;
|
||||
gl_FragData[0] = rgbVec;
|
||||
}
|
||||
|
||||
#endif"
|
||||
}
|
||||
}
|
||||
Program "fp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +1,79 @@
|
||||
Shader "Color Space/YCrCbtoRGB Split Alpha" {
|
||||
Properties {
|
||||
_YTex ("Y (RGB)", 2D) = "white" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "white" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "white" {}
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Color Space/YCrCbtoRGB Split Alpha"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_YTex ("Y (RGB)", 2D) = "black" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "gray" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "gray" {}
|
||||
|
||||
[KeywordEnum(Vertical, Horizontal)] Mode ("Alpha Mode", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Lighting Off Fog { Color (0,0,0,0) }
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile MODE_VERTICAL MODE_HORIZONTAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _YTex;
|
||||
sampler2D _CbTex;
|
||||
sampler2D _CrTex;
|
||||
|
||||
#include "YCbCrtoRGB.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uvY : TEXCOORD0;
|
||||
half2 uvAlpha : TEXCOORD1;
|
||||
half2 uvCbCr : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 _YTex_ST;
|
||||
float4 _CbTex_ST;
|
||||
|
||||
v2f vert (appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos (v.vertex);
|
||||
|
||||
float4 texcoordBottom = v.texcoord;
|
||||
float4 texcoordTop = v.texcoord;
|
||||
#if MODE_VERTICAL
|
||||
texcoordBottom.y = ( v.texcoord.y / 2.0f );
|
||||
texcoordTop.y = texcoordBottom.y + 0.5f;
|
||||
#else
|
||||
texcoordBottom.x = ( v.texcoord.x / 2.0f );
|
||||
texcoordTop.x = texcoordBottom.x + 0.5f;
|
||||
#endif
|
||||
|
||||
o.uvY = TRANSFORM_TEX (texcoordTop, _YTex);
|
||||
o.uvAlpha = TRANSFORM_TEX (texcoordBottom, _YTex);
|
||||
o.uvCbCr = TRANSFORM_TEX (texcoordTop, _CbTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
fixed4 rgbVec = YCbCrToRGB(SampleYCbCr( i.uvY, i.uvCbCr));
|
||||
|
||||
rgbVec.w = ((tex2D(_YTex, i.uvAlpha).a - (16.0/255.0)) * (255.0/219.0));
|
||||
|
||||
return rgbVec;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
Pass {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
ZWrite Off
|
||||
Fog {
|
||||
Color (0,0,0,0)
|
||||
}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Program "vp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES
|
||||
#define SHADER_API_GLES 1
|
||||
#define tex2D texture2D
|
||||
|
||||
|
||||
#ifdef VERTEX
|
||||
#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
|
||||
uniform mat4 glstate_matrix_mvp;
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD2;
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
|
||||
uniform highp vec4 _YTex_ST;
|
||||
uniform highp vec4 _CbTex_ST;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
attribute vec4 _glesVertex;
|
||||
void main ()
|
||||
{
|
||||
highp vec4 texcoordTop;
|
||||
highp vec4 texcoordBottom;
|
||||
mediump vec2 tmpvar_1;
|
||||
mediump vec2 tmpvar_2;
|
||||
mediump vec2 tmpvar_3;
|
||||
texcoordBottom = _glesMultiTexCoord0;
|
||||
texcoordBottom.y = (_glesMultiTexCoord0.y / 2.0);
|
||||
texcoordTop = _glesMultiTexCoord0;
|
||||
texcoordTop.y = (texcoordBottom.y + 0.5);
|
||||
highp vec2 tmpvar_4;
|
||||
tmpvar_4 = ((texcoordTop.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
tmpvar_1 = tmpvar_4;
|
||||
highp vec2 tmpvar_5;
|
||||
tmpvar_5 = ((texcoordBottom.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
tmpvar_2 = tmpvar_5;
|
||||
highp vec2 tmpvar_6;
|
||||
tmpvar_6 = ((texcoordTop.xy * _CbTex_ST.xy) + _CbTex_ST.zw);
|
||||
tmpvar_3 = tmpvar_6;
|
||||
gl_Position = (gl_ModelViewProjectionMatrix * _glesVertex);
|
||||
xlv_TEXCOORD0 = tmpvar_1;
|
||||
xlv_TEXCOORD1 = tmpvar_2;
|
||||
xlv_TEXCOORD2 = tmpvar_3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD2;
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
uniform sampler2D _YTex;
|
||||
uniform sampler2D _CrTex;
|
||||
uniform sampler2D _CbTex;
|
||||
void main ()
|
||||
{
|
||||
lowp vec4 rgbVec;
|
||||
lowp vec4 tmpvar_1;
|
||||
tmpvar_1.w = 1.0;
|
||||
tmpvar_1.x = texture2D (_YTex, xlv_TEXCOORD0).x;
|
||||
tmpvar_1.y = texture2D (_CrTex, xlv_TEXCOORD2).y;
|
||||
tmpvar_1.z = texture2D (_CbTex, xlv_TEXCOORD2).z;
|
||||
rgbVec.x = dot (vec4(1.16438, 0.0, 1.59603, -0.870785), tmpvar_1);
|
||||
rgbVec.y = dot (vec4(1.16438, -0.391762, -0.812969, 0.529594), tmpvar_1);
|
||||
rgbVec.z = dot (vec4(1.16438, 2.01723, 0.0, -1.08139), tmpvar_1);
|
||||
rgbVec.w = ((texture2D (_YTex, xlv_TEXCOORD1).y - 0.0627451) * 1.16438);
|
||||
gl_FragData[0] = rgbVec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif"
|
||||
}
|
||||
}
|
||||
Program "fp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,63 @@
|
||||
Shader "Color Space/YCrCbtoRGB Trans" {
|
||||
Properties {
|
||||
_YTex ("Y (RGB)", 2D) = "white" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "white" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "white" {}
|
||||
_TintColor ("Color", Color) = (1,1,1,1)
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "Color Space/YCbCrtoRGB Trans"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_YTex ("Y (RGB)", 2D) = "black" {}
|
||||
_CrTex ("Cr (RGB)", 2D) = "gray" {}
|
||||
_CbTex ("Cb (RGB)", 2D) = "gray" {}
|
||||
_TintColor ("Color", COLOR) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Lighting Off Fog { Color (0,0,0,0) }
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _YTex;
|
||||
sampler2D _CbTex;
|
||||
sampler2D _CrTex;
|
||||
|
||||
#include "YCbCrtoRGB.cginc"
|
||||
|
||||
fixed4 _TintColor;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
half2 uvY : TEXCOORD0;
|
||||
half2 uvCbCr : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 _YTex_ST;
|
||||
float4 _CbTex_ST;
|
||||
|
||||
v2f vert (appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos (v.vertex);
|
||||
o.uvY = TRANSFORM_TEX (v.texcoord, _YTex);
|
||||
o.uvCbCr = TRANSFORM_TEX (v.texcoord, _CbTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
return YCbCrToRGB(SampleYCbCr( i.uvY, i.uvCbCr))*_TintColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
Pass {
|
||||
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="True" "RenderType"="Transparent" }
|
||||
ZWrite Off
|
||||
Fog {
|
||||
Color (0,0,0,0)
|
||||
}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB
|
||||
Program "vp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES
|
||||
#define SHADER_API_GLES 1
|
||||
#define tex2D texture2D
|
||||
|
||||
|
||||
#ifdef VERTEX
|
||||
#define gl_ModelViewProjectionMatrix glstate_matrix_mvp
|
||||
uniform mat4 glstate_matrix_mvp;
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
|
||||
uniform highp vec4 _YTex_ST;
|
||||
uniform highp vec4 _CbTex_ST;
|
||||
attribute vec4 _glesMultiTexCoord0;
|
||||
attribute vec4 _glesVertex;
|
||||
void main ()
|
||||
{
|
||||
mediump vec2 tmpvar_1;
|
||||
mediump vec2 tmpvar_2;
|
||||
highp vec2 tmpvar_3;
|
||||
tmpvar_3 = ((_glesMultiTexCoord0.xy * _YTex_ST.xy) + _YTex_ST.zw);
|
||||
tmpvar_1 = tmpvar_3;
|
||||
highp vec2 tmpvar_4;
|
||||
tmpvar_4 = ((_glesMultiTexCoord0.xy * _CbTex_ST.xy) + _CbTex_ST.zw);
|
||||
tmpvar_2 = tmpvar_4;
|
||||
gl_Position = (gl_ModelViewProjectionMatrix * _glesVertex);
|
||||
xlv_TEXCOORD0 = tmpvar_1;
|
||||
xlv_TEXCOORD1 = tmpvar_2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef FRAGMENT
|
||||
|
||||
varying mediump vec2 xlv_TEXCOORD1;
|
||||
varying mediump vec2 xlv_TEXCOORD0;
|
||||
uniform sampler2D _YTex;
|
||||
uniform lowp vec4 _TintColor;
|
||||
uniform sampler2D _CrTex;
|
||||
uniform sampler2D _CbTex;
|
||||
void main ()
|
||||
{
|
||||
lowp vec4 rgbVec;
|
||||
lowp vec4 tmpvar_1;
|
||||
tmpvar_1.w = 1.0;
|
||||
tmpvar_1.x = texture2D (_YTex, xlv_TEXCOORD0).x;
|
||||
tmpvar_1.y = texture2D (_CrTex, xlv_TEXCOORD1).y;
|
||||
tmpvar_1.z = texture2D (_CbTex, xlv_TEXCOORD1).z;
|
||||
rgbVec.x = dot (vec4(1.16438, 0.0, 1.59603, -0.870785), tmpvar_1);
|
||||
rgbVec.y = dot (vec4(1.16438, -0.391762, -0.812969, 0.529594), tmpvar_1);
|
||||
rgbVec.z = dot (vec4(1.16438, 2.01723, 0.0, -1.08139), tmpvar_1);
|
||||
rgbVec.w = 1.0;
|
||||
lowp vec4 tmpvar_2;
|
||||
tmpvar_2 = (rgbVec * _TintColor);
|
||||
rgbVec = tmpvar_2;
|
||||
gl_FragData[0] = tmpvar_2;
|
||||
}
|
||||
|
||||
#endif"
|
||||
}
|
||||
}
|
||||
Program "fp" {
|
||||
SubProgram "gles " {
|
||||
"!!GLES"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user