Skip to content

Commit

Permalink
Merge pull request #89094 from permelin/fix-particle-userdata-gles3
Browse files Browse the repository at this point in the history
Fix `USERDATA` built-ins for GLES3 particle shaders
  • Loading branch information
akien-mga committed Mar 8, 2024
2 parents cebaf9d + 24b58c6 commit 1186d4a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
30 changes: 24 additions & 6 deletions drivers/gles3/shaders/particles.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions drivers/gles3/storage/particles_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1186d4a

Please sign in to comment.