Home Artists Posts Import Register

Content

    One of the issues I've been wanting to fix since I started working on VT is how to deal with sprite transparency. If you've played many other eroge or VNs you may know what I'm talking about. As a character's image starts to fade, the Sprite layers making up that image become visible for a few frames, breaking the illusion.

    Now, this creates obvious problems for me. Not at the moment, since characters are still fairly simple, but with the stomach system coming and the need for more layers, it's possible that mid-digestion you'll end up seeing something like this:

 

    Yeah, no good. There would be no point adding in a system for multiple stomachs if it came with such a major graphical bug. However, as far as I am aware there is no simple way to solve this. There may be some method hidden in some library somewhere that could easily take care of it, as is often the case, but at the time of writing I haven't been able to find any info on it.

    So, what then? I could use a shader, I guess. Probably. But I don't have much experience with them and what little I do has told me they're very finicky and difficult to work with if you don't know exactly what you're doing. Another way could be to manually create a new image from the combined image data of your current layers, pixel by pixel, but that would be far, far too slow.

    I actually stumbled on the solution while I was trying to figure out how to solve the issue of mod images being loaded into memory. There was a component I had largely been ignoring up to that point, the RawImage class, because it seemed to be an inferior version of its brother, the Image class. After all, Images give you lots of options to work with and use Sprites, which are smaller and more efficient than the Textures that RawImages use, making them a clear winner.

    The thing is, Sprites are able to be more efficient than Textures because they go through quite a bit of processing beforehand to optimize them for their use in Unity. The reason that mods currently take so long to load and must be stored in memory is because every single image must go through the process of slowly being converted into a Sprite in order to be used by an Image. While RawImages are worse performance-wise than Images, it's hypothetically possible that by using them I could stream image data directly into the game, killing two birds with one stone. (This bears further testing though.)

    So how does this solve the transparency issue? Well, the ability to use Textures instead of Sprites opened up a lot of options for me. They're much more malleable and much easier to create, after all. I eventually discovered that if I set up a second camera in my scene, I could have it render for a split second and output everything it saw to a new texture, and then copy that to a RawImage within my main camera's field of view. If I just layered the images I would normally create in my scene in front of this camera, I could very effectively and easily smush all those layers into a single texture, completely fixing the transparency problem and making image management much more simple to boot.

    And is this a good solution? Probably not. The best solution would likely be to use shaders, but it's important to balance what's good with what works best for you in game dev. I don't think I can overstate just how exciting it is when all the pieces fall into place like that, though. There's an immense sense of satisfaction in having a dumb idea that actually works, which pretty much encapsulates VT's entire development in a nutshell.

    As for the next update, I believe it's still a ways out. I've been on a roll when it comes to polishing and adding new backend stuff, so I'm riding out that wave and seeing how far it takes me since that technically should be my main focus while the game's in pre-alpha. As always, thank you so much for your support and patience!

Comments

Shaman 414

I just love the enthusiasm in your explanation also take your time, love your work.

no2ironman1100

rendering it like this is roundabout but It is fun finding ways to solve those kind of problems.