Khaligufzel / Dimensionfall

A survival game inspired by Cataclysm: Dark Days Ahead and Bright Nights.
MIT License
12 stars 5 forks source link

Furniture hides above player #385

Closed snipercup closed 2 weeks ago

snipercup commented 2 weeks ago

Requires #384 Fixes #353

Instead of making each instance invisible, the visual fragments are now discarded by the shader. This should improve reliability and performance. The downside is that due to the shader, all furniture is very bright when the player is close. I don't know enough about shaders to fix this. I see Khaligufzel has plans for lighting so maybe it will be different afterwards. I might update the shader if I learn more bout it.

The shader I made is applied to:

I could also apply it to 'level' nodes for chunks and for sprite3d that represent single containers, but I didn't want to put it all in this pr.

Since every furniture and item has a different sprite, I had to make a new material for each of them (but they all share the same shader). I didn't know where to create them, so I put the function in DFurnitures and DItems. They will make new materials if they do not exist yet and free them after the game ends. I am a bit worried this will get in the way of threads running while furniture spawns. We can solve this by creating all materials beforehand if needed.