Logic World Wednesdays: Thrilling Thumbnails

by @JimmyDeveloper4 days ago (edited4 days ago)

Hello Logicians! I’ve had a fairly pedestrian week of development, working on miscellaneous maintenance tasks. For example, I polished off last week’s work on fixed point positions by updating the save format version: position data is now saved and loaded as fixed-point instead of floating-point, matching the new data structures that are used internally. I also added a save converter to the new format so that you can use all your 0.90 saves in 0.91, and I updated the sandbox list UI to notify the user of which saves are using the old format and need to be converted.

save list

But my biggest task this week by far was to make some major updates to the world objects shader. This all started when I decided to address an issue with how thumbnails (the little isometric component graphics that appear in the Selection Menu and on the hotbar) are rendered. In 0.90, thumbnails look different depending on the scene in which they are generated. This is because the thumbnail renders use exactly the same materials as are used to render objects in the world. World objects are affected by environment lighting, so thumbnails are too.

click for bigger image

This is kind of weird, but it’s not a big deal in 0.90; I’m not sure if anybody but me has even noticed it. However, for some upcoming features I plan to add for 0.91, thumbnails really ought to be generated consistently and reliably, and look identical no matter where the generation happens.

So, I’ve upgraded the shader I wrote for GPU instancing. It now has two lighting modes: environment lighting and custom lighting. We use this new “custom” lighting mode for thumbnail renders, and so now it doesn’t matter where they’re created, they always have consistent lighting. I also added support to the shader for rendering in non-instanced mode, so we can use it for non-instanced decorations like the clicky part of buttons and switches, and these decorations will also have consistent, custom lighting applied to them in thumbnail renders.

Here’s the result:

click for bigger image

If you look closely, you’ll notice a few more differences in the appearance of thumbnails between 0.90 and 0.91:

  • Thumbnail renders are now anti-aliased, so the lines are smooth instead of jaggy. I already did this a few months ago, but I remember it was REALLY HARD so please appreciate it anew!
  • I fixed some artifacts along the edges of thumbnail renders, most noticeably in components with pegs that go right to the edge like D-Latches and Sockets.
  • The lighting is softer, with less contrast between the sides and tops of blocks. For now, the lighting otherwise emulates the 0.90 Grasslands appearance, but I’m still tweaking this. There will be secret settings for all the variables of thumbnail lighting, in case you want to customize it :)

Also: while I was mucking around in the shader code, I found a way to make it run a little bit faster! So that’s nice.

It’s such a small, subtle change, but it took hours and hours of banging my head against the code to make it happen. I’m still very new to graphics programming; I’m learning quickly, but this stuff is still taking me 10x longer than it would for someone experienced. However, it’s all done now. Thumbnail lighting is independent of environment lighting, my shader is faster and more capable, and the shader code is much more organized & reusable. I’m happy with the graphics work I’ve done this week.

I’ve got a few more small maintenance tasks on my list – none of them nearly as daunting as shader work, thankfully. After those are taken care of, I’ll spend most of the next two weeks on bugfixing. Thank you to everyone who’s reported a bug in 0.90 (especially Ecconia <3), I will be going through them very soon. After that, I’ll add a couple cool new building mechanics, and then Logic World’s first major update will be ready for release!

Thanks for reading. See you next Wednesday.