Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleGeometryHelper creates one particle per subgeometry. #51

Closed
player-03 opened this issue Apr 22, 2023 · 2 comments
Closed

ParticleGeometryHelper creates one particle per subgeometry. #51

player-03 opened this issue Apr 22, 2023 · 2 comments

Comments

@player-03
Copy link
Contributor

Away3D was never particularly well-documented, so perhaps this shouldn't be a surprise. Documentation on particles seems to be limited to one article that doesn't even mention subgeometries.

The first thing we need for particles is a set of geometries. Each element of this set will represent a particle. You can use any geometry in the set; a built-in geometry primitive provided by Away3D or an external geometry loaded from a file.

This seems to indicate that each Geometry corresponds to a single particle, but ParticleGeometryHelper instead creates a new particle per subgeometry. This isn't intuitive as a user, and it also makes ParticleGeometryHelper that much more complicated.

@player-03
Copy link
Contributor Author

Oh, I missed that multiple ParticleData instances can have the same particleIndex, so it's all still one particle. I'll have to dig deeper.

@player-03
Copy link
Contributor Author

player-03 commented Apr 22, 2023

The reason for this subdivision is mainly so multiple materials can be used within a single Mesh.

So the reason to preserve a particle's subgeometries is to allow you to set multiple materials later on. Interesting.

Edit:

When drawing objects, the gpu needs to be told to use a different program every time for every material. Unfortunately, this switch is typically very expensive and something you’d want to prevent as much as possible. To this end, Away3D sorts all the objects that need to be rendered (the so called “renderables”) primarily according to their materials so all objects with the same material will be rendered consecutively. If you’re using different material instances for things that look exactly the same, it means more programs need to be switched needlessly.

Maybe ParticleGeometryHelper should sort the subgeometries it creates, so Away3D doesn't have to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant