pollution visuals


heavilly polluted areas will now contain clouds of smog

Tweaks
2 years ago
1.1
4.18K

g Nice mod! but how does it work?

2 years ago

But how it works?

2 years ago
(updated 2 years ago)

hello darkfrei,

there are a few modular graphics that i had made

these are my debug graphics to make it a little more clear on what is happening.

the script will check a chunk it's pollution value. and it will also check the neighboring chunks their pollution values.
and based on this information it will spawn the right sprite. (which are currently animation prototypes)


here you can get a better idea if what i mean. the current pollution threshold is 50. so if a chunk is more then 50 polluted it will render a middle piece.
if a chunk is less then 50 polluted but one of its neighboring chunks is more than 50 polluted. then it will render one of the corresponding pieces.

you can check my code in the function "check_polluted_chunk(chunk_data)" to see exactly what these conditions are.

all my necessary tables are defined in the function "setup()"

i encourage you to look through my code if you want to have a thorough understanding on how it works.
i have put comments in a lot of places. explaining what everything does and what its for

2 years ago
(updated 2 years ago)

Was it tested on megabase? My mod creates just squares and it needs too much perfomance on the really big megbases.
Is the thickness of the smog was based on the pollution?

2 years ago

i have not tested this on a mega base no.
it would be interesting to see how the performance would hold up. but i have not yet put much attention into performance,

2 years ago
(updated 2 years ago)

there is a table in the variable "density_levels" the table looks like this {50,100,150}
if a chunk has 50 pollution or more it will have 1 layer of thickness
if a chunk has 100 pollution or more it will have 2 layers thickness
if a chunk has 150 pollution or more it will have 3 layers thickness <- this is the thickest level of smog

2 years ago

Would it be more efficient to use 3 different sprite sets and only ever draw one per chunk?

2 years ago
(updated 2 years ago)

hello nironwolf,
i'm not really sure what you mean but i assume you mean that i mirror the side and corner pieces for the other side.

I've tried this in the very beginning but you start getting into trouble with the inverted corner pieces. I'll show you what i mean.

this is why i have made a sprite for every corner, bottom, side and top.

2 years ago

if you mean that the thickness should be 3 different sprite sets.
well then you start to loose scalability. in the most recent update you can set the max layers yourself. I'd have to make a different sprite for every thickness if i wanted more layers of thickness which could go up to 10. I'd have to make all these sprites. and i also have to account for layer changes. theoretically you could go from a layer 10 thickness to any other 0-9. I'd have to make sprites for all those layers changes too. that would be 120 sprites just for all the corner and side pieces and then also 10 on top for all the middle pieces. which would mean i have to make 130 sprites. not sure if that would be more efficient.

2 years ago
(updated 2 years ago)

Is it not just a sprite RGBA tinting for smog thickness levels? You can make a nice 255 colors gradient without any problems with amount of sprites.

2 years ago

i didn't know you could make color gradients with the factorio api. how woud i do this?

2 years ago
(updated 2 years ago)

Not color gradients, but gradients of sprites. You can have in one chunk the sprite {0.5,0.5,0.5,0.5} and in the next one {0.50390625, 0.50390625, 0.50390625, 0.50390625}, which is almost the same color, but after several of chunks you can get the smooth visual gradient between chunks.
https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_sprite

2 years ago

i see what you mean. but if i remove the layer system i would get these square looking seams i think.
especially around areas where the pollution gradient is really steep.

2 years ago

Could your sprites have "fuzzy" edges? Like a wisp of pollution going into the next chunk or not completely filling the chunk? Those soft edges my still produce a nice blend with the gradient drawing as darkfrei suggested.

Please understand I'm not saying what you've done isn't fantastic. Just trying to help brainstorm some "optimization" ideas.

2 years ago

Follow up thought. If each edge (keeping your corner and edge pieces even) had a regular fade out centered on the chunk boundary, would an adjacent chunk at a different gradient just smoothly fill in?

Without looking at your sprite size I'm going to use some simplified numbers.

Full chunk graphic is 1000x1000. What my thought is, expand this 100 all the way around. Now you've got a 1200x1200 sprite. The 200 around the whole outside gets a fade from 100% to 0% so that it's 50% at the original chunk edge.
If another at the same gradient is placed next to it. That transition would ramp up and down at the same rate and look like 100% all the way across the transition. But if say the next chunk is only at half intensity, the roll off of the "thicker" chunk would fade across the border smoothly into the less intense one.

IMHO, having the sprite spill into the edge of the next chunk is fine even if that chunk has 0 pollution. Suddenly having a high polluting chunk transfers it's pollution into adjacent chunks anyway so this just illustrates that happening.

2 years ago

Could your sprites have "fuzzy" edges? Like a wisp of pollution going into the next chunk or not completely filling the chunk? Those soft edges my still produce a nice blend with the gradient drawing as darkfrei suggested.

i have thought about this early on while developing the mod. but i thought the the fuzzy edges would overlap on other polluted chunks and it would make the edges of polluted chunks look like it would have thicker smog. i thought this wouldn't look nice. haven't tested this however so i could be totally wrong.

Please understand I'm not saying what you've done isn't fantastic. Just trying to help brainstorm some "optimization" ideas.

haha no worries. all ideas are welcome.

I'm having a hard time understanding what you mean in your follow up idea. i will read it again tomorrow when I've got some more time.

2 years ago
(updated 2 years ago)

Made a more illustrated response over on my site since I don't think I can post the images here in the Discussion section.

https://nironwolf.com/index.php/games/pollution-visuals

2 years ago

As for the base texture, you could "cut" it from a "seamless texture". Have the base repeat size of the texture chunk size but start with like a 2x2 repeat of it to cut the oversized shape out of to fade the edges. Then when it hits the next edge it just straight overlaps.

For instance here is a quick tutorial for Photoshop, but you should be able to Google up your image editor of choice. :) https://www.youtube.com/watch?v=FR3Z0zr1RaY

2 years ago

i don't like the idea of using overlapping fuzzy edges because it would create a thicker line where the sprites are overlapping

you can post images here with this format

2 years ago

Right, that's what the rolling it off along the edge is supposed to fix. I'll see if I can edit one of yours and post back here later. Bedtime now. :)

2 years ago
(updated 2 years ago)

If the sprite is 40x40 tiles (one chunk is 32x32 tiles), then you have overlapping 4 tiles in every neighbour chunk. So you can make the 24x24 tiles "solid" color texture and 8 tiles in each side the transparency fading.
The problem can be be the corners, where 4 sprites have overlapping.

New response