Using a texture to handle gases in the atmosphere.

Hey all!
I am making a game where I want one of the features to be air and land pollution, however, I have a dilemma. How do I do it?

An inspiration for the mechanic is Factorio:
image
(Image source: Pollution - Factorio Wiki)

In Factorio, the world is subdivided into chunks and each chunk has its own pollution level, which spreads over time.

The way I want to implement it is to have more than one type of pollution (such as Carbon, NOX, Sulfur etc.). These are in a map of limited size and the pollution levels should be read and written by CPU and read by GPU (for materials).

Pollution levels should decay and spread every tick (tick interval of ~10 seconds).

I also should be able to save it and load it in my save file.

Given this, what is the best way to do it? I was thinking about render targets, but I don’t know if the spreading and decay part would cause great amounts of lag. (given that for a 512*512 texture it would still be over 250k pixels to calculate PER POLLUTANT)
I can use C++ and blueprint for this, as long as its efficient.

Thanks a lot in advance!

As far as i can see, the Fog of war approach from this video can be reasonably adapt to your goal. In short - rendertarget applied by postprocess over whole world. UE4 - Tutorial / HowTo - Line of Sight Vision System - YouTube

Of course it still depends on your world resolution and the acceptable ways of visualisation, but given no details about your graphics - i can’t say if this way is applicable to your visuals.

Had a look and I don’t think it will work… He uses triangles. A few triangles and its done. Mine uses individual “pixels” to represet chunks, meaning that mine would be much more performance heavy…

Also, is there a way to save these textures in a game save?

He uses triangles. A few triangles and its done. Mine uses individual “pixels” to represet chunks, meaning that mine would be much more performance heavy…

Triangles is just a convenient way to draw a visibility sector. The point is that it’s done on the UCanvas. You can check it’s source and if you dive deep enough you can see there is a things like FBatchedElements::AddPoint().

Or you may try to generate texture at runtime by other ways than AddPoint() or even UCanvas - those likely also exists.

Also, is there a way to save these textures in a game save?

Well, those textures are just a runtime generated visualization. Your game’s internal model still comes first and it IS the thing that should be saved, not the resulting textures that were drawn upon this model