Hi. I’ve been working on a volumetric fog implementation and now I want to share it.
It works with particles with light influence and a texture with noise to create a dithering effect, reducing visual artifacts.
This implementation emits the particles with a function instead of using the ParticleEmitter property “Rate” to bypass particle rate limits to make the volumetric fog look the best.
This volumetric fog is highly performant in decent devices.
Because of how light influence works with ParticleEmitters, the lights are sampled directly from Roblox’s voxel grid, making the volumetric fog look smooth.
This can be an issue sometimes when using ShadowMap or Future lightning technologies because of inaccuracy with lights and shadows.
Example (look how there is illuminated fog in the shadow):
Volumetric Fog Setup
Now, I’ll explain how to setup this volumetric fog implementation in your game:
- First, you need to get the model
- The model is a folder named “VolumetricFog” with a “Camera” part and a “Settings” instance inside
- You need to put the “VolumetricFog” folder in Workspace
After doing that, you can now playtest your game and it should work.
You can change the volumetric fog settings to make it look different.
The settings are inside the “Settings” instance as attributes.
This is an explanation of what every option does:
-
CameraSize
: The size of the camera part -
Enabled
: Enables the volumetric fog. This setting can be modified in realtime -
LightInfluence
: How much light influence the fog has -
ParticleMaxSize
: The maximum size a particle can have -
ParticleRate
: How much particles are emitted per second -
ParticleTransparency
: The transparency value of the particles (Note: Transparency values very close to 1 can cause visual artifacts) -
ParticlesFacingCamera
: Makes the particles to face the camera -
TextureQuality
: The texture quality of the particles. Lower quality = more visual artifacts. This setting can be modified in realtime (Note: 1 = low quality, 2 = medium quality, and 3 = high quality. If using a number that isn’t 1, 2, or 3, medium quality will be used) -
Tint
: The tint of the fog (Note: Use dark colors or the fog will look very bright) -
ZFar
: How much distance (in studs) the fog will reach (Note: More distance will require more particle rate and more particle max size to make the fog look good)
When implementing this, the most common issue that can happen to your environment is that the lightning may seem too bright, so you might need to make some changes to your game’s lightning or to the volumetric fog settings to solve this.
I will work on updates later. I want to make it look better with more performance, maybe optimizating the code, but I don’t have enough time (I’m lazy).
You can get the model here:
Volumetric Fog 1.0.0.rbxm (7.7 KB)
You can test it here: