Last month I had just started working on a system for transforming the color of sprites. I finished it pretty early on into this month, and immediately afterward made an post-processing effect which performed the same effect but across the entire screen. Although color matrices can do some really interesting and nearly arbitrary things to process one set of colors into another, for now I settled for just creating a set of interfaces for the most common set of effects I’d need: Hue, Saturation, Lightness, and Brightness. If you’re familiar with these sorts of operations you might have expected “Contrast” to be listed there, and it was at one point – however, I realized it was easy to approximate its effects with the lightness and brightness sliders, so I removed it.
Perhaps a word of explanation about what a color matrix is would be useful. A color matrix is a way of multiplying color values by each other and then offsetting the result: So, for instance, I could rotate the colors by making the red channel equal to the green channel and the green channel equal to the blue channel and so forth, or could zero out the blue channel to tint it yellow, or could add to all the channels to increase the overall lightness of the image. With that in mind, the operations do the following:
- Hue: Rotate the RGB channels by degrees from -180 to 180
- Saturation: Multiply the RGB channels while offsetting them enough to keep the overall average value the same
- Lightness: Add to the RGB channels, moving them towards white or black
- Brightness: Multiply the RGB channels, making colors more vibrant
This is a pretty powerful set of commands and is probably all you’d need under most circumstances. Nevertheless, it is tempting to add an interface for setting the matrix directly at some point, which would be much clunkier but allow for more unusual effects such as negative imaging, mapping the image’s transparency to its RGB brightness, or performing operations on only certain color channels. I’ll likely add it either at such time as I need that functionality or as I decide to sell this on the asset store.
Another feature I added, which I’m not sure if I’ll ever use but it seemed like an obvious addition, was adding a mask texture to control to what degree the color matrix is applied. I have no idea if or when this will become significant, but the idea of modifying both this texture property and the color matrix values simultaneously opens the door for some really unusual and powerful effects. Another possibility which I’m tempted to explore in the future might be loading a bunch of color matrices into a 3d texture and applying that as a post-processing effect… but I digress. The range of possibilities is exciting, but I need to keep moving.
This is something I can clearly go on about at length, but in practice this only took me a week or so of work and is more or less complete now. After completing the color transform feature, I was feeling stressed out with all of the work I’d been doing on the game and decided to take a week off… sort of. I ended up spending it working on music composition, something I’d been missing doing. This isn’t strictly part of the DevBlog, since this piece won’t feature in the game, but I’m quite pleased with how it turned out and felt like posting it here anyway.
I’d also, at the end of last month, finished implementing a system for changing between rooms in the game. This system was more or less functional but not really tested, and I’ve been developing it further over the last month. Aside from debugging, I’ve also made it so each room has a set of appearance options such as default lighting, background image, and post-processing effects, and whenever you move between rooms it changes between them. I actually went a step further and made it so these values actually change inside the editor depending on which room you’re currently looking at, so I can actually see these appearance modifications without starting the game and running to the room.
I spent some time at this point making some improvements to my work-space. It turns out that for $70 in monitor mounts you can drastically increase your available desk-space, and also just make a working environment feel generally more professional. For whatever reason, I’ve never felt as much like I was living in the future as I did after setting up my room with monitor mounts. Unfortunately for some reason my phone camera is incredibly terrible and this was the best picture I could take (so much for the future), but you get the idea.
In between all these other things I was making slight tweaks and improvements to the test rooms, shifting the terrain around, improving the visual effects, adding a mist particle effect and so forth.
https://youtu.be/3MLSZlWFRRg
I’m very pleased with the overall appearance of this section so far. I am not, however, pleased with its performance: There’s a little bit of framiness in the first couple of areas, but not enough to worry me too much. However, if I move further on, into areas with larger particle systems, performance starts to become truly terrible. At first I thought this was due to core issues with the way the Unity particle system renderer worked, and started working on developing a replacement, but once the supposed replacement was a ways along I tested it against the basic particle system and noted its performance was actually slightly worse – you know, the same sort of performance hit you’d expect from a system doing basically the same thing as what was there, but made by someone with less internal access and less experience with this kind of programming. Replacing the particle renderer was a bust, but all hope is not lost: Further brief diagnostic attempts revealed that the worst issues seemed to disappear if I disabled my custom particle animation effect, which could either mean that that effect is far more processor-intensive than I had believed or that enabling it was forcing the particle system into a state where it couldn’t operate as efficiently. Between that, the possibility of shader efficiency improvements, and the potential to replace some of the particle effects with cheaper and simpler animated textures, I think I’ll be able to resolve this to my satisfaction… eventually.
I’m going to be out of town for the next couple of weeks but will probably still have plenty of time to work on the project, so the question is how much of this work I can effectively do on my old laptop. Considering the areas with really bad performance drop down to like 2 frames a second even on this somewhat recent desktop, it may be unfeasible to tackle these performance improvements right away just due to the amount of time I’d have to spend waiting for clicks to register while testing changes. Still, I’ll give it a shot – and even if it doesn’t work I still have a ton of animation work to do, which I should have no problem doing with that equipment. Even if that, too, proves infeasible for some reason, I can plan out what I need to do for these first few areas – even if I have to do it with pen and paper.