From 2b7ae2e2a8390a836b6c4107032a5326739b9fe5 Mon Sep 17 00:00:00 2001 From: Merlin Date: Mon, 31 Oct 2022 02:55:18 -0700 Subject: [PATCH] Fix flipped Y UV on quest in AVPro player --- .../Shaders/CRTRenderTextureProcessor.shader | 9 ++++++++- Assets/USharpVideo/Shaders/StandardVideoCore.cginc | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Assets/USharpVideo/Shaders/CRTRenderTextureProcessor.shader b/Assets/USharpVideo/Shaders/CRTRenderTextureProcessor.shader index 26f841f..3e04187 100644 --- a/Assets/USharpVideo/Shaders/CRTRenderTextureProcessor.shader +++ b/Assets/USharpVideo/Shaders/CRTRenderTextureProcessor.shader @@ -63,7 +63,14 @@ if (any(uv <= 0) || any(uv >= 1)) return float3(0, 0, 0); - float3 texColor = tex2D(_SourceTexture, _IsAVPro ? float2(uv.x, 1 - uv.y) : uv).rgb; + #if UNITY_UV_STARTS_AT_TOP + if (_IsAVPro) + { + uv = float2(uv.x, 1 - uv.y); + } + #endif + + float3 texColor = tex2D(_SourceTexture, uv).rgb; if (_IsAVPro) texColor = pow(texColor, 2.2f); diff --git a/Assets/USharpVideo/Shaders/StandardVideoCore.cginc b/Assets/USharpVideo/Shaders/StandardVideoCore.cginc index 3401859..118e626 100644 --- a/Assets/USharpVideo/Shaders/StandardVideoCore.cginc +++ b/Assets/USharpVideo/Shaders/StandardVideoCore.cginc @@ -55,10 +55,19 @@ half3 VideoEmission(float2 uv) // return float3(0, 0, 0); } - float3 texColor = tex2D(_EmissionMap, _IsAVProInput ? float2(uv.x, 1 - uv.y) : uv).rgb; + #if UNITY_UV_STARTS_AT_TOP + if (_IsAVProInput) + { + uv = float2(uv.x, 1 - uv.y); + } + #endif + + float3 texColor = tex2D(_EmissionMap, uv).rgb; if (_IsAVProInput) + { texColor = pow(texColor, 2.2f); + } return texColor * _EmissionColor.rgb * visibility; #endif