Fix USERDATA built-ins for GLES3 particle shaders

This commit is contained in:
Per Melin 2024-03-02 18:39:24 +01:00
parent f2045ba822
commit 24b58c655a
2 changed files with 28 additions and 8 deletions

View file

@ -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

View file

@ -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) {