From 1066f01607468a002d62bce989dca73ead3544eb Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Mon, 22 Jan 2024 13:53:38 +1100 Subject: [PATCH] Add ivec variants to multiview_uv for stereo rendering --- drivers/gles3/shaders/scene.glsl | 6 ++++++ .../forward_clustered/scene_forward_clustered.glsl | 12 ++++++++++++ .../shaders/forward_mobile/scene_forward_mobile.glsl | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index e95d684763d..6e282283704 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -867,12 +867,18 @@ uniform highp sampler2DArray color_buffer; // texunit:-5 vec3 multiview_uv(vec2 uv) { return vec3(uv, ViewIndex); } +ivec3 multiview_uv(ivec2 uv) { + return ivec3(uv, int(ViewIndex)); +} #else uniform highp sampler2D depth_buffer; // texunit:-6 uniform highp sampler2D color_buffer; // texunit:-5 vec2 multiview_uv(vec2 uv) { return uv; } +ivec2 multiview_uv(ivec2 uv) { + return uv; +} #endif uniform highp mat4 world_transform; diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl index 930d9814942..cb95621219c 100644 --- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl @@ -140,6 +140,9 @@ layout(location = 10) out flat uint instance_index_interp; vec3 multiview_uv(vec2 uv) { return vec3(uv, ViewIndex); } +ivec3 multiview_uv(ivec2 uv) { + return ivec3(uv, int(ViewIndex)); +} layout(location = 11) out vec4 combined_projected; #else // USE_MULTIVIEW // Set to zero, not supported in non stereo @@ -147,6 +150,9 @@ layout(location = 11) out vec4 combined_projected; vec2 multiview_uv(vec2 uv) { return uv; } +ivec2 multiview_uv(ivec2 uv) { + return uv; +} #endif //USE_MULTIVIEW invariant gl_Position; @@ -704,6 +710,9 @@ layout(location = 10) in flat uint instance_index_interp; vec3 multiview_uv(vec2 uv) { return vec3(uv, ViewIndex); } +ivec3 multiview_uv(ivec2 uv) { + return ivec3(uv, int(ViewIndex)); +} layout(location = 11) in vec4 combined_projected; #else // USE_MULTIVIEW // Set to zero, not supported in non stereo @@ -711,6 +720,9 @@ layout(location = 11) in vec4 combined_projected; vec2 multiview_uv(vec2 uv) { return uv; } +ivec2 multiview_uv(ivec2 uv) { + return uv; +} #endif //USE_MULTIVIEW //defines to keep compatibility with vertex diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl index 03737e087cb..e9c69058f2a 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl @@ -125,12 +125,18 @@ layout(location = 9) out highp float dp_clip; vec3 multiview_uv(vec2 uv) { return vec3(uv, ViewIndex); } +ivec3 multiview_uv(ivec2 uv) { + return ivec3(uv, int(ViewIndex)); +} #else // Set to zero, not supported in non stereo #define ViewIndex 0 vec2 multiview_uv(vec2 uv) { return uv; } +ivec2 multiview_uv(ivec2 uv) { + return uv; +} #endif //USE_MULTIVIEW invariant gl_Position; @@ -568,12 +574,18 @@ layout(location = 9) highp in float dp_clip; vec3 multiview_uv(vec2 uv) { return vec3(uv, ViewIndex); } +ivec3 multiview_uv(ivec2 uv) { + return ivec3(uv, int(ViewIndex)); +} #else // Set to zero, not supported in non stereo #define ViewIndex 0 vec2 multiview_uv(vec2 uv) { return uv; } +ivec2 multiview_uv(ivec2 uv) { + return uv; +} #endif //USE_MULTIVIEW //defines to keep compatibility with vertex