From 24b58c655a28cb545f51eefd498dfb9493baca1e Mon Sep 17 00:00:00 2001 From: Per Melin Date: Sat, 2 Mar 2024 18:39:24 +0100 Subject: [PATCH] Fix USERDATA built-ins for GLES3 particle shaders --- drivers/gles3/shaders/particles.glsl | 30 ++++++++++++++++----- drivers/gles3/storage/particles_storage.cpp | 6 +++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/gles3/shaders/particles.glsl b/drivers/gles3/shaders/particles.glsl index 64ef26b0756..d95f7f43099 100644 --- a/drivers/gles3/shaders/particles.glsl +++ b/drivers/gles3/shaders/particles.glsl @@ -112,22 +112,22 @@ layout(location = 4) in highp vec4 xform_2; layout(location = 5) in highp vec4 xform_3; #endif #ifdef USERDATA1_USED -layout(location = 6) in highp vec4 userdata1; +in highp vec4 userdata1; #endif #ifdef USERDATA2_USED -layout(location = 7) in highp vec4 userdata2; +in highp vec4 userdata2; #endif #ifdef USERDATA3_USED -layout(location = 8) in highp vec4 userdata3; +in highp vec4 userdata3; #endif #ifdef USERDATA4_USED -layout(location = 9) in highp vec4 userdata4; +in highp vec4 userdata4; #endif #ifdef USERDATA5_USED -layout(location = 10) in highp vec4 userdata5; +in highp vec4 userdata5; #endif #ifdef USERDATA6_USED -layout(location = 11) in highp vec4 userdata6; +in highp vec4 userdata6; #endif out highp vec4 out_color; //tfb: @@ -219,6 +219,24 @@ void main() { #endif xform = transpose(xform); flags = floatBitsToUint(velocity_flags.w); +#ifdef USERDATA1_USED + out_userdata1 = userdata1; +#endif +#ifdef USERDATA2_USED + out_userdata2 = userdata2; +#endif +#ifdef USERDATA3_USED + out_userdata3 = userdata3; +#endif +#ifdef USERDATA4_USED + out_userdata4 = userdata4; +#endif +#ifdef USERDATA5_USED + out_userdata5 = userdata5; +#endif +#ifdef USERDATA6_USED + out_userdata6 = userdata6; +#endif } //clear started flag if set diff --git a/drivers/gles3/storage/particles_storage.cpp b/drivers/gles3/storage/particles_storage.cpp index c5a97bdbd51..8e48d0695ae 100644 --- a/drivers/gles3/storage/particles_storage.cpp +++ b/drivers/gles3/storage/particles_storage.cpp @@ -728,8 +728,10 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta ParticlesShaderGLES3::ShaderVariant variant = ParticlesShaderGLES3::MODE_DEFAULT; uint32_t specialization = 0; - for (uint32_t i = 0; i < p_particles->userdata_count; i++) { - specialization |= (1 << i); + for (uint32_t i = 0; i < PARTICLES_MAX_USERDATAS; i++) { + if (m->shader_data->userdatas_used[i]) { + specialization |= ParticlesShaderGLES3::USERDATA1_USED << i; + } } if (p_particles->mode == RS::ParticlesMode::PARTICLES_MODE_3D) {