Skip to content

Commit 6229c2a

Browse files
committed
Translate inactive particles to -INF
1 parent 5860b02 commit 6229c2a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

drivers/gles3/shaders/particles_copy.glsl

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ uniform highp mat4 inv_emission_transform;
4444

4545
#define PARTICLE_FLAG_ACTIVE uint(1)
4646

47+
#define FLT_MAX float(3.402823466e+38)
48+
4749
void main() {
48-
mat4 txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); // zero scale, becomes invisible.
50+
// Set scale to zero and translate to -INF so particle will be invisible
51+
// even for materials that ignore rotation/scale (i.e. billboards).
52+
mat4 txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(-FLT_MAX, -FLT_MAX, -FLT_MAX, 0.0));
4953
if (bool(floatBitsToUint(velocity_flags.w) & PARTICLE_FLAG_ACTIVE)) {
5054
#ifdef MODE_3D
5155
txform = transpose(mat4(xform_1, xform_2, xform_3, vec4(0.0, 0.0, 0.0, 1.0)));
@@ -102,9 +106,8 @@ void main() {
102106
// as they will be drawn with the node position as origin.
103107
txform = inv_emission_transform * txform;
104108
#endif
105-
106-
txform = transpose(txform);
107109
}
110+
txform = transpose(txform);
108111

109112
instance_color_custom_data = uvec4(packHalf2x16(color.xy), packHalf2x16(color.zw), packHalf2x16(custom.xy), packHalf2x16(custom.zw));
110113
out_xform_1 = txform[0];

servers/rendering/renderer_rd/shaders/particles_copy.glsl

+4-3
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,12 @@ void main() {
206206
// as they will be drawn with the node position as origin.
207207
txform = params.inv_emission_transform * txform;
208208
}
209-
210-
txform = transpose(txform);
211209
} else {
212-
txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); //zero scale, becomes invisible
210+
// Set scale to zero and translate to -INF so particle will be invisible
211+
// even for materials that ignore rotation/scale (i.e. billboards).
212+
txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(-1.0 / 0.0, -1.0 / 0.0, -1.0 / 0.0, 0.0));
213213
}
214+
txform = transpose(txform);
214215

215216
if (params.copy_mode_2d) {
216217
uint write_offset = gl_GlobalInvocationID.x * (2 + 1 + 1); //xform + color + custom

0 commit comments

Comments
 (0)