From dce1e045e2dcd3e5e32b9b35bb71346cd22bbaed Mon Sep 17 00:00:00 2001 From: Andrew Richards Date: Thu, 12 Dec 2024 15:45:37 +0000 Subject: [PATCH] Reworked BOTTOM_UP_TEXTURE_COORDINATES functions. --- CrossPlatform/Shaders/common.sl | 26 ++++++++++++++++++++------ DirectX11/Sfx/shader_platform.sl | 7 ++++--- DirectX12/Sfx/shader_platform.sl | 15 ++++----------- Vulkan/Sfx/shader_platform.sl | 12 ++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CrossPlatform/Shaders/common.sl b/CrossPlatform/Shaders/common.sl index c2957a42..d09ceb3b 100644 --- a/CrossPlatform/Shaders/common.sl +++ b/CrossPlatform/Shaders/common.sl @@ -48,15 +48,29 @@ #define sample_3d_lod(tex,sampler,texc,lod) tex.SampleLevel(sampler,texc,lod) #ifndef __cplusplus - vec2 ReverseYTextureCoordinates(vec2 texc) + + #ifndef BOTTOM_UP_TEXTURE_COORDINATES + #define BOTTOM_UP_TEXTURE_COORDINATES 0 + #endif + + #if BOTTOM_UP_TEXTURE_COORDINATES + vec2 BottomUpTextureCoordinates(vec2 texc) { return vec2(texc.x, 1.0 - texc.y); } - - #ifndef BOTTOM_UP_TEXTURE_COORDINATES_DEFINED - #define BottomUpTextureCoordinates(original_texc) original_texc - #define BottomUpTextureCoordinates4(original_texc) original_texc - #define BOTTOM_UP_TEXTURE_COORDINATES_DEFINED 1 + vec4 BottomUpTextureCoordinates4(vec4 texc) + { + return vec4(texc.x, 1.0 - texc.y, texc.z, 1.0 - texc.w); + } + #else + vec2 BottomUpTextureCoordinates(vec2 texc) + { + return texc; + } + vec4 BottomUpTextureCoordinates4(vec4 texc) + { + return texc; + } #endif #define ALIGN_16 diff --git a/DirectX11/Sfx/shader_platform.sl b/DirectX11/Sfx/shader_platform.sl index 440ca2a5..f4f3b396 100644 --- a/DirectX11/Sfx/shader_platform.sl +++ b/DirectX11/Sfx/shader_platform.sl @@ -42,10 +42,11 @@ #define layout(a) #define SIMUL_RENDERTARGET_OUTPUT_DSB_INDEX_0(n) : SV_TARGET0 #define SIMUL_RENDERTARGET_OUTPUT_DSB_INDEX_1(n) : SV_TARGET1 - #define BottomUpTextureCoordinates4(texc) vec4(texc.x,1.0-texc.y,texc.z,1.0-texc.w) - #define BottomUpTextureCoordinates(texc) vec2(texc.x,1.0-texc.y) + + #ifndef BOTTOM_UP_TEXTURE_COORDINATES + #define BOTTOM_UP_TEXTURE_COORDINATES 1 + #endif #endif -#define BOTTOM_UP_TEXTURE_COORDINATES_DEFINED 1 #endif \ No newline at end of file diff --git a/DirectX12/Sfx/shader_platform.sl b/DirectX12/Sfx/shader_platform.sl index 3e8c539a..eaee2b2b 100644 --- a/DirectX12/Sfx/shader_platform.sl +++ b/DirectX12/Sfx/shader_platform.sl @@ -23,17 +23,10 @@ #define SIMUL_RENDERTARGET_OUTPUT_DSB_INDEX_0(n) : SV_TARGET0 #define SIMUL_RENDERTARGET_OUTPUT_DSB_INDEX_1(n) : SV_TARGET1 -#ifndef BOTTOM_UP_TEXTURE_COORDINATES_DEFINED - vec2 BottomUpTextureCoordinates(vec2 texc) - { - return vec2(texc.x,1.0-texc.y); - } - vec4 BottomUpTextureCoordinates4(vec4 texc) - { - return vec4(texc.x,1.0-texc.y,texc.z,1.0-texc.w); - } - #define BOTTOM_UP_TEXTURE_COORDINATES_DEFINED 1 -#endif + #ifndef BOTTOM_UP_TEXTURE_COORDINATES + #define BOTTOM_UP_TEXTURE_COORDINATES 1 + #endif + #endif #endif diff --git a/Vulkan/Sfx/shader_platform.sl b/Vulkan/Sfx/shader_platform.sl index ed289417..729d396b 100644 --- a/Vulkan/Sfx/shader_platform.sl +++ b/Vulkan/Sfx/shader_platform.sl @@ -5,16 +5,8 @@ #ifndef __cplusplus -#ifdef XBOTTOM_UP_TEXTURE_COORDINATES_DEFINED - vec2 BottomUpTextureCoordinates(vec2 texc) - { - return vec2(texc.x,1.0-texc.y); - } - vec4 BottomUpTextureCoordinates4(vec4 texc) - { - return vec4(texc.x,1.0-texc.y,texc.z,1.0-texc.w); - } - #define BOTTOM_UP_TEXTURE_COORDINATES_DEFINED 1 +#ifndef BOTTOM_UP_TEXTURE_COORDINATES +#define BOTTOM_UP_TEXTURE_COORDINATES 1 #endif #define USE_D3D_REF_MODE 0