Updating the Lava Code


So here is the static lava:

On to changing it.

Options

The first option I thought of was to use OpenGL shaders to create the lava movement effect. But to do this I'd have to rewrite so much of the rendering code and I don't want to do that. So the next possibility,  that took much longer to arrive at, was to layer multiple images on top of each other... Pretty simple.

The way I'm doing this is by creating a texture in SDL and rendering each image to it separately after moving each image separately, there is also a check when the images are moved making sure not too much of an image is out of bounds of the needed area that it would cause any empty spots in the lava.

So here is the first iteration of moving three different images on top of each other:


This leaves the lava looking like one continuous texture, which it is. Reminds me of the effect the show Chowder uses for clothing:

There are a few problems that I have with the lava as it is now: 

 1. the movement is not smooth

 2. the lava texture itself looks strange

 3. and it "bounces" around

My idea to solve 1 and 3 is to "wrap" the textures, meaning that when the texture moves past one side the part that has overflown shows up on the other side. Not sure if I am explaining this right. Either way, that alone takes care of the undesired bouncing effect and with the wrapping I can just make it move at a more reasonable and constant rate (currently the movement is randomly generated which is partly the reason for the un-smooth movement.

"Wrapping" Textures

As explained above, this is not wrapping in the typical 3D graphics sense, I just don't know what the name is for this kind of thing. Moving along, the graphics library SDL doesn't have "wrapping" functionality, why would it, so I have to write something to solve this.

The first thing that comes to mind to solve this is to have a few copies of each texture so that I can put them into a 2x2 grid, where each is an independent texture. This will allow the textures to be shuffled around when an overflow occurs while making sure no empty space ever becomes evident in the lava. Not an optimal solution, I'm sure there is something better. So I'll think this over for a bit and come back. Here's a diagram in the mean time, Muratori-style.

Alright here is the current status after half an hour: 

Honestly, no idea why it's doing this... There clearly moving at different speeds some how, so first I will check that.

I found a lot of problems. Mostly with the for loops that go through these things ... Okay, I fixed it so now they're moving at the same speed but this actually looks pretty bad. And there is still the problem of the smearing effect, and I'm not sure how that's happening. 

Fixed the tearing by properly caring for the texture by clearing it... But the textures aren't "wrapping".  Alright, I think I have solve the wrapping by changing one of the awkward ways I'm handling movement of these things.

Finally, I fixed several simple math and for loop errors, only took ~20 minutes? Here is the current lava:


Okay, think this is better in some ways, but still ugly and there still seems to be some judder or something off with the movement of a few of these things. Hoping this ends with something that will ship in the game ... oh man... I'm gonna try making them move at different speeds.

Now, with updated speeds and alpha values, here that is:


Definitely gonna update alpha and speed values, but not bad... After asking the art man for any advice, they said to have other yellow and red particles on the lava itself, makes sense. Not sure where to go from here. Come back to it tomorrow.

Day II: Alright, after altering everything even more, here is what we currently have:


I think I like the older one better ... Oh well. We'll see, we'll see.

Anyways that's the lava.

Day III: gonna lose my mind if I keep trying to perfect this... so, this is it for now...


I didn't proof-read this

Get His Master's Voice

Comments

Log in with itch.io to leave a comment.

lava looks amazing

(I didn’t proof read this)