HomeGamesUpdatesPricingMethodology
Steam News4 August 202612d ago

Monday Musings #60 – Portals and Particles

As I've been looking through the toolbox for ways to bring buildings to life, one nagging problem has remained unsolved: particle interactions with portals.

In this update4

Full notes

Full MoteMancer update

Read the full published notes in a cleaner layout. The original post stays linked below.

What changed

0 fixes2 additions4 changes0 removals
  • Gameplay
  • Performance
  • UI and audio
changedAs I've been looking through the toolbox for ways to bring buildings to life, one nagging problem has remained unsolved: particle interactions with portals.
addedAnd then there were stencilsEvery custom shader I wrote needed to add a custom stencil block to the code. Any shader made specifically in Shader Graph (as opposed to just writing the code by hand) needed to be exported and hacked into compliance. Granted it did work, but the process is very time consuming and slows iteration down quite a bit.
addedAnd then there were stencilsOn the bright side, it forced me to learn how to automate some of the processes, and now adding stenciling to anything is a button click. If you ever find yourself doing the same action over and over - especially one you have to relearn every few weeks - taking the time to write a small tool will save hours of future sanity. Highly recommended.
changedAnd then there were stencilsWith that trick in the bag, the result is mostly convincing, and it even works with the mega-shader that handles all of MoteMancer's structures.
changedBut then there were particlesNeither is strictly better than the other, but VFX Graph performs its particle calculations on the GPU. That's ideal for MoteMancer because it keeps that work away from the CPU running the automation simulation. They're also incredibly cheap. Even with tens of thousands of VFX Graph particles running through Fire Wires, they're still cheaper than turning those same lines into geometry.
changedSo what's the solution?There are several paths I'm chasing. Hacking the shader in the usual way has so far proved fruitless; VFX Graph is more stubborn than most. I think there's a version where I pass a portal mask into the graph and use it to eliminate particles outside the visible area, but that may be expensive at the scale MoteMancer needs. I could also fall back to Shuriken, but that begins moving the cost back onto the CPU, which I'd rather avoid.

MoteMancer changes

changedAs I've been looking through the toolbox for ways to bring buildings to life, one nagging problem has remained unsolved: particle interactions with portals.
addedEvery custom shader I wrote needed to add a custom stencil block to the code. Any shader made specifically in Shader Graph (as opposed to just writing the code by hand) needed to be exported and hacked into compliance. Granted it did work, but the process is very time consuming and slows iteration down quite a bit.
addedOn the bright side, it forced me to learn how to automate some of the processes, and now adding stenciling to anything is a button click. If you ever find yourself doing the same action over and over - especially one you have to relearn every few weeks - taking the time to write a small tool will save hours of future sanity. Highly recommended.
changedWith that trick in the bag, the result is mostly convincing, and it even works with the mega-shader that handles all of MoteMancer's structures.
changedNeither is strictly better than the other, but VFX Graph performs its particle calculations on the GPU. That's ideal for MoteMancer because it keeps that work away from the CPU running the automation simulation. They're also incredibly cheap. Even with tens of thousands of VFX Graph particles running through Fire Wires, they're still cheaper than turning those same lines into geometry.

As I've been looking through the toolbox for ways to bring buildings to life, one nagging problem has remained unsolved: particle interactions with portals.

MoteMancer's solution to Portals is not super common among games. That brings the benefit of being a novel effect to many players, but also one that presents many hoops to jump through.

Proof of Concept

I still remember the first proof of concept I did for what live portal swapping could look like, and how a 2d-live portal transition could work. I dug through my old video library and found it, preserved here for your viewing pleasure as an example of real scrappy-dev energy:

I also spun up this visual proof that you could co-locate portals and they would create a complete circuit. I ended up spacing portals out a little further than this in the end, but you technically only need 2 unique locations to complete the 6-plane circuit. Read it in a circle.

And then there were stencils

There's a built-in Unity paradigm called stenciling that allows you to draw inside or outside a given area, this is supported inside their basic Sprite Renderer, which means cutting any image by the stencils is a breeze.

The catch is there's a big difference between “supported by most things” and “supported by everything.”

Every custom shader I wrote needed to add a custom stencil block to the code. Any shader made specifically in Shader Graph (as opposed to just writing the code by hand) needed to be exported and hacked into compliance. Granted it did work, but the process is very time consuming and slows iteration down quite a bit.

On the bright side, it forced me to learn how to automate some of the processes, and now adding stenciling to anything is a button click. If you ever find yourself doing the same action over and over - especially one you have to relearn every few weeks - taking the time to write a small tool will save hours of future sanity. Highly recommended.

With that trick in the bag, the result is mostly convincing, and it even works with the mega-shader that handles all of MoteMancer's structures.

But then there were particles

Unity currently has two main flavors of particles: the old-school Particle System, commonly called Shuriken, and the newer VFX Graph.

Neither is strictly better than the other, but VFX Graph performs its particle calculations on the GPU. That's ideal for MoteMancer because it keeps that work away from the CPU running the automation simulation. They're also incredibly cheap. Even with tens of thousands of VFX Graph particles running through Fire Wires, they're still cheaper than turning those same lines into geometry.

But there's a catch which you've probably guessed by now: they don't play nicely with stenciling.

The problem has been partially invisible for a while because the particles at least sort correctly. If you're standing on Life and looking down into Water, you would never notice. But if you're standing on Water and looking up into Life...

So far, this hasn't been as bad as it could be because only Fire Wires and Mote Patch particles are especially abundant. But in a world where nearly every structure wants the aesthetic benefit of lively particle motion, the problem becomes considerably larger.

So what's the solution?

While I usually have a pretty good beat on a problem, today my answer is: I don't know yet.

There are several paths I'm chasing. Hacking the shader in the usual way has so far proved fruitless; VFX Graph is more stubborn than most. I think there's a version where I pass a portal mask into the graph and use it to eliminate particles outside the visible area, but that may be expensive at the scale MoteMancer needs. I could also fall back to Shuriken, but that begins moving the cost back onto the CPU, which I'd rather avoid.

Really the main thing I'm musing about today is that all problems are hard until they are easy, and it is important to share roadblocks just as much as triumphs. They are undeniably part of the process. One thing I've learned though over many years of development: Tenacity is often the best tool you have.

So in that spirit, back to the Lab! ~CyanAvatar 🌿

Source

Steam News / 4 August 2026

Open original post

Changelog.gg summarizes and formats this update. How we read updates.