From a2146839d7dc46a54923e9e706817db53404acff Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Tue, 14 Oct 2025 12:04:40 +0200 Subject: [PATCH] EEVEE: Unify float2 implicit conversion with other parts of Blender This patch adjusts the implicit conversion rules involving float2 to match other parts of Blender, like BKE Conversions, Geometry Nodes, and the Compositor. The new rules also make much more sense to me on their own. The GPU_VEC2 is no currently used for GPU materials as far as I can see, so this should not be a breaking change. Pull Request: https://projects.blender.org/blender/blender/pulls/148033 --- source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl index f7068cdc00b..8961b4296fb 100644 --- a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl @@ -36,18 +36,18 @@ float2 calc_barycentric_co(int vertid) /* Assumes GPU_VEC4 is color data, special case that needs luminance coefficients from OCIO. */ #define float_from_vec4(v, luminance_coefficients) dot(v.rgb, luminance_coefficients) #define float_from_vec3(v) ((v.r + v.g + v.b) * (1.0f / 3.0f)) -#define float_from_vec2(v) v.r +#define float_from_vec2(v) ((v.x + v.y) * (1.0f / 2.0f)) -#define vec2_from_vec4(v) float2(((v.r + v.g + v.b) * (1.0f / 3.0f)), v.a) -#define vec2_from_vec3(v) float2(((v.r + v.g + v.b) * (1.0f / 3.0f)), 1.0f) +#define vec2_from_vec4(v) v.xy +#define vec2_from_vec3(v) v.xy #define vec2_from_float(v) float2(v) #define vec3_from_vec4(v) v.rgb -#define vec3_from_vec2(v) v.rrr +#define vec3_from_vec2(v) float3(v.xy, 0.0f) #define vec3_from_float(v) float3(v) #define vec4_from_vec3(v) float4(v, 1.0f) -#define vec4_from_vec2(v) v.rrrg +#define vec4_from_vec2(v) float4(v.xy, 0.0f, 1.0f) #define vec4_from_float(v) float4(float3(v), 1.0f) /* TODO: Move to shader_shared. */