demodude4u / Factorio-FBSR

Factorio Blueprint String Renderer
MIT License
74 stars 20 forks source link

Fixed ArtilleryTurrets, added shadow composition #127

Closed Bilka2 closed 3 years ago

Bilka2 commented 4 years ago

The artillery turret change also fixes the hack related to filename selectors - instead of embedding the selector in the Lua, it is now passed around in the functions.

By doing that, I noticed overlapping shadows and found comments that state that shadow composition should be implemented.

So I implemented shadow composition and made all entities draw their shadows :)

Due to drawing shadows below all entities, shadows are drawn below entities when the game says they should be above. However, before shadow composition, shadows would sometimes draw above entities that the shouldn't draw on. So some shadow ordering is better, some ordering is worse. I think that drawing shadows below all entities is an acceptable tradeoff for drawing shadows without overlapping and for all entities.

Examples: Before, note overlapping wall shadows and e-pole shadow above solar panel (both wrong) before

After, note that the steam turbine shadow no longer overlaps the rails (wrong), but gate shadow overlap is gone and e-pole shadow no longer overlaps solar panel (both right). Turrets now have shadows. after

Shadow composition example, note the artillery turret shadow: Before: before

After: after

Bilka2 commented 4 years ago

Note to the artillery after image: The missing shadows below the wagons are related to the shadow composition.

The shadow draw order could possibly be solved by doing the shadow->image merge between drawing the entity layers. The base game does this between the layers TRANSPORT_BELT_CIRCUIT_CONNECTOR and LOWER_OBJECT_ABOVE_SHADOW. I do not know how to do this here, as the entities are drawn via a sorted stream and I do not know how "inject" something after a certain layer.

Bilka2 commented 4 years ago

Hey it's me again.

I made a hack for the shadow draw order on a branch: https://github.com/Bilka2/Factorio-FBSR/compare/master...Bilka2:shadow-hack It's really bad code, but it works. Shadows on rails: rails Shadows still below solar panel, as wanted: solar