Skip to content

Implement the particle subsystem. - #256

Draft
Earu wants to merge 8 commits into
SourceDotNET:mainfrom
Earu:feature/particles
Draft

Earu wants to merge 8 commits into
SourceDotNET:mainfrom
Earu:feature/particles

Conversation

@Earu

@Earu Earu commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This PR is a draft to follow along the progress of the implementation of the particle system in sdn.

Any feedback/suggestion/tips are of course more than welcome, testing is also greatly appreciated as it's going to be fairly difficult to test all the cases involved here.

PS: I'm very sorry in advance for the amount of changes being pushed here.
PS2: Ghidra and Claude are being used in this process.

@Earu

Earu commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Noticed some previous changes for previous PRs got added in, will fix tomorrow.

@Earu
Earu force-pushed the feature/particles branch from 6022095 to 3c71865 Compare November 13, 2026 13:14
@Earu

Earu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

aligned branch with the latest changes on main

@Earu

Earu commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@marchc1 @callumok2004 I had a look in-game and all the particle operators should be implemented now, I could use help with testing / looking if behavior is different than in garrysmod etc..

Or even a first pass on the code changes

@ZehMatt

ZehMatt commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

This is quite a lot of code, I also see that it implements quite a few functions that don't have really anything to do with particles so it would be actually better to split this up into smaller PRs that are easier to review.

@Earu

Earu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

I did ask earlier in the discord what should be done but I've been told it was fine-ish (?). Regarding the extra functions they're necessary for the full impl of particles, I'm thinking ComputeLighting & co for instance, I can break it down further but there is at least one PR of ~12K LOC that needs to be done. This is because the particle system operators/initializers have a lot of boilerplate and amount to 160.

@ZehMatt

ZehMatt commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

I did ask earlier in the discord what should be done but I've been told it was fine-ish (?). Regarding the extra functions they're necessary for the full impl of particles, I'm thinking ComputeLighting & co for instance, I can break it down further but there is at least one PR of ~12K LOC that needs to be done. This is because the particle system operators/initializers have a lot of boilerplate and amount to 160.

I understand this is a big system but I would still split it to what is not directly relevant first, you are also implementing the full set of operators which on their own are rather modular, it's just a lot of code to go through but I'm not going to be in the way of blocking the PR if @marchc1 or @callumok2004 decide this is fine.

@Earu

Earu commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll try to split the new function implementations that are separate from the particle system into other PRs as a first pass, that should at least reduce the load of this one.

I think I can also separate the Lua bindings as another PR.

@Earu

Earu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@ZehMatt I've opened 4 PRs that match all the new things that have been implemented for particles to work but are not directly particle code.

Earu added 8 commits November 17, 2026 00:06
…model particles

- TE effect dispatch with ClientEffectRegistration and EffectDispatch string table
- ParticleEffect / ParticleEffectStop callbacks, DispatchParticleEffect and StopParticleEffects
- C_ParticleSystem think, CNewParticleEffect, ParticleProperty and ParticleMgr hooks
- lua: CreateParticleSystem(NoEntity), CNewParticleEffect methods, Entity particle methods, ParticleEffect(Attach), game.AddParticles
- AE_CL_CREATE/STOP/ADD_CP particle anim events and model keyvalue particles
- implement GetModelKeyValueText
- EffectData defaults Scale=1 and AllowOverride=true
- replace randomfloats .bin with inline RandomFloats.cs
…ers and render cache

- Spritecard shader (C# + GLSL) ported from the SDK, without depth blending
- C_OP_RenderSprites: spritecard and non-spritecard paths, sorted render list
- render cache batching and DrawRenderCache in opaque renderables
- NewParticleEffect.DrawModel per the GMod decomp
- sheet loading from VTF resource data
- emit_instantaneously and emit_continuously
- Position Within Sphere Random, Lifetime Random, Lifespan Decay, Movement Basic
- material system: IsSpriteCard, user clip transform override, camera position/vectors recompute
… remaining renderers

Operators:
- control point, movement, remap and transform operators ported from GMod client.dll

Initializers:
- bulk of the remaining initializers
- query support for hitbox sampling (GetRandomPointsOnControllingObjectHitBox,
  HitboxToWorldTransforms, IsBrushModel)

Forces and constraints:
- builtin force generators
- constraints: distance, distance to path, planar, world collide, world trace
  (with shared collision cache) and box
- NoiseSIMD and RandSIMD helpers

Emitters:
- instantaneous and continuous emitters reworked to match GMod
- emit noise and emit to maintain count added
- PrevSimTime reset to 1e23 every simulation step, as GMod does

Renderers:
- render_sprite_trail, plus a splinecard vertex shader (GLSL port of
  splinecard_vs20) for $splinetype materials
- render_screen_velocity_rotate
- render_rope: BeamSegDraw path and spritecard spline path. BeamSegDraw can now
  write into an external MeshBuilder with indices.
- Render models: renderer, precache and IParticleSystemQuery hooks. It draws
  nothing yet: the client query has no GetModel, GetActivityNumber or DrawModel.
- definition Precache now calls renderer Precache, as GMod does
- IModelRender.SetupLighting added to the engine (not wired to the particle
  query yet)
- add the remaining initializers, split by category (collision, control point,
  hitbox, parent, position, random, remap), including Cull relative to model,
  Remap Control Point to Vector and Remap Speed to Scalar
- ParticleSystemQuery: closest hitbox, desired hitbox and point-in-hitbox
  queries, plus Studio_MaxFrame for sequence-based lifetimes
- implement IEngineClient ComputeLighting, ComputeDynamicLighting,
  GetLightForPoint and GetLightForPointFast from engine.dll; the
  normal is now optional
- ParticleCollection: random vector queries advance the seed by 3 and sphere
  radius uses pow(r2, 1/3), both to match GMod
- add attribute field and control point clamp helpers
…ounds fixes

- util.ParticleTracer / util.ParticleTracerEx, the client "ParticleTracer"
  effect, GetTracerOrigin (with the SWEP GetTracerOrigin hook) and
  FX_TracerSound
- IntersectRayWithRay and CalcDistanceSqrToLineSegment
- CNewParticleEffect:Render()
- GL46: remap texcoord 6/7 to the wrinkle/specular locations to stay within
  16 vertex attributes, and only bind flex streams when TC4/TC5 are unused;
  spritecard shader locations updated to match
- ParticleCollection: fix the tint blue channel, initialize the constant
  normal attribute, and match GMod's RecomputeBounds (skip screen space
  effects, SSE min/max NaN semantics, summation order)
- ParticleSystemDefinition: parse the "normal" constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants