Phantom lava and lukewarm lava in ILZ, analysis and fixes
Belgarel
Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer
You might have noticed buggy lava in ILZ where you're damaged by standing on things that do not look like lava and also can stand in some lava without taking damage. I debugged and fixed both of these, details for how to fix them follow.
Here's an example of the first type, the phantom lava. Note how the prawn takes damage from nothing:
The issue is in TemperatureDamage.OnCollisionStay(). The MeshRenderer for the VoxelandChunk I'm on in that video has the following materials:
lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava05 (instance)
lava06 (instance)
The 'standing in lava' check looks for any material containing the string "lava09". That matches "lava04tolava09 (instance)" and after a raycast to see if I'm colliding with it passes it thinks I'm in lava. It likely should be matching that lava09 one exactly instead as lava04tolava09 doesn't look very lava-ish to me. Here's a video of that same area where I'm having the game draw 1m tall green spikes that linger for 10s along the raycast hit showing the locations that it considered to be lava due to the lava04tolava09 material matching "lava09":
Now about the second type of buggy lava, the kind you can stand in but not take damage. I'll use the same green spikes as above and walk across some "real" lava as an example - note how the game isn't considering a big patch of lava to be lava (no spikes indicating a raycast hit on lava):
Standing in that patch you see the missing spikes on I take no damage, I'm not considered to be in lava here:
https://i.imgur.com/tx44APh.jpg
The materials at this point are:
lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava09 (instance)
Note how it has both lava09 and the lava04tolava09 as before but now neither are matching. In fact, the raycast doesn't intersect any of these, I'm effectively standing on nothing. So that's our second bug, a problem with the raycasting. This turns out to be a precision issue as the ray is being cast from the exact point of the collision into the ground and it will thus sometimes be treated as slightly below the ground. By hoisting the starting position of the ray out of the ground by 0.1m in the opposite direction (and lengthening the max distance from 0.3 to 0.4) it intersects both lava04tolava09 and lava09 as expected.
So let's put it all together and try out both fixes and see how it plays:
No more invisible lava, and no more lava you can stand in. Note that the few remaining gaps aren't dead zones as before, they're likely the prawn skipping across the landscape. You can see that when I walk through one gap near the end that it does register as lava.
Here's an example of the first type, the phantom lava. Note how the prawn takes damage from nothing:
The issue is in TemperatureDamage.OnCollisionStay(). The MeshRenderer for the VoxelandChunk I'm on in that video has the following materials:
lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava05 (instance)
lava06 (instance)
The 'standing in lava' check looks for any material containing the string "lava09". That matches "lava04tolava09 (instance)" and after a raycast to see if I'm colliding with it passes it thinks I'm in lava. It likely should be matching that lava09 one exactly instead as lava04tolava09 doesn't look very lava-ish to me. Here's a video of that same area where I'm having the game draw 1m tall green spikes that linger for 10s along the raycast hit showing the locations that it considered to be lava due to the lava04tolava09 material matching "lava09":
Now about the second type of buggy lava, the kind you can stand in but not take damage. I'll use the same green spikes as above and walk across some "real" lava as an example - note how the game isn't considering a big patch of lava to be lava (no spikes indicating a raycast hit on lava):
Standing in that patch you see the missing spikes on I take no damage, I'm not considered to be in lava here:
https://i.imgur.com/tx44APh.jpg
The materials at this point are:
lava04tolava09 (instance)
lava03 (instance)
lava04 (instance)
lava09 (instance)
Note how it has both lava09 and the lava04tolava09 as before but now neither are matching. In fact, the raycast doesn't intersect any of these, I'm effectively standing on nothing. So that's our second bug, a problem with the raycasting. This turns out to be a precision issue as the ray is being cast from the exact point of the collision into the ground and it will thus sometimes be treated as slightly below the ground. By hoisting the starting position of the ray out of the ground by 0.1m in the opposite direction (and lengthening the max distance from 0.3 to 0.4) it intersects both lava04tolava09 and lava09 as expected.
So let's put it all together and try out both fixes and see how it plays:
No more invisible lava, and no more lava you can stand in. Note that the few remaining gaps aren't dead zones as before, they're likely the prawn skipping across the landscape. You can see that when I walk through one gap near the end that it does register as lava.
Comments
Yep. The invisible lava in the cave entrance to the precursor thermal plant blew up my prawn on my real playthrough which is why I've been curious for a while what the exact cause was. It's that lava04tolava09 material tripping up the kludge that scans the material name for "lava09" (lava09 is the real deal). I've been over there and tested it and these changes fix it. I'm kludging their kludge by changing it to IndexOf("lava09 ") == 0 rather than Contains("lava09").
I'd post a fixed DLL for you guys to play with but I'm on experimental right now. Maybe I'll update in a bit and make one.
bgfixlava: enables the fixes (default)
bgunfixlava: disables the fixes
bgshowlava: draws green spikes for raycasts that are considered to be lava
bghidelava: disables them (default)
These aren't global or saved, so if you create a new prawn or whatever you might need to issue them again.
https://trello.com/c/zIZ31xK6/1214-52328-phantom-lava-lukewarm-lava-in-ilz-possible-fixes-thanks-belgarel
@Quiet_Blowfish You still have to type out what you wanted to say at the end of the quote. Now, click the little gear that appears at the top-right (next to "Awesome") of posts that you author, and then click "Edit". Fix your post up, and then click "Save Comment", at the lower-right.
Oh is /that/ why that happens? It sure can be difficult to tell what's a hotspot and what isn't. This explains a lot.
Saw a lot of code check ins mentioning this on 9/17 but hadn't had time to check.
Great news! thanks!