Phantom lava and lukewarm lava in ILZ, analysis and fixes

BelgarelBelgarel 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.

Comments

  • 0x6A72320x6A7232 US Join Date: 2016-10-06 Member: 222906Members
    edited September 2017
    @Obraxis ▲ Looks like @Belgarel tracked down the exact cause of a bug and its solution. For future reference, is there any specific dev(s) we should ping for when someone has tracked down the exact cause for a bug and / or fixed it so it can get properly addressed?
  • narfblatnarfblat Utah, USA Join Date: 2016-05-15 Member: 216799Members, Forum Moderators, Forum staff
    I'm guessing there's some of this in the castle, would explain why Prawn gets hurt when there doesn't seem to be lava around.
  • BelgarelBelgarel Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer
    narfblat wrote: »
    I'm guessing there's some of this in the castle

    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.
  • BelgarelBelgarel Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer
    Btw, here's a video of that area you're talking about with and without the fix enabled. You can see the phantom lava damage as I go down the first time with the fixes disabled.

  • BelgarelBelgarel Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer
    Here's a modified Assembly-CSharp.dll (rename without .lava and place in C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed, only use with v52328). It enables these fixes and also a few commands so you can see the difference:

    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.
  • Quiet_BlowfishQuiet_Blowfish Join Date: 2017-09-11 Member: 232955Members
    Belgarel wrote: »
    Here's a modified Assembly-CSharp.dll (rename without .lava and place in C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed, only use with v52328). It enables these fixes and also a few commands so you can see the difference:

    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.

  • 0x6A72320x6A7232 US Join Date: 2016-10-06 Member: 222906Members
    edited September 2017
    Belgarel wrote: »
    < snip >

    @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.
  • elfcrisiselfcrisis Join Date: 2017-05-13 Member: 230466Members
    Belgarel wrote: »
    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").

    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.
  • baronvonsatanbaronvonsatan TX, USA Join Date: 2016-12-01 Member: 224415Members
    I just want to say that I'm in awe that anyone NOT on the dev team could do this. I mean, I understand that the devs do all come from the pool of available programming talent, but it's still amazing to see some of that talent out in the wild (so to speak).
  • BelgarelBelgarel Join Date: 2017-07-03 Member: 231570Members, Subnautica Developer
    The fixes are now in the current experimental build.
  • garathgarath Texas Join Date: 2017-02-08 Member: 227730Members
    Belgarel wrote: »
    The fixes are now in the current experimental build.

    Saw a lot of code check ins mentioning this on 9/17 but hadn't had time to check.


    Great news! thanks!
Sign In or Register to comment.