Three.js: GPUParticleSystem.js color option bug and memory leak

Created on 9 Apr 2017  路  13Comments  路  Source: mrdoob/three.js

There are two problems in GPUParticleSystem.js:

1) spawnParticle method color option is not work as a valid rgb color. There is an error in sending a color to the shader.
2) The dispose method is missing. Therefore, a GPUParticleSystem memory is not cleared.
The dispose method should contain:

self.particleShaderMat.dispose();
self.particleShaderGeo.dispose();
Bug

All 13 comments

  1. spawnParticle method color option is not work as a valid rgb color. There is an error in sending a color to the shader.

Right now the color option needs to be defined as hexadecimal numbers like this. How do you pass the color value so it's producing an error?

options = { color: 0xff0000 }

In example https://threejs.org/examples/#webgl_gpu_particle_system color option is equal 0xaa88ff.
I see green color, but rgb #aa88ff is purple.

Oh, that's strange indeed! I'm getting this:

image

There is an error in sending a color to the shader.

Can you post this error message please? Maybe there is an issue with your graphics card/driver.

I see the correct color, too (Chrome, FF, Edge; Windows 10)

@vorkulsky I've added a dispose method that regards the internal material, geometries and textures. The mentioned color problem is still an open issue. Maybe there is a problem wit the float <-> vector4 encoding/decoding on your machine.

1
Chrome, FF, Edge; Windows 10, Intel hd graphics 4000
@Mugen87 No error in the form of a message, there is an error in the form of incorrect behavior only.

This seems to be a similar issue: https://github.com/mrdoob/three.js/issues/7804

One option to solve this problem: We avoid the whole float/vector4 encoding stuff and use a single shader attribute for each property. This would also make the code more simple.

I just saw: On my (very low end) laptop (intel hd) the example is displayed in a nice green color, too.

@jostschmithals @vorkulsky Can you please test if this version of GPUParticleSystem renders the colors correctly on your devices?

GPUParticleSystem.js.zip

@Mugen87 Using your test code the color is purple on the prehistoric device that displayed green before.

Good to hear that! It actually looks like that the float/vector4 encoding is problematic on older devices. As mentioned in this comment the floating point precision probably causes this issue. I'll update the PR with the latest code.

Fixed with #11151.

Was this page helpful?
0 / 5 - 0 ratings