tModLoader

tModLoader

Particle Library
Showing 1-10 of 30 entries
< 1  2  3 >
Update: May 30 @ 2:10am

- Add depth
- Add examples
- Add utilities
- Fix rotation winding direction being incorrect

Update: Mar 8 @ 2:11pm

- Removed devtool

Update: Feb 15 @ 3:12pm

- Fixes some zoom issues

Update: Dec 22, 2024 @ 2:16pm

- FIxes a crash resulting from initializing geometry buffers with a size of 0.

Update: Dec 3, 2024 @ 12:42pm

Version 3.0.0.2 has been published to Stable tModLoader v2024.9, learn more at the homepage[github.com]

Update: Dec 3, 2024 @ 9:28am

Version 3.0.0.1 has been published to Stable tModLoader v2024.9, learn more at the homepage[github.com]

Update: Dec 3, 2024 @ 9:23am

Version 3.0.0.0 has been published to Stable tModLoader v2024.9, learn more at the homepage[github.com]

- Addition of v3.0 API
- Addition of user configured particle limit functionality

Update: Jan 5, 2024 @ 8:58am

Version 2.0.0.2 has been published to Preview tModLoader v2023.11, learn more at the homepage[github.com]

Update: Jan 4, 2024 @ 7:03pm

Version 2.0.0.1 has been published to Preview tModLoader v2023.11, learn more at the homepage[github.com]

- Fixes zoom not affecting GPU particles

Update: Jan 3, 2024 @ 8:11pm

Version 2.0.0.0 has been published to Preview tModLoader v2023.11, learn more at the homepage[github.com]

Major changes:

  • Completely rewritten particles. There are now three different kinds of particles you can utilize.
  • CPU Particles, Particle, is the same as the original particle design. You can create your own particle with custom Update and Draw methods, then spawn it in the world with ParticleSystem.NewParticle(...); or ParticleSystem.NewParticle<T>(...). Particles must define a parameterless constructor to utilize generic typed methods (NewParticle<T>())
  • Quad Particles are one of two types of GPU Particles. They exist entirely on the GPU, allowing much greater performance at the tradeoff of control. You can't define custom Update or Draw methods for this particle type and they can only use one texture, but they are sufficient for 99% of use cases and are much more performant than their CPU counterpart. They also employ a new drawing parameter called Depth, which allows you to give your particles the illusion of parallaxing. It also makes them smaller or bigger depending on how "close" (high) or "far" (low) their depth value is.
  • Point Particles are the other type of GPU Particles. They have the exact same behavior as Quad Particles, except they are more performant due to only requiring one vertex per particle, and they cannot utilize scaling (including with Depth).
  • Completely rewritten emitter. The new emitter allows much more customization and flexibility that saves you from having to define certain behaviors on your own. Emitters must define a parameterless constructor to utilize generic typed methods (NewEmitter<T>())

GPU Particles

Keep all of this in mind:
  1. There are two: QuadParticle and PointParticle. These classes define a subset of properties that they can utilize. They inherit from GPUParticle, which exists solely for genericness
  2. They cannot be used outside of their respective GPUParticleSystem, which are QuadParticleSystem and PointParticleSystem. To use the systems, you'll need to create one and store it as a variable. You'll want a place to manage all of your particle systems. See: ExampleParticleSystemManager[github.com]. Each system implements a NewParticle method so you can spawn particles
  3. REMEMBER TO CALL Dispose() ON PARTICLE SYSTEMS. Do this when unloading your mod or when you know they are no longer needed. Avoid doing this frequently at all costs.
  4. You can inherit from a particle system and partially control its functionality. See: ExampleParticleSystemWrapper[github.com]
  5. The particle systems can be customized heavily via their respective GPUParticleSystemSettings or by using the properties in their classes. Both systems are fairly close in customization, though the PointParticleSystem has less customization than the QuadParticleSystem due to not needing it.
  6. They are highly performant, and should absolutely be favored when dealing with large amounts of simple particles. GPU Particles can cover 99% of use cases
  7. Keep your particle limits low and considerate. Sometimes less is more, especially when you're probably not concurrently spawning 1000 particles per 60 frames. Measure how many particles you expect to spawn and how long they last on average, then adjust your limit accordingly.

CPU particle changes:

  • See: ExampleParticle[github.com] for how to create a particle and ExampleTrailingParticleBase[github.com] for how you can utilize inheritance to centralize functionality
  • Added new property, VelocityDeivation. This additively adds the value to the velocity before VelocityAcceleration is applied.
  • Added new property, Bounds, allowing you to specify expected draw bounds for your particle so that the system can automatically cull your particle's draw code from being unnecessarily run when not in view of the player
  • Added new property, Sprite, allowing direct access to the automatically fetched texture
  • Added new virtual method Spawn
  • Added new virtual method Death
  • Initialize has been merged into Spawn
  • AI has been renamed to Update
  • The AI array has been removed
  • The oldX arrays have been removed
  • PreDraw has been removed
  • PostDraw has been removed
  • SpawnAction has been removed in favor of virtual method Spawn
  • DeathAction has been removed in favor of virtual method Death
  • The behavior of VelocityAcceleration has changed to be multiplicative
  • Particle movement calculation is as follows: position += velocity then ((velocity += deviation) *= acceleration)
  • Particle scale calculation is as follows: scale += velocity then (velocity *= acceleration)
  • Particle rotation calculation is as follows: rotation += velocity then (velocity *= acceleration)

Emitter changes:

  • Complete rewrite, nothing is the same.
  • See: ExampleEmitter[github.com]
  • Now supports a variety of customizable settings, which are stored as properties in the Emitter class
  • Added Initialize virtual method for setting initial values without needing to define a constructor
  • AI has been renamed to Update, and Update predefines certain behavior, so make sure you call base.Update() if you wish to keep that behavior
  • Added SpawnParticle virtual method. Does not spawn anything by default, you should override this to take advantage of the emitter's predefined behavior to spawn the particles yourself
  • Added Kill method, to remove an Emitter for good
  • Added SaveData virtual method, so you can save custom data with your emitter
  • Added LoadData virtual method, so you can load custom data with your emitter. Use defensive code to prevent errors

EmitterSettings

  • EmitterShape
  • EmitterOrigin
  • Position
  • Width and Height
  • Padding and Bounds for culling
  • MinimumInterval and MaximumInterval for how often to spawn particles
  • MinimumSpawns and MaximumSpawns for how many particles to spawn
  • Data which stores custom metadata in string format
  • and Save which allows you to specify whether the Emitter saves on world exit.

EmitterParticleSettings

  • Various properties for random velocity values
  • Various properties for random scale values
  • Various properties for random rotation values
  • Various properties for random depth values

EmitterColorSettings

  • Properties for start and end color, alongside support for using HSLA instead when UseHSLA is true