Programming - Marcel - Spatial ground UI: Sprite vs Decal vs Projector


Hey, Marcel here. Today I'll talk a bit about some of the UI feedback we're creating for the energy system in Katharsis.

In our game, the UI is one of our priorities. It must be simple, clear and give the player the information he needs in every moment. In fact, it is probably the department we're spending  more time on.


Our energy system is based on a single building, the Relay. It works like an extension of the main generator, giving energy around it. We need to comunicate clearly the effective range of that area, so the player can plan the disposition of the basecamp accordingly. Maybe you remember the first iteration from a previous devlog (https://wip-studios.itch.io/katharsis/devlog/55784/programming-marcel-building-a...), in which we just used Unity's gizmos while we were still developing the base system.


Of course, default gizmos aren't an acceptable solution for the final product, so we started researching for other options.

First one was using a simple 2D sprite as a texture for a plane object. However, that brought overlapping problems with irregular terrain.


Then, we tried with decals. Unfortunately, Unity still doesn't have a proper built-in decal system, but there are some workarounds. We implemented a decal system demo published by Unity (https://docs.unity3d.com/Manual/GraphicsCommandBuffers.html). We're very unexperienced on shader and rendering programming, so we just copied and pasted the code and prayed for it to work. 

Surprisingly it did, but in a quite awkward way. For some reason, the "documentation" for the demo is really short and doesn't explain much (also, it's provided on a .txt file for notepad, no comments on that). It was kind of hard to make it work as we wanted, and the implementation was really flimsy. On a certain moment we needed to have a script attached to a river and start the game with the main character looking to that river, otherwise the system wouldn't work. Weird stuff.


Finally, we found out about the Unity Projector System, which is a much more flexible way to achieve our goal. It is a single component that projects a cookie texture as light to a surface, allowing you to filter by layer the surfaces in which it's drawn. Via a simple shader, we're able to give that cookie texture a color (thanks Jeff Zimmer for this one https://hyunkell.com/blog/rts-style-unit-selection-in-unity-5/). This is our definitive choice, as it's easy to use and covers all our needs.


In conclusion, there always are multiple answers to the same question in programming. The difficulty lies in choosing the optimal option.

See you in future devlogs!

Comments

Log in with itch.io to leave a comment.

thanks