first commit

This commit is contained in:
2026-02-09 20:10:14 +08:00
commit 47a5cff08b
2638 changed files with 322636 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
Shader "AVProVideo/Lit/Diffuse (texture+color+fog+stereo support)"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB)", 2D) = "white" {}
_ChromaTex("Chroma", 2D) = "white" {}
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Geometry" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:VertexFunction
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ USE_YPCBCR
#include "AVProVideo.cginc"
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform fixed4 _Color;
struct Input
{
float2 uv_MainTex;
float4 color;
};
void VertexFunction(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), true);
o.uv_MainTex = v.texcoord.xy *= scaleOffset.xy;
o.uv_MainTex = v.texcoord.xy += scaleOffset.zw;
#elif STEREO_CUSTOM_UV
o.uv_MainTex = v.texcoord.xy;
if (!IsStereoEyeLeft())
{
o.uv_MainTex = v.texcoord1.xy;
}
#endif
o.color = _Color;
#if STEREO_DEBUG
o.color *= GetStereoDebugTint(IsStereoEyeLeft());
#endif
}
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c;
#if USE_YPCBCR
c = SampleYpCbCr(_MainTex, _ChromaTex, IN.uv_MainTex, _YpCbCrTransform);
#else
c = SampleRGBA(_MainTex, IN.uv_MainTex);
#endif
c *= IN.color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Legacy Shaders/Transparent/VertexLit"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 06b0cff0150d7eb41b3d269f7e11daa3
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,72 @@
Shader "AVProVideo/Lit/Transparent Diffuse (texture+color+fog+packed alpha)"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB)", 2D) = "black" {}
_ChromaTex("Chroma", 2D) = "black" {}
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 200
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
CGPROGRAM
#pragma surface surf Lambert vertex:VertexFunction alpha
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#include "AVProVideo.cginc"
uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform fixed4 _Color;
struct Input
{
float4 texcoords;
};
void VertexFunction(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
o.texcoords = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, v.texcoord, _MainTex_ST.y < 0.0);
}
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, IN.texcoords.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, IN.texcoords.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, IN.texcoords.zw);
#endif
col *= _Color;
o.Albedo = col.rgb;
o.Alpha = col.a;
}
ENDCG
}
Fallback "Legacy Shaders/Transparent/VertexLit"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 751148eda67f7b34fbd51bfb7951084f
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,215 @@
Shader "AVProVideo/Skybox/3x2 Cube"
{
Properties
{
_Tint ("Tint Color", Color) = (.5, .5, .5, .5)
[Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _MainTex ("MainTex (HDR)", 2D) = "grey" { }
[NoScaleOffset] _ChromaTex ("Chroma", 2D) = "grey" { }
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo ("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
Cull Off ZWrite Off
CGINCLUDE
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
half4 _Tint;
half _Exposure;
float _Rotation;
sampler2D _MainTex;
float4 _MainTex_TexelSize;
half4 _MainTex_HDR;
float4 _MainTex_ST;
#if USE_YPCBCR
sampler2D _ChromaTex;
float4x4 _YpCbCrTransform;
#endif
float3 RotateAroundYInDegrees (float3 vertex, float degrees)
{
const float CONST_PI = 3.14159265359f;
float alpha = degrees * CONST_PI / 180.0;
float sina, cosa;
sincos(alpha, sina, cosa);
float2x2 m = float2x2(cosa, -sina, sina, cosa);
return float3(mul(m, vertex.xz), vertex.y).xzy;
}
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
#if STEREO_DEBUG
float4 tint : COLOR;
#endif
#endif
};
static const float onehalf = 1.0 / 2.0;
static const float onethird = 1.0 / 3.0;
static const float twothird = 2.0 / 3.0;
static const float exp_coeff = 1.01;
static const float2 face_scale = float2(onethird, onehalf);
v2f sb_vert(appdata_t v, float2 face_offset)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
#endif
float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
o.vertex = XFormObjectToClip(float4(rotated, 0.0));
// Remap texcoords for the cubemap face with the offset passed in.
float2 t = _MainTex_TexelSize.wz * face_scale;
float2 p = (floor((t * exp_coeff) - t) / t) * 0.5;
float2 hp = p * 0.5;
float2 of = face_offset + hp;
float2 s = face_scale - p;
float2 uv = v.texcoord * s + of;
o.texcoord = TRANSFORM_TEX(uv, _MainTex);
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
o.texcoord *= scaleOffset.xy;
o.texcoord += scaleOffset.zw;
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
#endif
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 tex;
#if USE_YPCBCR
tex = SampleYpCbCr(_MainTex, _ChromaTex, i.texcoord, _YpCbCrTransform);
#else
tex = SampleRGBA(_MainTex, i.texcoord);
#endif
half3 c = tex.rgb;
//c = DecodeHDR(tex, _MainTex_HDR);
//c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb;
c *= _Exposure;
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
#if STEREO_DEBUG
c *= i.tint;
#endif
#endif
return half4(c, 1.0);
}
ENDCG
Pass // Front
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(onethird, 0));
}
ENDCG
}
Pass // Back
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(twothird, 0));
}
ENDCG
}
Pass // Right
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(0, onehalf));
}
ENDCG
}
Pass // Left
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(onethird, onehalf));
}
ENDCG
}
Pass // Top
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(twothird, onehalf));
}
ENDCG
}
Pass // Bottom
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v, float2(0, 0));
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 7a533059caadf0a4388b91e05079e0d5
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,186 @@
Shader "AVProVideo/Skybox/Sphere - Android OES"
{
Properties
{
_Tint ("Tint Color", Color) = (0.5, 0.5, 0.5, 0.5)
[Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _MainTex ("MainTex (HDR)", 2D) = "grey" { }
[NoScaleOffset] _ChromaTex ("Chroma", 2D) = "grey" { }
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo ("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
Cull Off
ZWrite Off
Pass
{
GLSLPROGRAM
#pragma only_renderers gles3
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ LAYOUT_EQUIRECT180
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "AVProVideo.cginc"
#define fmod(x, y) ((x) - (y) * floor((x) / (y)))
const float CONST_PI = 3.14159265359;
//--------------------------------------------------------------------------------------------------------------
// Vertex shader
#ifdef VERTEX
uniform vec4 _MainTex_ST;
uniform float _Rotation;
out vec3 texcoord;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
out vec4 scaleOffset;
#endif
#if defined(STEREO_DEBUG)
out vec4 tint;
#endif
vec3 RotateAroundYInDegrees(vec3 vertex, float degrees)
{
float alpha = degrees * CONST_PI / 180.0;
float sina = sin(alpha);
float cosa = cos(alpha);
mat2 m = mat2(cosa, -sina, sina, cosa);
return vec3(m * vertex.xz, vertex.y).xzy;
}
void main()
{
vec3 rotated = RotateAroundYInDegrees(gl_Vertex.xyz, _Rotation);
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * vec4(rotated, 0.0);
#else
gl_Position = XFormObjectToClip(vec4(rotated, 0.0));
#endif
#if defined(FORCEEYE_LEFT)
bool isLeftEye = true;
#elif defined(FORCEEYE_RIGHT)
bool isLeftEye = false;
#elif defined(STEREO_MULTIVIEW_ON)
bool isLeftEye = eyeIndex == 0;
#else
bool isLeftEye = true;
#endif
texcoord = gl_Vertex.xyz;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
scaleOffset = GetStereoScaleOffset(isLeftEye, true);
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint(isLeftEye);
#endif
}
#endif // VERTEX
//--------------------------------------------------------------------------------------------------------------
// Fragment shader
#ifdef FRAGMENT
in vec3 texcoord;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
in vec4 scaleOffset;
#endif
#if defined(STEREO_DEBUG)
in vec4 tint;
#endif
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
uniform vec4 _MainTex_ST;
uniform mat4 _MainTex_Xfrm;
uniform float _Exposure;
uniform vec4 _Tint;
vec2 toRadialCoords(vec3 coords)
{
vec3 normalizedCoords = normalize(coords);
float latitude = acos(normalizedCoords.y);
float longitude = atan(normalizedCoords.z, normalizedCoords.x);
vec2 sphereCoords = vec2(longitude, latitude) * vec2(0.5 / CONST_PI, 1.0 / CONST_PI);
vec2 radial = vec2(0.5, 1.0) - sphereCoords;
radial.x += 0.25;
radial.x = fmod(radial.x, 1.0);
return radial;
}
vec2 transformTex(vec2 texCoord, vec4 texST)
{
return texCoord * texST.xy + texST.zw;
}
void main()
{
vec2 tc = toRadialCoords(texcoord);
#if defined(LAYOUT_EQUIRECT180)
tc.x = ((tc.x - 0.5) * 2.0) + 0.5;
if (tc.x < 0.0 || tc.x > 1.0)
{
discard;
}
#endif
tc = (_MainTex_Xfrm * vec4(tc.x, tc.y, 0.0, 1.0)).xy;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
tc.xy *= scaleOffset.xy;
tc.xy += scaleOffset.zw;
#endif
tc = transformTex(tc, _MainTex_ST);
vec4 col = texture(_MainTex, tc);
#if defined(APPLY_GAMMA)
col.rgb = GammaToLinear(col.rgb);
#endif
col.rgb *= _Exposure;
// col.rgb *= _Tint.rgb;
#if defined(STEREO_DEBUG)
col *= tint;
#endif
gl_FragColor = col;
}
#endif // FRAGMENT
ENDGLSL
}
}
Fallback "AVProVideo/Skybox/Sphere"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1eae6c2be3a6c4093abcd4117c757d06
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
Shader "AVProVideo/Skybox/Sphere"
{
Properties
{
_Tint ("Tint Color", Color) = (.5, .5, .5, .5)
[Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _MainTex ("MainTex (HDR)", 2D) = "grey" { }
[NoScaleOffset] _ChromaTex ("Chroma", 2D) = "grey" { }
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo ("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
Cull Off ZWrite Off
CGINCLUDE
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ LAYOUT_EQUIRECT180
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
half4 _Tint;
half _Exposure;
float _Rotation;
sampler2D _MainTex;
float4 _MainTex_TexelSize;
half4 _MainTex_HDR;
float4 _MainTex_ST;
#if USE_YPCBCR
sampler2D _ChromaTex;
float4x4 _YpCbCrTransform;
#endif
float3 RotateAroundYInDegrees (float3 vertex, float degrees)
{
const float CONST_PI = 3.14159265359f;
float alpha = degrees * CONST_PI / 180.0;
float sina, cosa;
sincos(alpha, sina, cosa);
float2x2 m = float2x2(cosa, -sina, sina, cosa);
return float3(mul(m, vertex.xz), vertex.y).xzy;
}
inline float2 ToRadialCoords(float3 coords)
{
const float CONST_PI = 3.14159265359f;
float3 normalizedCoords = normalize(coords);
float latitude = acos(normalizedCoords.y);
float longitude = atan2(normalizedCoords.z, normalizedCoords.x);
float2 sphereCoords = float2(longitude, latitude) * float2(0.5/CONST_PI, 1.0/CONST_PI);
float2 radial = float2(0.5,1.0) - sphereCoords;
radial.x += 0.25;
radial.x = fmod(radial.x, 1.0);
return radial;
}
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f {
float4 vertex : SV_POSITION;
float3 texcoord : TEXCOORD0;
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset : TEXCOORD1;
#endif
#if (STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT) && STEREO_DEBUG
float4 tint : COLOR;
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
v2f sb_vert(appdata_t v)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v); // calculates and sets the built-n unity_StereoEyeIndex and unity_InstanceID Unity shader variables to the correct values based on which eye the GPU is currently rendering
UNITY_INITIALIZE_OUTPUT(v2f, o); // initializes all v2f values to 0
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); // tells the GPU which eye in the texture array it should render to
#endif
float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation);
o.vertex = XFormObjectToClip(float4(rotated, 0.0));
o.texcoord = v.vertex.xyz;
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
o.scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
#endif
#if (STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT) && STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
return o;
}
half4 frag(v2f i) : SV_Target
{
float2 tc = ToRadialCoords(i.texcoord);
#if LAYOUT_EQUIRECT180
float x = ((tc.x - 0.5) * 2.0) + 0.5;
if (x < 0.0 || x > 1.0)
{
discard;
}
tc.x = saturate(x);
#endif
tc = TRANSFORM_TEX(tc, _MainTex);
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
tc.xy *= i.scaleOffset.xy;
tc.xy += i.scaleOffset.zw;
#endif
#if USE_YPCBCR
half4 col = SampleYpCbCr(_MainTex, _ChromaTex, tc, _YpCbCrTransform);
#else
half4 col = SampleRGBA(_MainTex, tc);
#endif
//c = DecodeHDR(tex, _MainTex_HDR);
//c = c * _Tint.rgb;
///c = c * unity_ColorSpaceDouble.rgb;
col.rgb *= _Exposure;
#if (STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT) && STEREO_DEBUG
col *= i.tint;
#endif
return col;
}
ENDCG
Pass // Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
v2f vert(appdata_t v)
{
return sb_vert(v);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d7bb9d4ea887e4041877356986247bba
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,134 @@
Shader "AVProVideo/Unlit/Opaque (texture+color+stereo support) - Android OES ONLY"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "black" { }
_ChromaTex("Chroma", 2D) = "gray" { } // For fallback shader
_Color("Main Color", Color) = (1,1,1,1) // For fallback shader
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" "IgnoreProjector"="False" "Queue"="Geometry" }
LOD 100
Lighting Off
Cull Off
Pass
{
GLSLPROGRAM
#pragma only_renderers gles3
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "AVProVideo.cginc"
#ifdef VERTEX
out vec2 texVal;
uniform vec4 _MainTex_ST;
uniform mat4 _MainTex_Xfrm;
#if defined(STEREO_DEBUG)
out vec4 tint;
#endif
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
texVal = gl_MultiTexCoord0.xy;
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal = (_MainTex_Xfrm * vec4(texVal.x, texVal.y, 0.0, 1.0)).xy;
texVal = TRANSFORM_TEX_ST(texVal, _MainTex_ST);
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
texVal.xy *= scaleOffset.xy;
texVal.xy += scaleOffset.zw;
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint(Android_IsStereoEyeLeft());
#endif
}
#endif
#ifdef FRAGMENT
in vec2 texVal;
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
#if defined(STEREO_DEBUG)
in vec4 tint;
#endif
void main()
{
vec4 col = texture(_MainTex, texVal.xy);
#if defined(APPLY_GAMMA) && !defined(USING_DEFAULT_TEXTURE)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(STEREO_DEBUG)
col *= tint;
#endif
gl_FragColor = col;
}
#endif
ENDGLSL
}
}
Fallback "AVProVideo/Unlit/Opaque (texture+color+fog+stereo support)"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: eb44a525a7e2c6640a8cd90fd7fabce4
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,111 @@
Shader "AVProVideo/Unlit/Transparent (texture+alpha support) - Android OES ONLY"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "black" { }
_ChromaTex("Chroma", 2D) = "gray" { } // For fallback shader
_Color("Main Color", Color) = (1,1,1,1) // For fallback shader
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "IgnoreProjector"="True" "Queue"="Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
Cull Off
Pass
{
GLSLPROGRAM
#pragma only_renderers gles3
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "AVProVideo.cginc"
#ifdef VERTEX
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
out vec4 texVal;
#else
out vec2 texVal;
#endif
uniform vec4 _MainTex_ST;
uniform vec4 _MainTex_TexelSize;
uniform mat4 _MainTex_Xfrm;
void main()
{
gl_Position = XFormObjectToClip(gl_Vertex);
texVal.xy = gl_MultiTexCoord0.xy;
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal.xy = (_MainTex_Xfrm * vec4(texVal.x, texVal.y, 0.0, 1.0) ).xy;
texVal.xy = TRANSFORM_TEX_ST(texVal, _MainTex_ST);
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
texVal = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, texVal.xy, _MainTex_ST.y < 0.0);
#if defined(ALPHAPACK_TOP_BOTTOM)
texVal.yw = texVal.wy;
#endif
#endif
}
#endif // VERTEX
#ifdef FRAGMENT
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
in vec4 texVal;
#else
in vec2 texVal;
#endif
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
void main()
{
vec4 col = texture(_MainTex, texVal.xy);
#if defined(APPLY_GAMMA) && !defined(USING_DEFAULT_TEXTURE)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
vec3 rgb = texture(_MainTex, texVal.zw).rgb;
col.a = (rgb.r + rgb.g + rgb.b) / 3.0;
#endif
gl_FragColor = col;
}
#endif
ENDGLSL
}
}
Fallback "AVProVideo/Unlit/Transparent (texture+color+fog+stereo+alpha)"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 329f34b49d9d2e941951589b296d042a
timeCreated: 1634745134
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,149 @@
Shader "AVProVideo/Unlit/Transparent (texture+color+fog+stereo+alpha)"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "black" { }
_ChromaTex("Chroma", 2D) = "gray" { }
_Color("Main Color", Color) = (1,1,1,1)
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "IgnoreProjector"="True" "Queue"="Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
#if STEREO_CUSTOM_UV
float2 uv2 : TEXCOORD1; // Custom uv set for right eye (left eye is in TEXCOORD0)
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 uv : TEXCOORD0;
#if STEREO_DEBUG
float4 tint : COLOR;
#endif
UNITY_FOG_COORDS(1)
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform float4x4 _MainTex_Xfrm;
uniform fixed4 _Color;
v2f vert (appdata v)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v); // calculates and sets the built-n unity_StereoEyeIndex and unity_InstanceID Unity shader variables to the correct values based on which eye the GPU is currently rendering
UNITY_INITIALIZE_OUTPUT(v2f, o); // initializes all v2f values to 0
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); // tells the GPU which eye in the texture array it should render to
#endif
o.vertex = XFormObjectToClip(v.vertex);
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
o.uv.xy = mul(_MainTex_Xfrm, float4(v.uv.xy, 0.0, 1.0)).xy;
o.uv.xy = TRANSFORM_TEX(o.uv.xy, _MainTex);
// Horrible hack to undo the scale transform to fit into our UV packing layout logic...
if (_MainTex_ST.y < 0.0)
{
o.uv.y = 1.0 - o.uv.y;
}
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
o.uv.xy *= scaleOffset.xy;
o.uv.xy += scaleOffset.zw;
#elif STEREO_CUSTOM_UV
if (!IsStereoEyeLeft())
{
o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
}
#endif
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
o.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, o.uv.xy, _MainTex_ST.y < 0.0);
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, i.uv.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, i.uv.zw);
#endif
col *= _Color;
#if STEREO_DEBUG
col *= i.tint;
#endif
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 0ed1fb9218ad96f49acfdb428d5b5aab
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,160 @@
Shader "AVProVideo/Unlit/Opaque (texture+color+fog+stereo support)"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "black" { }
_ChromaTex ("Chroma", 2D) = "gray" { }
_MainTex_R ("Right Eye Base", 2D) = "black" { }
_ChromaTex_R ("Right Eye Chroma", 2D) = "gray" { }
_Color("Main Color", Color) = (1, 1, 1, 1)
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV, TwoTextures)] Stereo("Stereo Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" "IgnoreProjector"="False" "Queue"="Geometry" }
LOD 100
Lighting Off
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV STEREO_TWO_TEXTURES
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
#if STEREO_CUSTOM_UV
float2 uv2 : TEXCOORD1; // Custom uv set for right eye (left eye is in TEXCOORD0)
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
#if STEREO_DEBUG
half4 tint : COLOR;
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4x4 _MainTex_Xfrm;
#if STEREO_TWO_TEXTURES
uniform sampler2D _MainTex_R;
#if USE_YPCBCR
uniform sampler2D _ChromaTex_R;
#endif
#endif
uniform half4 _Color;
v2f vert (appdata v)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v); // calculates and sets the built-n unity_StereoEyeIndex and unity_InstanceID Unity shader variables to the correct values based on which eye the GPU is currently rendering
UNITY_INITIALIZE_OUTPUT(v2f, o); // initializes all v2f values to 0
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); // tells the GPU which eye in the texture array it should render to
#endif
o.vertex = XFormObjectToClip(v.vertex);
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
o.uv.xy = mul(_MainTex_Xfrm, float4(v.uv.xy, 0.0, 1.0)).xy;
o.uv.xy = TRANSFORM_TEX(o.uv, _MainTex);
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
o.uv.xy *= scaleOffset.xy;
o.uv.xy += scaleOffset.zw;
#elif STEREO_CUSTOM_UV
if (!IsStereoEyeLeft())
{
o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
}
#endif
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
inline half4 sampleTextureForEye(float2 uv, bool rightEye)
{
#if STEREO_TWO_TEXTURES
if (rightEye)
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex_R, _ChromaTex_R, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex_R, uv);
#endif
}
else
#endif
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex, _ChromaTex, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex, uv);
#endif
}
}
fixed4 frag(v2f i) : SV_Target
{
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#endif
half4 col = sampleTextureForEye(i.uv, IsStereoEyeRight()) * _Color;
#if STEREO_DEBUG
col *= i.tint;
#endif
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 1ca6555d94ddb204c87e9fe549085b3c
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,258 @@
Shader "AVProVideo/VR/InsideSphere Unlit (stereo+color) - Android OES ONLY"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "black" {}
_ChromaTex("Chroma", 2D) = "white" {} // For fallback shader
_Color("Color", Color) = (0.0, 1.0, 0.0, 1.0)
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye("Force Eye Mode", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(HIGH_QUALITY)] _HighQuality("High Quality", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
}
SubShader
{
Tags{ "Queue" = "Geometry" }
Pass
{
Cull Front
//ZTest Always
ZWrite On
Lighting Off
GLSLPROGRAM
#pragma only_renderers gles gles3
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ LAYOUT_EQUIRECT180
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ HIGH_QUALITY
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#ifdef VERTEX
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "AVProVideo.cginc"
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
#if defined(HIGH_QUALITY)
varying vec3 texNormal;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
varying vec4 texScaleOffset;
#endif
#else
varying vec3 texVal;
uniform vec4 _MainTex_ST;
uniform mat4 _MainTex_Xfrm;
#endif
#if defined(STEREO_DEBUG)
varying vec4 tint;
#endif
/// @fix: explicit TRANSFORM_TEX(); Unity's preprocessor chokes when attempting to use the TRANSFORM_TEX() macro in UnityCG.glslinc
/// (as of Unity 4.5.0f6; issue dates back to 2011 or earlier: http://forum.unity3d.com/threads/glsl-transform_tex-and-tiling.93756/)
vec2 transformTex(vec2 texCoord, vec4 texST)
{
return (texCoord * texST.xy + texST.zw);
}
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
#if defined(HIGH_QUALITY)
texNormal = normalize(gl_Normal.xyz);
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
texScaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), true);
#endif
#else
texVal.xy = gl_MultiTexCoord0.xy;
texVal.xy = transformTex(gl_MultiTexCoord0.xy, _MainTex_ST);
texVal.x = 1.0 - texVal.x;
#if defined(LAYOUT_EQUIRECT180)
texVal.x = ((texVal.x - 0.5) * 2.0) + 0.5;
// Set value for clipping if UV area is behind viewer
texVal.z = (gl_MultiTexCoord0.x > 0.25 && gl_MultiTexCoord0.x < 0.75) ? 1.0 : -1.0;
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal.xy = (_MainTex_Xfrm * vec4(texVal.x, texVal.y, 0.0, 1.0)).xy;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
texVal.xy *= scaleOffset.xy;
texVal.xy += scaleOffset.zw;
#elif defined(STEREO_CUSTOM_UV)
if(!Android_IsStereoEyeLeft())
{
texVal.xy= transformTex(gl_MultiTexCoord1.xy, _MainTex_ST);
texVal.xy = vec2(1.0, 1.0) - texVal.xy;
}
#endif
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint(Android_IsStereoEyeLeft());
#endif
}
#endif
#ifdef FRAGMENT
#if defined(HIGH_QUALITY)
#if defined (GL_FRAGMENT_PRECISION_HIGH)
precision highp float;
#endif
varying vec3 texNormal;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
varying vec4 texScaleOffset;
#endif
uniform mat4 _MainTex_Xfrm;
#else
varying vec3 texVal;
#endif
#if defined(STEREO_DEBUG)
varying vec4 tint;
#endif
#if defined(APPLY_GAMMA)
vec3 GammaToLinear(vec3 col)
{
return col * (col * (col * 0.305306011 + 0.682171111) + 0.012522878);
}
#endif
#if defined(HIGH_QUALITY)
vec2 NormalToEquiRect(vec3 n)
{
const float M_1_PI = 0.31830988618379067153776752674503; // 1.0/PI
const float M_1_2PI = 0.15915494309189533576888376337251; // 2.0/PI
vec2 uv;
uv.x = 0.5 - atan(n.z, n.x) * M_1_2PI;
uv.y = 0.5 - asin(-n.y) * M_1_PI;
return uv;
}
/// @fix: explicit TRANSFORM_TEX(); Unity's preprocessor chokes when attempting to use the TRANSFORM_TEX() macro in UnityCG.glslinc
/// (as of Unity 4.5.0f6; issue dates back to 2011 or earlier: http://forum.unity3d.com/threads/glsl-transform_tex-and-tiling.93756/)
vec2 transformTex(vec2 texCoord, vec4 texST)
{
return (texCoord * texST.xy + texST.zw);
}
uniform vec4 _MainTex_ST;
#endif
uniform vec4 _Color;
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
void main()
{
vec2 uv;
#if defined(HIGH_QUALITY)
vec3 n = normalize(texNormal);
#if defined(LAYOUT_EQUIRECT180)
if( n.z > 0.0001 )
{
// Clip pixels on the back of the sphere
discard;
}
#endif
uv = NormalToEquiRect(n);
uv.x += 0.75;
uv.x = mod(uv.x, 1.0);
uv = transformTex(uv, _MainTex_ST);
#if defined(LAYOUT_EQUIRECT180)
uv.x = ((uv.x - 0.5) * 2.0) + 0.5;
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
uv.xy = (_MainTex_Xfrm * vec4(uv.x, uv.y, 0.0, 1.0)).xy;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
uv.xy *= texScaleOffset.xy;
uv.xy += texScaleOffset.zw;
#endif
#else
uv = texVal.xy;
#if defined(LAYOUT_EQUIRECT180)
if( texVal.z < -0.0001 )
{
// Clip pixels on the back of the sphere
discard;
}
#endif
#endif
vec4 col = vec4(1.0, 1.0, 0.0, 1.0);
#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
#if __VERSION__ < 300
col = texture2D(_MainTex, uv);
#else
col = texture(_MainTex, uv);
#endif
#endif
col *= _Color;
#if defined(APPLY_GAMMA) && !defined(USING_DEFAULT_TEXTURE)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(STEREO_DEBUG)
col *= tint;
#endif
gl_FragColor = col;
}
#endif
ENDGLSL
}
}
Fallback "AVProVideo/VR/InsideSphere Unlit (stereo+fog)"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: a22a9f37cda6a3b48be178ec57376024
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,104 @@
Shader "AVProVideo/VR/InsideSphere Unlit (stereo+fog) Stereo UV"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" "IgnoreProjector" = "True" "Queue" = "Background" }
ZWrite On
//ZTest Always
Cull Front
Lighting Off
Pass
{
CGPROGRAM
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
//#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
//#define STEREO_DEBUG 1
//#define HIGH_QUALITY 1
#pragma multi_compile_fog
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
struct appdata
{
float4 vertex : POSITION; // vertex position
float2 uv : TEXCOORD0; // texture coordinate 1
float2 uv2 : TEXCOORD1; // texture coordinate 2
};
struct v2f
{
float4 vertex : SV_POSITION; // clip space position
float2 uv : TEXCOORD0; // texture coordinate
UNITY_FOG_COORDS(1)
#if STEREO_DEBUG
float4 tint : COLOR;
#endif
};
uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
o.vertex = XFormObjectToClip(v.vertex);
if (IsStereoEyeLeft())
{
o.uv.xy = TRANSFORM_TEX(v.uv, _MainTex);
o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
}
else
{
o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
}
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float2 uv;
uv = i.uv;
fixed4 col = tex2D(_MainTex, uv);
#if APPLY_GAMMA
col.rgb = GammaToLinear(col.rgb);
#endif
#if STEREO_DEBUG
col *= i.tint;
#endif
UNITY_APPLY_FOG(i.fogCoord, col);
return fixed4(col.rgb, 1.0);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 08ccc6021f136814494572dcad0c489d
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,340 @@
Shader "AVProVideo/VR/InsideSphere Unlit Transparent (stereo+color+alpha) - Android OES ONLY"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "black" {}
_ChromaTex("Chroma", 2D) = "white" {} // For fallback shader
_Color("Color", Color) = (0.0, 1.0, 0.0, 1.0)
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye("Force Eye Mode", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(HIGH_QUALITY)] _HighQuality("High Quality", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
_EdgeFeather("Edge Feather", Range (0, 1)) = 0.02
}
SubShader
{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
Pass
{
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
Cull Front
Lighting Off
GLSLPROGRAM
#pragma only_renderers gles gles3
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ LAYOUT_EQUIRECT180
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ HIGH_QUALITY
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "AVProVideo.cginc"
#ifdef VERTEX
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
#if defined(HIGH_QUALITY)
varying vec3 texNormal;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
varying vec4 texScaleOffset;
#endif
#else
varying vec3 texVal;
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
varying vec2 alphaPackOffset;
#endif
uniform vec4 _MainTex_ST;
uniform vec4 _MainTex_TexelSize;
uniform mat4 _MainTex_Xfrm;
#endif
#if defined(STEREO_DEBUG)
varying vec4 tint;
#endif
/// @fix: explicit TRANSFORM_TEX(); Unity's preprocessor chokes when attempting to use the TRANSFORM_TEX() macro in UnityCG.glslinc
/// (as of Unity 4.5.0f6; issue dates back to 2011 or earlier: http://forum.unity3d.com/threads/glsl-transform_tex-and-tiling.93756/)
vec2 transformTex(vec2 texCoord, vec4 texST)
{
return (texCoord * texST.xy + texST.zw);
}
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
#if defined(HIGH_QUALITY)
texNormal = normalize(gl_Normal.xyz);
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
texScaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
#endif
#else
texVal.xy = gl_MultiTexCoord0.xy;
texVal.xy = transformTex(gl_MultiTexCoord0.xy, _MainTex_ST);
texVal.x = 1.0 - texVal.x;
#if defined(LAYOUT_EQUIRECT180)
texVal.x = ((texVal.x - 0.5) * 2.0) + 0.5;
// Set value for clipping if UV area is behind viewer
texVal.z = (gl_MultiTexCoord0.x > 0.25 && gl_MultiTexCoord0.x < 0.75) ? 1.0 : -1.0;
texVal.z = -gl_Normal.z;
#else
texVal.z = 0.0;
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal.xy = (_MainTex_Xfrm * vec4(texVal.x, texVal.y, 0.0, 1.0)).xy;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
texVal.xy *= scaleOffset.xy;
texVal.xy += scaleOffset.zw;
#elif defined(STEREO_CUSTOM_UV)
if(!Android_IsStereoEyeLeft())
{
texVal.xy= transformTex(gl_MultiTexCoord1.xy, _MainTex_ST);
texVal.xy = vec2(1.0, 1.0) - texVal.xy;
}
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
vec4 alphaOffset = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, texVal.xy, _MainTex_ST.y < 0.0);
#if defined(ALPHAPACK_TOP_BOTTOM)
alphaOffset.yw = alphaOffset.wy;
#endif
texVal.xy = alphaOffset.xy;
alphaPackOffset = alphaOffset.zw;
#endif
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint(Android_IsStereoEyeLeft());
#endif
}
#endif
#ifdef FRAGMENT
#if defined(HIGH_QUALITY)
#if defined (GL_FRAGMENT_PRECISION_HIGH)
precision highp float;
#endif
varying vec3 texNormal;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
varying vec4 texScaleOffset;
#endif
uniform mat4 _MainTex_Xfrm;
#else
varying vec3 texVal;
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
varying vec2 alphaPackOffset;
#endif
#endif
uniform float _EdgeFeather;
#if defined(STEREO_DEBUG)
varying vec4 tint;
#endif
#if defined(HIGH_QUALITY)
vec2 NormalToEquiRect(vec3 n)
{
const float M_1_PI = 0.31830988618379067153776752674503; // 1.0/PI
const float M_1_2PI = 0.15915494309189533576888376337251; // 2.0/PI
vec2 uv;
uv.x = 0.5 - atan(n.z, n.x) * M_1_2PI;
uv.y = 0.5 - asin(-n.y) * M_1_PI;
return uv;
}
/// @fix: explicit TRANSFORM_TEX(); Unity's preprocessor chokes when attempting to use the TRANSFORM_TEX() macro in UnityCG.glslinc
/// (as of Unity 4.5.0f6; issue dates back to 2011 or earlier: http://forum.unity3d.com/threads/glsl-transform_tex-and-tiling.93756/)
vec2 transformTex(vec2 texCoord, vec4 texST)
{
return (texCoord * texST.xy + texST.zw);
}
uniform vec4 _MainTex_ST;
uniform vec4 _MainTex_TexelSize;
#endif
uniform vec4 _Color;
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
void main()
{
vec4 uv = vec4(0.0, 0.0, 0.0, 0.0);
#if defined(HIGH_QUALITY)
vec3 n = normalize(texNormal);
#if defined(LAYOUT_EQUIRECT180)
if( n.z > 0.0001 )
{
// Clip pixels on the back of the sphere
discard;
}
#endif
uv.xy = NormalToEquiRect(n);
uv.x += 0.75;
uv.x = mod(uv.x, 1.0);
uv.xy = transformTex(uv.xy, _MainTex_ST);
#if defined(LAYOUT_EQUIRECT180)
uv.x = ((uv.x - 0.5) * 2.0) + 0.5;
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
uv.xy = (_MainTex_Xfrm * vec4(uv.x, uv.y, 0.0, 1.0)).xy;
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
uv.xy *= texScaleOffset.xy;
uv.xy += texScaleOffset.zw;
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, uv.xy, _MainTex_ST.y < 0.0);
#if defined(ALPHAPACK_TOP_BOTTOM)
uv.yw = uv.wy;
#endif
#endif
#else
uv.xy = texVal.xy;
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
uv.zw = alphaPackOffset;
#endif
#if defined(LAYOUT_EQUIRECT180)
if( texVal.z < -0.0001 )
{
// Clip pixels on the back of the sphere
discard;
}
#endif
#endif
vec4 col = vec4(1.0, 1.0, 0.0, 1.0);
#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
#if __VERSION__ < 300
col = texture2D(_MainTex, uv.xy);
#else
col = texture(_MainTex, uv.xy);
#endif
#endif
col *= _Color;
#if defined(APPLY_GAMMA) && !defined(USING_DEFAULT_TEXTURE)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
#if __VERSION__ < 300
vec3 rgb = texture2D(_MainTex, uv.zw).rgb;
#else
vec3 rgb = texture(_MainTex, uv.zw).rgb;
#endif
col.a = (rgb.r + rgb.g + rgb.b) / 3.0;
#else
col.a = 1.0;
#endif
#endif
#if defined(STEREO_DEBUG)
col *= tint;
#endif
#if defined(LAYOUT_EQUIRECT180)
// Apply edge feathering based on UV mapping - this is useful if you're using a hemisphere mesh for 180 degree video and want to have soft edges
if (_EdgeFeather > 0.0)
{
vec4 featherDirection = vec4(0.0, 0.0, 1.0, 1.0);
#if defined(STEREO_TOP_BOTTOM)
if (uv.y > 0.5)
{
featherDirection.y = 0.5;
}
else
{
featherDirection.w = 0.5;
}
#endif
#if defined(STEREO_LEFT_RIGHT)
if (uv.x > 0.5)
{
featherDirection.x = 0.5;
}
else
{
featherDirection.z = 0.5;
}
#endif
#if defined(ALPHAPACK_TOP_BOTTOM)
featherDirection.w *= 0.5;
#endif
#if defined(ALPHAPACK_LEFT_RIGHT)
featherDirection.z *= 0.5;
#endif
// float d = min(uv.x - featherDirection.x, min((uv.y - featherDirection.y), min(featherDirection.z - uv.x, featherDirection.w - uv.y)));
float d = (uv.x - featherDirection.x) * (uv.y - featherDirection.y) * (featherDirection.z - uv.x) * (featherDirection.w - uv.y) * 10.0;
float a = smoothstep(0.0, _EdgeFeather, d);
col.a *= a;
}
#endif
gl_FragColor = col;
}
#endif
ENDGLSL
}
}
Fallback "AVProVideo/VR/InsideSphere Unlit Transparent (stereo+color+fog+alpha)"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: d077c188d5d1c7c4f82531e47eb896a9
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,264 @@
Shader "AVProVideo/VR/InsideSphere Unlit Transparent (stereo+color+fog+alpha)"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
_ChromaTex("Chroma", 2D) = "white" {}
_Color("Main Color", Color) = (1,1,1,1)
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo ("Stereo Mode", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(HIGH_QUALITY)] _HighQuality ("High Quality", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
_EdgeFeather("Edge Feather", Range (0, 1)) = 0.02
}
SubShader
{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
ZWrite On
//ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
Cull Front
Lighting Off
Pass
{
CGPROGRAM
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
#if HIGH_QUALITY || APPLY_GAMMA
#pragma target 3.0
#endif
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ HIGH_QUALITY
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ LAYOUT_EQUIRECT180
struct appdata
{
float4 vertex : POSITION; // vertex position
#if HIGH_QUALITY
float3 normal : NORMAL;
#else
float2 uv : TEXCOORD0; // texture coordinate
#if STEREO_CUSTOM_UV
float2 uv2 : TEXCOORD1; // Custom uv set for right eye (left eye is in TEXCOORD0)
#endif
float3 normal : NORMAL;
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f
{
float4 vertex : SV_POSITION; // clip space position
#if HIGH_QUALITY
float3 normal : TEXCOORD0;
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset : TEXCOORD1; // texture coordinate
UNITY_FOG_COORDS(2)
#else
UNITY_FOG_COORDS(1)
#endif
#else
float4 uv : TEXCOORD0; // texture coordinate
UNITY_FOG_COORDS(1)
#endif
#if STEREO_DEBUG
float4 tint : COLOR;
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform fixed4 _Color;
uniform float _EdgeFeather;
v2f vert (appdata v)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v); // calculates and sets the built-n unity_StereoEyeIndex and unity_InstanceID Unity shader variables to the correct values based on which eye the GPU is currently rendering
UNITY_INITIALIZE_OUTPUT(v2f, o); // initializes all v2f values to 0
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); // tells the GPU which eye in the texture array it should render to
#endif
o.vertex = XFormObjectToClip(v.vertex);
#if !HIGH_QUALITY
o.uv.zw = 0.0;
o.uv.xy = TRANSFORM_TEX(v.uv, _MainTex);
#if LAYOUT_EQUIRECT180
o.uv.x = ((o.uv.x - 0.5) * 2.0) + 0.5;
// Set value for clipping if UV area is behind viewer
o.uv.z = -v.normal.z;
#endif
o.uv.xy = float2(1.0-o.uv.x, o.uv.y);
#endif
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
#if !HIGH_QUALITY
o.uv.xy *= scaleOffset.xy;
o.uv.xy += scaleOffset.zw;
#else
o.scaleOffset = scaleOffset;
#endif
#elif STEREO_CUSTOM_UV && !HIGH_QUALITY
if (!IsStereoEyeLeft())
{
o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
}
#endif
#if !HIGH_QUALITY
#if ALPHAPACK_TOP_BOTTOM || ALPHAPACK_LEFT_RIGHT
o.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, o.uv.xy, _MainTex_ST.y > 0.0);
#endif
#endif
#if HIGH_QUALITY
o.normal = v.normal;
#endif
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float4 uv = 0;
#if HIGH_QUALITY
float3 n = normalize(i.normal);
#if LAYOUT_EQUIRECT180
clip(-n.z); // Clip pixels on the back of the sphere
#endif
float M_1_PI = 1.0 / 3.1415926535897932384626433832795;
float M_1_2PI = 1.0 / 6.283185307179586476925286766559;
uv.x = 0.5 - atan2(n.z, n.x) * M_1_2PI;
uv.y = 0.5 - asin(-n.y) * M_1_PI;
uv.x += 0.75;
uv.x = fmod(uv.x, 1.0);
//uv.x = uv.x % 1.0;
uv.xy = TRANSFORM_TEX(uv, _MainTex);
#if LAYOUT_EQUIRECT180
uv.x = ((uv.x - 0.5) * 2.0) + 0.5;
#endif
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
uv.xy *= i.scaleOffset.xy;
uv.xy += i.scaleOffset.zw;
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, uv.xy, _MainTex_ST.y < 0.0);
#endif
#else
uv = i.uv;
#if LAYOUT_EQUIRECT180
clip(i.uv.z); // Clip pixels on the back of the sphere
#endif
#endif
fixed4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, uv.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, uv.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, uv.zw);
#endif
#if STEREO_DEBUG
col *= i.tint;
#endif
col *= _Color;
UNITY_APPLY_FOG(i.fogCoord, col);
#if LAYOUT_EQUIRECT180
// Apply edge feathering based on UV mapping - this is useful if you're using a hemisphere mesh for 180 degree video and want to have soft edges
if (_EdgeFeather > 0.0)
{
float4 featherDirection = float4(0.0, 0.0, 1.0, 1.0);
#if STEREO_TOP_BOTTOM
if (uv.y > 0.5)
{
featherDirection.y = 0.5;
}
else
{
featherDirection.w = 0.5;
}
#endif
#if STEREO_LEFT_RIGHT
if (uv.x > 0.5)
{
featherDirection.x = 0.5;
}
else
{
featherDirection.z = 0.5;
}
#endif
#if ALPHAPACK_TOP_BOTTOM
featherDirection.w *= 0.5;
#endif
#if ALPHAPACK_LEFT_RIGHT
featherDirection.z *= 0.5;
#endif
// float d = min(uv.x - featherDirection.x, min((uv.y - featherDirection.y), min(featherDirection.z - uv.x, featherDirection.w - uv.y)));
float d = (uv.x - featherDirection.x) * (uv.y - featherDirection.y) * (featherDirection.z - uv.x) * (featherDirection.w - uv.y) * 10.0;
float a = smoothstep(0.0, _EdgeFeather, d);
col.a *= a;
}
#endif
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 867ec56bd96e5504a95f991314cd5706
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,222 @@
Shader "AVProVideo/VR/InsideSphere Unlit (stereo+fog)"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
_ChromaTex("Chroma", 2D) = "white" {}
_MainTex_R ("Right Eye Base", 2D) = "black" { }
_ChromaTex_R ("Right Eye Chroma", 2D) = "gray" { }
[KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV, TwoTextures)] Stereo ("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
[KeywordEnum(None, EquiRect180)] Layout("Layout", Float) = 0
[Toggle(HIGH_QUALITY)] _HighQuality ("High Quality", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" "IgnoreProjector" = "True" "Queue" = "Background" }
ZWrite On
//ZTest Always
Cull Front
Lighting Off
Pass
{
CGPROGRAM
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
#if HIGH_QUALITY || APPLY_GAMMA
#pragma target 3.0
#endif
#pragma vertex vert
#pragma fragment frag
//#define STEREO_DEBUG 1
//#define HIGH_QUALITY 1
#pragma multi_compile_fog
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV STEREO_TWO_TEXTURES
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ HIGH_QUALITY
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ LAYOUT_EQUIRECT180
struct appdata
{
float4 vertex : POSITION; // vertex position
#if HIGH_QUALITY
float3 normal : NORMAL;
#else
float2 uv : TEXCOORD0; // texture coordinate
#if STEREO_CUSTOM_UV
float2 uv2 : TEXCOORD1; // Custom uv set for right eye (left eye is in TEXCOORD0)
#endif
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f
{
float4 vertex : SV_POSITION; // clip space position
#if HIGH_QUALITY
float3 normal : TEXCOORD0;
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset : TEXCOORD1; // texture coordinate
UNITY_FOG_COORDS(2)
#else
UNITY_FOG_COORDS(1)
#endif
#else
float2 uv : TEXCOORD0; // texture coordinate
UNITY_FOG_COORDS(1)
#endif
#if STEREO_DEBUG
half4 tint : COLOR;
#endif
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4x4 _MainTex_Xfrm;
#if STEREO_TWO_TEXTURES
uniform sampler2D _MainTex_R;
#if USE_YPCBCR
uniform sampler2D _ChromaTex_R;
#endif
#endif
v2f vert(appdata v)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(v); // calculates and sets the built-n unity_StereoEyeIndex and unity_InstanceID Unity shader variables to the correct values based on which eye the GPU is currently rendering
UNITY_INITIALIZE_OUTPUT(v2f, o); // initializes all v2f values to 0
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); // tells the GPU which eye in the texture array it should render to
#endif
o.vertex = XFormObjectToClip(v.vertex);
#if !HIGH_QUALITY
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder
// decodes in blocks that overrun the video frame size, it pads)
o.uv.xy = mul(_MainTex_Xfrm, float4(v.uv.xy, 0.0, 1.0)).xy;
o.uv.xy = TRANSFORM_TEX(o.uv, _MainTex);
#if LAYOUT_EQUIRECT180
o.uv.x = ((o.uv.x - 0.5) * 2.0) + 0.5;
#endif
o.uv.xy = float2(1.0-o.uv.x, o.uv.y);
#endif
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
#if !HIGH_QUALITY
o.uv.xy *= scaleOffset.xy;
o.uv.xy += scaleOffset.zw;
#else
o.scaleOffset = scaleOffset;
#endif
#elif STEREO_CUSTOM_UV && !HIGH_QUALITY
if (IsStereoEyeRight())
{
o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
}
#endif
#if HIGH_QUALITY
o.normal = v.normal;
#endif
#if STEREO_DEBUG
o.tint = GetStereoDebugTint(IsStereoEyeLeft());
#endif
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
inline half4 sampleTextureForEye(float2 uv, bool rightEye)
{
#if STEREO_TWO_TEXTURES
if (rightEye)
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex_R, _ChromaTex_R, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex_R, uv);
#endif
}
else
#endif
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex, _ChromaTex, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex, uv);
#endif
}
}
fixed4 frag(v2f i) : SV_Target
{
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#endif
#if HIGH_QUALITY
float M_1_PI = 1.0 / 3.1415926535897932384626433832795;
float M_1_2PI = 1.0 / 6.283185307179586476925286766559;
float3 n = normalize(i.normal);
float x = 0.5 - atan2(n.z, n.x) * M_1_2PI + 0.75;
x = fmod(x, 1.0);
float y = 0.5 - asin(-n.y) * M_1_PI;
float2 uv = TRANSFORM_TEX(float2(x, y), _MainTex);
#if LAYOUT_EQUIRECT180
uv.x = ((uv.x - 0.5) * 2.0) + 0.5;
#endif
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
uv.xy *= i.scaleOffset.xy;
uv.xy += i.scaleOffset.zw;
#endif
#else
float2 uv = i.uv;
#endif
half4 col = sampleTextureForEye(uv, IsStereoEyeRight());
#if STEREO_DEBUG
col *= i.tint;
#endif
UNITY_APPLY_FOG(i.fogCoord, col);
return fixed4(col.rgb, 1.0);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 46b84ca7ab6291e4fb6c57ac48d01e8f
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,403 @@
//-----------------------------------------------------------------------------
// Copyright 2015-2021 RenderHeads Ltd. All rights reserverd.
//-----------------------------------------------------------------------------
//#define AVPRO_CHEAP_GAMMA_CONVERSION
#if defined (SHADERLAB_GLSL)
#define AVPRO_CHEAP_GAMMA_CONVERSION
#define INLINE
#define FIXED float
#define HALF float
#define HALF2 vec2
#define HALF3 vec3
#define HALF4 vec4
#define FLOAT2 vec2
#define FLOAT3 vec3
#define FLOAT4 vec4
#define FIXED4 vec4
#define FLOAT3X3 mat3
#define FLOAT4X4 mat4
#define LERP mix
#else
#define INLINE inline
#define FIXED fixed
#define HALF half
#define HALF2 half2
#define HALF3 half3
#define HALF4 half4
#define FLOAT2 float2
#define FLOAT3 float3
#define FLOAT4 float4
#define FIXED4 fixed4
#define FLOAT3X3 float3x3
#define FLOAT4X4 float4x4
#define LERP lerp
#endif
// Specify this so Unity doesn't automatically update our shaders.
#define UNITY_SHADER_NO_UPGRADE 1
//#pragma multi_compile __ XR_USE_BUILT_IN_EYE_VARIABLE
// We use this method so that when Unity automatically updates the shader from the old
// mul(UNITY_MATRIX_MVP.. to UnityObjectToClipPos that it only changes in one place.
INLINE FLOAT4 XFormObjectToClip(FLOAT4 vertex)
{
#if defined(SHADERLAB_GLSL)
return gl_ModelViewProjectionMatrix * vertex;
#else
return UnityObjectToClipPos(vertex);
#endif
}
uniform FLOAT3 _WorldCameraPosition;
uniform FLOAT3 _WorldCameraRight;
INLINE bool IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_TWO_TEXTURES)
return unity_StereoEyeIndex == 0;
#elif defined(USING_STEREO_MATRICES)
// Unity 5.4 has this new variable
return (unity_StereoEyeIndex == 0);
#elif defined (UNITY_DECLARE_MULTIVIEW)
// OVR_multiview extension
return (UNITY_VIEWID == 0);
#else
#if defined(SHADERLAB_GLSL) && defined(USING_URP)
// NOTE: Bug #1416: URP + OES
FLOAT3 renderCameraPos = FLOAT3( gl_ModelViewMatrixInverseTranspose[0][3], gl_ModelViewMatrixInverseTranspose[1][3], gl_ModelViewMatrixInverseTranspose[2][3] );
#elif defined(UNITY_MATRIX_I_V)
// NOTE: Bug #1165: _WorldSpaceCameraPos is not correct in multipass VR (when skybox is used) but UNITY_MATRIX_I_V seems to be
FLOAT3 renderCameraPos = UNITY_MATRIX_I_V._m03_m13_m23;
#else
FLOAT3 renderCameraPos = _WorldSpaceCameraPos.xyz;
#endif
float fL = distance(_WorldCameraPosition - _WorldCameraRight, renderCameraPos);
float fR = distance(_WorldCameraPosition + _WorldCameraRight, renderCameraPos);
return (fL < fR);
#endif
}
INLINE bool IsStereoEyeRight()
{
return !IsStereoEyeLeft();
}
#if defined(STEREO_TOP_BOTTOM)
FLOAT4 GetStereoScaleOffset(bool isLeftEye, bool isYFlipped)
{
float oy = isLeftEye ? 0.5 : 0.0;
if (isYFlipped)
{
oy = 0.5 - oy;
}
return FLOAT4(1.0, 0.5, 0.0, oy);
}
#elif defined(STEREO_LEFT_RIGHT)
FLOAT4 GetStereoScaleOffset(bool isLeftEye, bool isYFlipped)
{
return FLOAT4(0.5, 1.0, isLeftEye ? 0.0 : 0.5, 0.0);
}
#endif
#if defined(STEREO_DEBUG)
INLINE HALF4 GetStereoDebugTint(bool isLeftEye)
{
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT) || defined(STEREO_CUSTOM_UV) || defined(STEREO_TWO_TEXTURES)
if (isLeftEye)
{
return HALF4(0.0, 1.0, 0.0, 1.0); // Left
}
else
{
return HALF4(1.0, 0.0, 0.0, 1.0); // Right
}
#else
return HALF4(1.0, 1.0, 1.0, 1.0); // White
#endif
}
#endif
FLOAT2 ScaleZoomToFit(float targetWidth, float targetHeight, float sourceWidth, float sourceHeight)
{
#if defined(ALPHAPACK_TOP_BOTTOM)
sourceHeight *= 0.5;
#elif defined(ALPHAPACK_LEFT_RIGHT)
sourceWidth *= 0.5;
#endif
float targetAspect = targetHeight / targetWidth;
float sourceAspect = sourceHeight / sourceWidth;
FLOAT2 scale = FLOAT2(1.0, sourceAspect / targetAspect);
if (targetAspect < sourceAspect)
{
scale = FLOAT2(targetAspect / sourceAspect, 1.0);
}
return scale;
}
FLOAT4 OffsetAlphaPackingUV(FLOAT2 texelSize, FLOAT2 uv, bool flipVertical)
{
if (flipVertical)
{
uv.y = 1.0 - uv.y;
}
FLOAT4 result = uv.xyxy;
// We don't want bilinear interpolation to cause bleeding when reading the pixels at the edge of the
// packed areas, so we shift the UV's by a fraction of a pixel so the edges don't get sampled.
#if defined(ALPHAPACK_TOP_BOTTOM)
float offset = texelSize.y * 1.5;
float y = LERP(offset, 0.5 - offset, uv.y);
// [MOZ] 250218 - UNITY_UV_STARTS_AT_TOP here breaks OpenGLES on Android, need to check to see if it's required
// on other platforms, good on Android OpenGLES & Vulkan, Metal
#if 1 //defined(UNITY_UV_STARTS_AT_TOP)
result.y = 0.5 + y;
result.w = y;
#else
result.y = y;
result.w = 0.5 + y;
#endif
if (flipVertical)
{
result.yw = result.wy;
}
#elif defined(ALPHAPACK_LEFT_RIGHT)
float offset = texelSize.x * 1.5;
float x = LERP(offset, 0.5 - offset, uv.x);
result.x = x;
result.z = 0.5 + x;
#endif
return result;
}
INLINE HALF3 GammaToLinear_ApproxPow(HALF3 col)
{
#if defined (SHADERLAB_GLSL)
return pow(col, HALF3(2.2, 2.2, 2.2));
#else
return pow(col, HALF3(2.2h, 2.2h, 2.2h));
#endif
}
INLINE HALF3 LinearToGamma_ApproxPow(HALF3 col)
{
#if defined (SHADERLAB_GLSL)
return pow(col, HALF3(1.0/2.2, 1.0/2.2, 1.0/2.2));
#else
return pow(col, HALF3(1.0h/2.2h, 1.0h/2.2h, 1.0h/2.2h));
#endif
}
// Approximate version from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1
// NOTE: This is about 4 instructions vs 10 instructions for the accurate version
INLINE HALF3 GammaToLinear_ApproxFit(HALF3 col)
{
#if defined (SHADERLAB_GLSL)
HALF a = 0.305306011;
HALF b = 0.682171111;
HALF c = 0.012522878;
#else
HALF a = 0.305306011h;
HALF b = 0.682171111h;
HALF c = 0.012522878h;
#endif
return col * (col * (col * a + b) + c);
}
// Approximate version from http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1
INLINE HALF3 LinearToGamma_ApproxFit(HALF3 col)
{
#if defined (SHADERLAB_GLSL)
HALF a = 0.416666667;
HALF b = 0.055;
HALF c = 0.0;
HALF d = 1.055;
#else
HALF a = 0.416666667h;
HALF b = 0.055h;
HALF c = 0.0h;
HALF d = 1.055h;
#endif
return max(d * pow(col, HALF3(a, a, a)) - b, c);
}
INLINE HALF3 GammaToLinear_Accurate(HALF3 col)
{
if (col.r <= 0.04045)
col.r = col.r / 12.92;
else
col.r = pow((col.r + 0.055) / 1.055, 2.4);
if (col.g <= 0.04045)
col.g = col.g / 12.92;
else
col.g = pow((col.g + 0.055) / 1.055, 2.4);
if (col.b <= 0.04045)
col.b = col.b / 12.92;
else
col.b = pow((col.b + 0.055) / 1.055, 2.4);
// NOTE: We tried to optimise the above, but actually the compiler does a better job..
/*HALF3 a = col / 12.92;
HALF3 b = pow((col + 0.055) / 1.055, 2.4);
HALF3 c = step(col,0.04045);
col = LERP(b, a, c);*/
return col;
}
INLINE HALF3 LinearToGamma_Accurate(HALF3 col)
{
if (col.r <= 0.0031308)
col.r = col.r * 12.92;
else
col.r = 1.055 * pow(col.r, 0.4166667) - 0.055;
if (col.g <= 0.0031308)
col.g = col.g * 12.92;
else
col.g = 1.055 * pow(col.g, 0.4166667) - 0.055;
if (col.b <= 0.0031308)
col.b = col.b * 12.92;
else
col.b = 1.055 * pow(col.b, 0.4166667) - 0.055;
return col;
}
// http://entropymine.com/imageworsener/srgbformula/
INLINE HALF3 GammaToLinear(HALF3 col)
{
#if defined(AVPRO_CHEAP_GAMMA_CONVERSION)
return GammaToLinear_ApproxFit(col);
#else
return GammaToLinear_Accurate(col);
#endif
}
// http://entropymine.com/imageworsener/srgbformula/
INLINE HALF3 LinearToGamma(HALF3 col)
{
#if defined(AVPRO_CHEAP_GAMMA_CONVERSION)
return LinearToGamma_ApproxFit(col);
#else
return LinearToGamma_Accurate(col);
#endif
}
INLINE FLOAT3 ConvertYpCbCrToRGB(FLOAT3 YpCbCr, FLOAT4X4 YpCbCrTransform)
{
#if defined(SHADERLAB_GLSL)
return clamp(FLOAT3X3(YpCbCrTransform) * (YpCbCr + YpCbCrTransform[3].xyz), 0.0, 1.0);
#else
return saturate(mul((FLOAT3X3)YpCbCrTransform, YpCbCr + YpCbCrTransform[3].xyz));
#endif
}
#if defined(SHADERLAB_GLSL)
#if __VERSION__ < 300
#define TEX_EXTERNAL(sampler, uv) texture2D(sampler, uv.xy);
#else
#define TEX_EXTERNAL(sampler, uv) texture(sampler, uv.xy)
#endif
#endif
INLINE HALF4 SampleRGBA(sampler2D tex, FLOAT2 uv)
{
#if defined(SHADERLAB_GLSL) // GLSL doesn't support tex2D, and Adreno GPU doesn't support passing sampler as a parameter, so just return if this is called
return HALF4(1.0, 1.0, 0.0, 1.0);
#else
HALF4 rgba = tex2D(tex, uv);
#if defined(APPLY_GAMMA)
rgba.rgb = GammaToLinear(rgba.rgb);
#endif
return rgba;
#endif
}
INLINE HALF4 SampleYpCbCr(sampler2D luma, sampler2D chroma, FLOAT2 uv, FLOAT4X4 YpCbCrTransform)
{
#if defined(SHADERLAB_GLSL) // GLSL doesn't support tex2D, and Adreno GPU doesn't support passing sampler as a parameter, so just return if this is called
return HALF4(1.0, 1.0, 0.0, 1.0);
#else
#if defined(SHADER_API_METAL) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
FLOAT3 YpCbCr = FLOAT3(tex2D(luma, uv).r, tex2D(chroma, uv).rg);
#else
FLOAT3 YpCbCr = FLOAT3(tex2D(luma, uv).r, tex2D(chroma, uv).ra);
#endif
HALF4 rgba = HALF4(ConvertYpCbCrToRGB(YpCbCr, YpCbCrTransform), 1.0);
#if defined(APPLY_GAMMA)
rgba.rgb = GammaToLinear(rgba.rgb);
#endif
return rgba;
#endif
}
INLINE HALF SamplePackedAlpha(sampler2D tex, FLOAT2 uv)
{
#if defined(SHADERLAB_GLSL) // GLSL doesn't support tex2D, and Adreno GPU doesn't support passing sampler as a parameter, so just return if this is called
return 0.0;
#else
HALF alpha;
#if defined(USE_YPCBCR)
alpha = (tex2D(tex, uv).r - 0.0625) * (255.0 / 219.0);
#else
HALF3 rgb = tex2D(tex, uv).rgb;
#if defined(APPLY_GAMMA)
rgb = GammaToLinear(rgb);
#endif
alpha = (rgb.r + rgb.g + rgb.b) / 3.0;
#endif
return alpha;
#endif
}
#if defined(USE_HSBC)
INLINE HALF3 ApplyHue(HALF3 color, HALF hue)
{
HALF angle = radians(hue);
HALF3 k = HALF3(0.57735, 0.57735, 0.57735);
HALF cosAngle = cos(angle);
//Rodrigues' rotation formula
return color * cosAngle + cross(k, color) * sin(angle) + k * dot(k, color) * (1.0 - cosAngle);
}
INLINE HALF3 ApplyHSBEffect(HALF3 color, FIXED4 hsbc)
{
HALF hue = hsbc.r * 360.0;
HALF saturation = hsbc.g * 2.0;
HALF brightness = hsbc.b * 2.0 - 1.0;
HALF contrast = hsbc.a * 2.0;
HALF3 result = color;
result.rgb = ApplyHue(result, hue);
result.rgb = (result - 0.5) * contrast + 0.5 + brightness;
#if defined(SHADERLAB_GLSL)
result.rgb = LERP(vec3(Luminance(result)), result, saturation);
#else
result.rgb = LERP(Luminance(result), result, saturation);
#endif
return result;
}
#endif

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 5bcf2893fead7a14a8c737d1bb6cdd09
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6ed1c7be51e4ffc448c72fc7154ad955
folderAsset: yes
timeCreated: 1590346443
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// Copyright 2014-2017 RenderHeads Ltd. All rights reserved.
//-----------------------------------------------------------------------------
Shader "AVProVideo/Internal/BlendFrames"
{
Properties
{
_MainTex("Before Texture", 2D) = "white" {}
_AfterTex("After Texture", 2D) = "white" {}
_t("t", Float) = 0.5
}
SubShader
{
Pass
{
ZTest Always Cull Off ZWrite Off
Fog{ Mode off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma exclude_renderers flash xbox360 ps3 gles
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _AfterTex;
uniform float _t;
struct v2f
{
float4 pos : POSITION;
float4 uv : TEXCOORD0;
};
v2f vert(appdata_img v)
{
v2f o;
o.uv = float4(0.0, 0.0, 0.0, 0.0);
o.pos = XFormObjectToClip(v.vertex);
o.uv.xy = v.texcoord.xy;
return o;
}
float4 frag(v2f i) : COLOR
{
float4 before = tex2D(_MainTex, i.uv.xy);
float4 after = tex2D(_AfterTex, i.uv.xy);
float4 result = ((1.0 -_t) * before) + (_t * after);
return result;
}
ENDCG
}
}
FallBack Off
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 8ebaafdbf44b0b9489f20bc27374d187
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,65 @@
Shader "AVProVideo/Internal/Blit"
{
Properties
{
_SrcTex("Texture", 2D) = "white" { }
}
SubShader
{
Tags
{
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
}
Lighting Off
Cull Off
ZWrite Off
ZTest Always
Pass
{
Name "BLIT"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
uniform sampler2D _SrcTex;
uniform float4 _SrcTex_ST;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _SrcTex);
return o;
}
half4 frag(v2f i) : SV_Target
{
if (i.uv.x < 0.0f || i.uv.y < 0.0f || i.uv.x > 1.0f || i.uv.y > 1.0f)
return half4(0.0f, 0.0f, 0.0f, 0.0f);
return SampleRGBA(_SrcTex, i.uv);
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cc82d5ef8f3834ab78b36ba88e35ae65
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
Shader "AVProVideo/Internal/IMGUI/Texture Transparent"
{
Properties
{
_MainTex("Texture", any) = "" {}
_ChromaTex("Chroma", any) = "" {}
_VertScale("Vertical Scale", Range(-1, 1)) = 1.0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags { "ForceSupported" = "True" "RenderType" = "Overlay" }
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
ZWrite Off
ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata_t
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float4 uv : TEXCOORD0;
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform float4x4 _MainTex_Xfrm;
uniform float _VertScale;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = XFormObjectToClip(v.vertex);
o.color = v.color;
o.uv.xy = mul(_MainTex_Xfrm, float4(v.texcoord.xy, 0.0, 1.0)).xy;
o.uv.xy = TRANSFORM_TEX(o.uv, _MainTex);
o.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, TRANSFORM_TEX(o.uv, _MainTex), _VertScale < 0.0);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, i.uv.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, i.uv.zw);
#endif
return col * i.color;
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: d1085d25f9ef09b4c91188f9f99f37a2
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,79 @@
Shader "AVProVideo/Internal/Preview"
{
Properties
{
_MainTex("Texture", any) = "" {}
}
SubShader
{
Tags { "ForceSupported" = "True" }
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
Cull Off
ZWrite Off
ZTest Always
Pass
{
Name "ALPHA BLEND"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float2 clipUV : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform sampler2D _MainTex;
uniform sampler2D _GUIClipTexture;
uniform bool _ManualTex2SRGB;
uniform float4 _MainTex_ST;
uniform fixed4 _Color;
uniform float4x4 unity_GUIClipTextureMatrix;
v2f vert (appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
float3 eyePos = UnityObjectToViewPos(v.vertex);
o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
o.color = v.color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 colTex = tex2D(_MainTex, i.texcoord);
if (_ManualTex2SRGB)
colTex.rgb = LinearToGamma(colTex.rgb);
fixed4 col = colTex * i.color;
col.a *= tex2D(_GUIClipTexture, i.clipUV).a;
return col;
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1df272a1da1d6814eb2be42cad7516f2
timeCreated: 1600887843
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,131 @@
Shader "AVProVideo/Internal/Resolve"
{
Properties
{
_MainTex("Texture", any) = "" { }
_ChromaTex("Chroma", any) = "" { }
_Color ("Tint", Color) = (1,1,1,1)
_VertScale("Vertical Scale", Range(-1, 1)) = 1.0
[Toggle(USE_HSBC)] _UseHSBC("Use HSBC", Float) = 0
_Hue("Hue", Range(0, 1.0)) = 0
_Saturation("Saturation", Range(0, 1.0)) = 0.5
_Brightness("Brightness", Range(0, 1.0)) = 0.5
_Contrast("Contrast", Range(0, 1.0)) = 0.5
_InvGamma("InvGamma", Range(0.0001, 10000.0)) = 1.0
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
}
Lighting Off
Cull Off
ZWrite Off
ZTest Always
Pass
{
Name "RESOLVE"
CGPROGRAM
#pragma exclude_renderers gles
#pragma vertex vert
#pragma fragment frag
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ USE_HSBC
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata_t
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float4 uv : TEXCOORD0;
};
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
#if USE_HSBC
uniform fixed _Hue, _Saturation, _Brightness, _Contrast, _InvGamma;
#endif
uniform fixed4 _Color;
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform float4x4 _MainTex_Xfrm;
uniform float _VertScale;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = XFormObjectToClip(v.vertex);
o.color = v.color * _Color;
o.uv.xy = mul(_MainTex_Xfrm, float4(v.texcoord, 0.0f, 1.0f)).xy;
o.uv.wz = 0.0;
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
o.uv.xy *= scaleOffset.xy;
o.uv.xy += scaleOffset.zw;
#endif
// NOTE: this always runs because it's also used to flip vertically
o.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, o.uv.xy, _VertScale < 0.0);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, i.uv.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM || ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, i.uv.zw);
#endif
#if USE_HSBC
col.rgb = ApplyHSBEffect(col.rgb, fixed4(_Hue, _Saturation, _Brightness, _Contrast));
col.rgb = pow(col.rgb, _InvGamma);
#endif
return col * i.color;
}
ENDCG
}
}
Fallback off
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 698a57138fc7d844da1f0cac92fa8e36
timeCreated: 1600887843
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,161 @@
Shader "AVProVideo/Internal/ResolveOES"
{
Properties
{
_MainTex("Texture", any) = "" {}
_ChromaTex("Chroma", any) = "" {}
_Color ("Tint", Color) = (1,1,1,1)
_VertScale("Vertical Scale", Range(-1, 1)) = 1.0
[Toggle(USE_HSBC)] _UseHSBC("Use HSBC", Float) = 0
_Hue("Hue", Range(0, 1.0)) = 0
_Saturation("Saturation", Range(0, 1.0)) = 0.5
_Brightness("Brightness", Range(0, 1.0)) = 0.5
_Contrast("Contrast", Range(0, 1.0)) = 0.5
_InvGamma("InvGamma", Range(0.0001, 10000.0)) = 1.0
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
}
Lighting Off
Cull Off
ZWrite Off
ZTest Always
Pass
{
Name "RESOLVE-OES"
GLSLPROGRAM
#pragma only_renderers gles gles3
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USE_HSBC
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "../AVProVideo.cginc"
#ifdef VERTEX
varying vec4 varTexCoord;
varying vec4 varColor;
uniform vec4 _Color;
uniform vec4 _MainTex_ST;
uniform vec4 _MainTex_TexelSize;
uniform mat4 _MainTex_Xfrm;
uniform float _VertScale;
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
vec2 transformTex(vec4 texCoord, vec4 texST)
{
return (texCoord.xy * texST.xy + texST.zw);
}
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
varColor = gl_Color * _Color;
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
varTexCoord.xy = (_MainTex_Xfrm * vec4(gl_MultiTexCoord0.x, gl_MultiTexCoord0.y, 0.0, 1.0)).xy;
varTexCoord.zw = vec2(0.0, 0.0);
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
varTexCoord.xy *= scaleOffset.xy;
varTexCoord.xy += scaleOffset.zw;
#endif
#if defined (ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
varTexCoord = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, varTexCoord.xy, false);
#if defined(ALPHAPACK_TOP_BOTTOM)
varTexCoord.yw = varTexCoord.wy;
#endif
#endif
}
#endif
#ifdef FRAGMENT
varying vec4 varTexCoord;
varying vec4 varColor;
uniform samplerExternalOES _MainTex;
#if defined(USE_HSBC)
uniform float _Hue, _Saturation, _Brightness, _Contrast, _InvGamma;
#endif
void main()
{
vec4 col = TEX_EXTERNAL(_MainTex, varTexCoord.xy);
#if defined(APPLY_GAMMA)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
vec4 colAlpha = TEX_EXTERNAL(_MainTex, varTexCoord.zw);
col.a = (colAlpha.r + colAlpha.g + colAlpha.b) / 3.0;
#endif
#if defined(USE_HSBC)
col.rgb = ApplyHSBEffect(col.rgb, vec4(_Hue, _Saturation, _Brightness, _Contrast));
col.rgb = pow(col.rgb, vec3(_InvGamma));
#endif
gl_FragColor = col * varColor;
}
#endif
ENDGLSL
}
}
Fallback off
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7f39a07505493c248b3129e08feb50c4
timeCreated: 1600887843
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,180 @@
Shader "AVProVideo/Internal/Transition"
{
Properties
{
_MainTex ("Texture To", 2D) = "white" {}
_FromTex ("Texture From", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile LERP_NONE LERP_FADE LERP_BLACK LERP_WHITE LERP_TRANSP LERP_HORIZ LERP_HORIZ_MIRROR LERP_VERT LERP_VERT_MIRROR LERP_DIAG LERP_DIAG_MIRROR LERP_CIRCLE LERP_SCROLL_VERT LERP_SCROLL_HORIZ LERP_DIAMOND LERP_BLINDS LERP_RECTS_VERT LERP_ARROW LERP_SLIDE_HORIZ LERP_SLIDE_VERT LERP_ZOOM_FADE
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
sampler2D _FromTex;
float4 _MainTex_ST;
float4 _FromTex_ST;
float _Fade;
v2f vert (appdata v)
{
v2f o;
o.vertex = XFormObjectToClip(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float2 uv1 = i.uv;
float2 uv2 = i.uv;
#if LERP_FADE
float t = _Fade;
#elif LERP_BLACK
float t = _Fade;
if (t < 0.5)
{
return lerp(tex2D(_FromTex, uv1), float4(0.0, 0.0, 0.0, 1.0), t * 2.0);
}
else
{
return lerp(float4(0.0, 0.0, 0.0, 1.0), tex2D(_MainTex, uv2), 2.0 * (t - 0.5));
}
#elif LERP_WHITE
float t = _Fade;
if (t < 0.5)
{
return lerp(tex2D(_FromTex, uv1), float4(1.0, 1.0, 1.0, 1.0), t * 2.0);
}
else
{
return lerp(float4(1.0, 1.0, 1.0, 1.0), tex2D(_MainTex, uv2), 2.0 * (t - 0.5));
}
#elif LERP_TRANSP
float t = _Fade;
if (t < 0.5)
{
return lerp(tex2D(_FromTex, uv1), float4(0.0, 0.0, 0.0, 0.0), t * 2.0);
}
else
{
return lerp(float4(0.0, 0.0, 0.0, 0.0), tex2D(_MainTex, uv2), 2.0 * (t - 0.5));
}
#elif LERP_HORIZ
float t = step(i.uv.x, _Fade);
#elif LERP_HORIZ_MIRROR
float t = step(abs(i.uv.x - 0.5), _Fade);
#elif LERP_VERT
float t = step(i.uv.y, _Fade);
#elif LERP_VERT_MIRROR
float t = step(abs(i.uv.y - 0.5), _Fade);
#elif LERP_DIAG
float t = step((i.uv.y+i.uv.x)*0.5, _Fade);
#elif LERP_DIAG_MIRROR
float t = step(abs(i.uv.y - i.uv.x), _Fade);
#elif LERP_CIRCLE
float t = distance(float2(i.uv.x*1.777, i.uv.y), float2(0.5*1.7777, 0.5));
t = step(t, _Fade*2.1);
#elif LERP_SCROLL_VERT
float t = _Fade;
uv1.y += _Fade;
t = step(1 - uv1.y, 0);
#elif LERP_SCROLL_HORIZ
float t = _Fade;
uv1.x += _Fade;
t = step(1 - uv1.x, 0);
#elif LERP_DIAMOND
float2 origin = float2(0.5 * 1.7777, 0.5);
float t = abs(uv1.x*1.7777 - origin.x);
t += abs(uv1.y - origin.y);
t = step(t, _Fade*1.4);
#elif LERP_BLINDS
float x = frac(uv1.x*4.0);
float t = step(x, _Fade);
#elif LERP_ARROW
// Arrow
float y = abs(i.uv.y - 0.5) * 0.5;
float x = lerp(0.5, 1.0, i.uv.x);
float t = step(x, y + _Fade);
#elif LERP_SLIDE_HORIZ
// Slide horiz
float t = _Fade;
uv1.x += _Fade;
uv2.x -= 1.0 - _Fade;
t = step(1 - uv1.x, 0);
#elif LERP_SLIDE_VERT
// slide vert
float t = _Fade;
uv1.y += _Fade;
uv2.y -= 1.0 - _Fade;
t = step(1 - uv1.y, 0);
#elif LERP_ZOOM_FADE
// zoom-fade
float scale = lerp(1.0, 0.15, _Fade);
float scale2 = lerp(1.0, 0.15, 1.0-_Fade);
uv1 -= 0.5;
uv2 -= 0.5;
uv1 *= scale;
uv2 *= scale2;
uv1 += 0.5;
uv2 += 0.5;
float t = smoothstep(0.5, 1.0, _Fade);
#elif LERP_RECTS_VERT
float x = uv1.x;
float bf = _Fade / 1.5;
bf = frac(uv1.y * 8.0);
bf = (int)fmod(uv1.y * 8.0, 8.0);
bf += 1.0;
bf *= _Fade / 2.0;
float t = step(abs(x - 0.5), bf);
#endif
#if LERP_NONE
return tex2D(_MainTex, uv1);
#else
float4 cola = tex2D(_FromTex, uv1);
float4 colb = tex2D(_MainTex, uv2);
float4 col = lerp(cola, colb, t);
return col;
#endif
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 73f378cafe7b4a745907b70e76bb3259
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,170 @@
Shader "AVProVideo/Internal/UI/Stereo - AndroidOES"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "black" { }
[PerRendererData] _ChromaTex("Sprite Texture", 2D) = "gray" { }
_Color("Tint", Color) = (1,1,1,1)
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_ColorMask("Color Mask", Float) = 15
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
"CanUseSpriteAtlas" = "True"
}
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest[unity_GUIZTestMode]
Fog{ Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask[_ColorMask]
Pass
{
GLSLPROGRAM
#pragma only_renderers gles3
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
precision mediump float;
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "../AVProVideo.cginc"
#ifdef VERTEX
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
out vec2 texVal;
uniform vec4 _MainTex_ST;
uniform mat4 _MainTex_Xfrm;
#if defined(STEREO_DEBUG)
out vec4 tint;
#endif
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal.xy = (_MainTex_Xfrm * vec4(gl_MultiTexCoord0.x, gl_MultiTexCoord0.y, 0.0, 1.0)).xy;
texVal.xy = TRANSFORM_TEX_ST(texVal, _MainTex_ST);
#if defined(STEREO_TOP_BOTTOM) | defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset(Android_IsStereoEyeLeft(), false);
texVal.xy *= scaleOffset.xy;
texVal.xy += scaleOffset.zw;
#elif defined (STEREO_CUSTOM_UV)
if (!Android_IsStereoEyeLeft())
{
texVal = gl_MultiTexCoord1.xy;
texVal = vec2(1.0, 1.0) - texVal;
}
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint(Android_IsStereoEyeLeft());
#endif
}
#endif // VERTEX
#ifdef FRAGMENT
in vec2 texVal;
#if defined(STEREO_DEBUG)
in vec4 tint;
#endif
uniform vec4 _Color;
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
void main()
{
vec4 col = texture(_MainTex, texVal.xy);
#if defined(APPLY_GAMMA)
col.rgb = GammaToLinear(col.rgb);
#endif
col *= _Color;
#if defined(STEREO_DEBUG)
col *= tint;
#endif
gl_FragColor = col;
}
#endif // FRAGMENT
ENDGLSL
}
}
Fallback "AVProVideo/Internal/UI/Stereo"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f9f51999155859b419ff715c8127688a
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,176 @@
Shader "AVProVideo/Internal/UI/Stereo"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" { }
[PerRendererData] _ChromaTex ("Sprite Texture", 2D) = "white" { }
_Color ("Tint", Color) = (1, 1, 1, 1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[KeywordEnum(None, Top_Bottom, Left_Right, Two_Textures)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_TWO_TEXTURES
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ USE_YPCBCR
#include "UnityCG.cginc"
#include "../AVProVideo.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_INPUT_INSTANCE_ID
#endif
};
struct v2f
{
float4 vertex : SV_POSITION;
half4 color : COLOR;
half2 texcoord : TEXCOORD0;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_VERTEX_OUTPUT_STEREO
#endif
};
uniform half4 _Color;
uniform sampler2D _MainTex;
#if STEREO_TWO_TEXTURES
uniform sampler2D _MainTex_R;
#endif
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
#if STEREO_TWO_TEXTURES
uniform sampler2D _ChromaTex_R;
#endif
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_ST;
uniform float4 _MainTex_TexelSize;
uniform float4x4 _MainTex_Xfrm;
v2f vert(appdata_t i)
{
v2f o;
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_INSTANCE_ID(i);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
#endif
o.vertex = XFormObjectToClip(i.vertex);
#if UNITY_HALF_TEXEL_OFFSET
o.vertex.xy += (_ScreenParams.zw - 1.0) * float2(-1.0, 1.0);
#endif
o.texcoord.xy = mul(_MainTex_Xfrm, float4(i.texcoord.xy, 0.0, 1.0)).xy;
o.texcoord.xy = TRANSFORM_TEX(o.texcoord.xy, _MainTex);
#if STEREO_TOP_BOTTOM || STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_ST.y < 0.0);
o.texcoord.xy *= scaleOffset.xy;
o.texcoord.xy += scaleOffset.zw;
#endif
o.color = i.color * _Color;
#if STEREO_DEBUG
o.color *= GetStereoDebugTint(IsStereoEyeLeft());
#endif
return o;
}
inline half4 sampleTextureForEye(float2 uv, bool rightEye)
{
#if STEREO_TWO_TEXTURES
if (rightEye)
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex_R, _ChromaTex_R, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex_R, uv);
#endif
}
else
#endif
{
#if USE_YPCBCR
return SampleYpCbCr(_MainTex, _ChromaTex, uv, _YpCbCrTransform);
#else
return SampleRGBA(_MainTex, uv);
#endif
}
}
half4 frag(v2f i) : SV_Target
{
#ifdef UNITY_STEREO_INSTANCING_ENABLED
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#endif
half4 col = sampleTextureForEye(i.texcoord, IsStereoEyeRight());
col *= i.color;
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 018fe741dec71f14bb43801a31a07303
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,187 @@
Shader "AVProVideo/Internal/UI/Transparent Packed (stereo) - AndroidOES"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "black" { }
[PerRendererData] _ChromaTex ("Sprite Texture", 2D) = "gray" { }
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
_VertScale("Vertical Scale", Range(-1, 1)) = 1.0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
GLSLPROGRAM
#pragma only_renderers gles3
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ USE_YPCBCR
#pragma multi_compile __ USING_DEFAULT_TEXTURE
#pragma multi_compile __ USING_URP
#extension GL_OES_EGL_image_external : require
#extension GL_OES_EGL_image_external_essl3 : enable
#include "UnityCG.glslinc"
#if defined(STEREO_MULTIVIEW_ON)
UNITY_SETUP_STEREO_RENDERING
#endif
#define SHADERLAB_GLSL
#include "../AVProVideo.cginc"
#ifdef VERTEX
INLINE bool Android_IsStereoEyeLeft()
{
#if defined(FORCEEYE_LEFT)
return true;
#elif defined(FORCEEYE_RIGHT)
return false;
#elif defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
return (eyeIndex == 0);
#else
return IsStereoEyeLeft();
#endif
}
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
out vec4 texVal;
#else
out vec2 texVal;
#endif
#if defined(STEREO_DEBUG)
out vec4 tint;
#endif
uniform vec4 _MainTex_ST;
uniform vec4 _MainTex_TexelSize;
uniform mat4 _MainTex_Xfrm;
void main()
{
#if defined(STEREO_MULTIVIEW_ON)
int eyeIndex = SetupStereoEyeIndex();
mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
gl_Position = vpMatrix * unity_ObjectToWorld * gl_Vertex;
#else
gl_Position = XFormObjectToClip(gl_Vertex);
#endif
// Apply texture transformation matrix - adjusts for offset/cropping (when the decoder decodes in blocks that overrun the video frame size, it pads)
texVal.xy = (_MainTex_Xfrm * vec4(gl_MultiTexCoord0.x, gl_MultiTexCoord0.y, 0.0, 1.0)).xy;
texVal.xy = TRANSFORM_TEX_ST(texVal, _MainTex_ST);
#if defined(STEREO_TOP_BOTTOM) || defined(STEREO_LEFT_RIGHT)
vec4 scaleOffset = GetStereoScaleOffset( Android_IsStereoEyeLeft(), _MainTex_ST.y < 0.0 );
texVal.xy *= scaleOffset.xy;
texVal.xy += scaleOffset.zw;
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
texVal = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, texVal.xy, _MainTex_ST.y < 0.0);
#if defined(ALPHAPACK_TOP_BOTTOM)
texVal.yw = texVal.wy;
#endif
#endif
#if defined(STEREO_DEBUG)
tint = GetStereoDebugTint( Android_IsStereoEyeLeft() );
#endif
}
#endif // VERTEX
#ifdef FRAGMENT
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
in vec4 texVal;
#else
in vec2 texVal;
#endif
#if defined(STEREO_DEBUG)
in vec4 tint;
#endif
#if defined(USING_DEFAULT_TEXTURE)
uniform sampler2D _MainTex;
#else
uniform samplerExternalOES _MainTex;
#endif
void main()
{
vec4 col = texture(_MainTex, texVal.xy);
#if defined(APPLY_GAMMA)
col.rgb = GammaToLinear(col.rgb);
#endif
#if defined(ALPHAPACK_TOP_BOTTOM) || defined(ALPHAPACK_LEFT_RIGHT)
vec3 rgb = texture(_MainTex, texVal.zw).rgb;
col.a = (rgb.r + rgb.g + rgb.b) / 3.0;
#endif
#if defined(STEREO_DEBUG)
col *= tint;
#endif
gl_FragColor = col;
}
#endif // FRAGMENT
ENDGLSL
}
}
Fallback "AVProVideo/Internal/UI/Transparent Packed (stereo)"
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f35019bbb2560394aac63e40e1d98da7
ShaderImporter:
defaultTextures: []
userData:

View File

@@ -0,0 +1,171 @@
Shader "AVProVideo/Internal/UI/Transparent Packed (stereo)"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
[PerRendererData] _ChromaTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
_VertScale("Vertical Scale", Range(-1, 1)) = 1.0
[KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
[KeywordEnum(None, Top_Bottom, Left_Right)] Stereo("Stereo Mode", Float) = 0
[KeywordEnum(None, Left, Right)] ForceEye ("Force Eye Mode", Float) = 0
[Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
#pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
#pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT
#pragma multi_compile FORCEEYE_NONE FORCEEYE_LEFT FORCEEYE_RIGHT
#pragma multi_compile __ APPLY_GAMMA
#pragma multi_compile __ STEREO_DEBUG
#pragma multi_compile __ USE_YPCBCR
#if APPLY_GAMMA
//#pragma target 3.0
#endif
#include "UnityCG.cginc"
// TODO: once we drop support for Unity 4.x then we can include this
//#include "UnityUI.cginc"
#include "../AVProVideo.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half4 uv : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform fixed4 _Color;
uniform sampler2D _MainTex;
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
uniform float4 _MainTex_TexelSize;
uniform float _VertScale;
uniform float4 _ClipRect;
inline float UnityGet2DClipping (in float2 position, in float4 clipRect)
{
float2 inside = step(clipRect.xy, position.xy) * step(position.xy, clipRect.zw);
return inside.x * inside.y;
}
v2f vert(appdata_t IN)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(IN);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.worldPosition = IN.vertex;
OUT.vertex = XFormObjectToClip(IN.vertex);
#ifdef UNITY_HALF_TEXEL_OFFSET
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
#endif
OUT.uv.xy = IN.texcoord.xy;
// Horrible hack to undo the scale transform to fit into our UV packing layout logic...
if (_VertScale < 0.0)
{
OUT.uv.y = 1.0 - OUT.uv.y;
}
#if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), _MainTex_TexelSize.y < 0.0);
OUT.uv.xy *= scaleOffset.xy;
OUT.uv.xy += scaleOffset.zw;
#endif
OUT.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, OUT.uv.xy, _VertScale < 0.0);
OUT.color = IN.color * _Color;
#if STEREO_DEBUG
OUT.color *= GetStereoDebugTint(IsStereoEyeLeft());
#endif
return OUT;
}
half4 frag(v2f i) : SV_Target
{
half4 col;
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
#else
col = SampleRGBA(_MainTex, i.uv.xy);
#endif
#if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
col.a = SamplePackedAlpha(_MainTex, i.uv.zw);
#endif
col *= i.color;
col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
clip(col.a - 0.001);
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f32079bbb2560394abb63e40e1d53da7
ShaderImporter:
defaultTextures: []
userData: