1. Stuck or having problems creating your mod?

Unsolved Underwater tunnels

Discussion in 'Mod Support' started by swift502, Jun 28, 2019.

  1. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Hi,

    I'm porting the GTA 3 map, and there's underwater car and subway tunnels.
    How should I go about making them work?



    According to this post from 2016 it's not possible? https://www.beamng.com/threads/polaris-island.22770/#post-339767
    But it's a huge part of the map. So really want to have them in it. I'm wondering:

    1. Is there really not way to create zones where the water plane doesn't render and doesn't affect the simulation?
    2. I've looked at water blocks, but it will take a lot of tediously and carefully placed water blocks to cover the edges of the islands, line them up so they won't overlap. But then they won't even extend infinitely, and their depth is limited, so it doesn't seem like a great solution at all.
    3. Would it maybe be possible to "hide" the water plane when I'm entering the tunnels, and display it again when I go out? Some kind of triggers?
    4. @LuisAntonRebollo Is there any way to get the shaders used on water planes and blocks and apply them to my own geometry, so I could just "fake" water by having a simple flat plane mesh with holes for each respective island, having a nice water material? Can I have the water surface without any other water properties?

    Thanks for an advice.
     
    #1 swift502, Jun 28, 2019
    Last edited: Jun 28, 2019
  2. bob.blunderton

    bob.blunderton
    Expand Collapse

    Joined:
    Apr 3, 2015
    Messages:
    2,189
    I second this. I need this for my custom city map Los Injurus. The reason you can't have tunnels under water in this simulation is this. It would be nice if you could have 'subtract water' zones where it does not render and does not affect simulation inside of them, and be able to link multiple zones (which I believe is already possible) for tunnels that are not straight.
    Coding would just have to have an argument that would ask 'okay we hit water, is this a zone, is subtract water checked if this is a zone?'
    Could use colored glass to see 'into' the water block from the sides without any additional rendering tricks from inside the tunnel, say like the Stunt Race FX map with the underwater tunnel. This would not be common.
     
    #2 bob.blunderton, Jul 8, 2019
    Last edited: Jul 8, 2019
  3. thomatoes50

    thomatoes50
    Expand Collapse
    Staff Member

    Joined:
    Jan 31, 2013
    Messages:
    624
    You can use Water Block
    And you can control the depth with the Z scale value
     
    • Agree Agree x 1
  4. bob.blunderton

    bob.blunderton
    Expand Collapse

    Joined:
    Apr 3, 2015
    Messages:
    2,189
    Okay Sir, I'll bite. I have a few questions about caveats, however.

    *If using water block, how will I fill the void-space around the map on the 2~3 sides that are ocean (without breaking immersion in some way)?
    *You can only make a water block SO wide or long before it doesn't want to go any bigger, this was an older version limitation, does this still have a limit?
    *How will I match up the water blocks to one another, as this could preclude using waves and such (I've tried this in the past). I could see seams before when I tried this.
    *Water blocks are only square or rectangular, what if the tunnel is not aligned perfectly to North / South or East / West (I could rotate the block, but then I'd have to rotate *ALL* of them, and this could cause an issue if the tunnel exit on the far side is not an exact 90 degrees from the angle of the entrance). Otherwise, water could overlap (Could mask this with surface rocks etc, but this is less optimal in some settings).
    *Do large water blocks fall to the same physics 'trap' (extreme poor performance) as wide rivers do? In my tail of the dragon map, at the north end, there is a section of extremely wide river in a ravine near where the north-end of the roadway is and you must turn around. If you fall in the water (which I tried to discourage with trees, and narrowing it a bit to help FPS), the FPS drops notably. When I had an early beta of this, the river was wider with less flat banks (more water from a wider river) and it brought FPS to <10FPS. Now I fixed MOST of that performance issue by artificially narrowing the river, but there's still questions in the back of my mind about that.

    I ask these things, as it's been a stumbling block for game-engines in the past, but was curious about this game engine to that aspect as it could be a stumbling block for some.
     
  5. thomatoes50

    thomatoes50
    Expand Collapse
    Staff Member

    Joined:
    Jan 31, 2013
    Messages:
    624
    the only thing i'm aware is the performance hit on render (it's a bit worse then sea plane)

    I didn't had any seam issue back in the days (i was using power of 2 everywhere but most probably things may have been broken by now)

    Not sure why the shape of the tunnel is a problem, you can use one plane over the underwater part and try to keep the depth to the highest point of the tunnel
     
  6. bob.blunderton

    bob.blunderton
    Expand Collapse

    Joined:
    Apr 3, 2015
    Messages:
    2,189
    Thank-you for the answers and your time.
    Not quite the way I wanted to go about it. I think for now I will omit underwater tunnels from my design entirely, as it'd be much to cumbersome to water do water blocks on a 11km x 11km map. I also can't afford a performance penalty (especially with my PC on it's last legs, only getting 35fps right now when it should be 70+) right now - though that's not your fault. One too many lightning hits on this SeaSonic power supply, even with our roof grounded to earth, it's 3.3v rail is failing badly...
    So without getting too into that bit, I will thank-you again and will stick with bridges for now, as I'd likely need 100 water blocks to go around the edge of the map - and that's only making the water go out 100~1000 meters from the edge of the map.

    Please add 'air blocks' that over-ride water planes to the list of desired / dreamy features! Things like that (and like tiled terrain!) make the game-engine more desirable to potential developers desiring to use it.
     
  7. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Thanks.

    I guess water blocks will do it. I'll try and see how it looks, especially on the water horizon.

    Now I wish BeamNG was open source so we could go in and do these things you don't consider a priority, whereas it causes us quite some problems. Most of us modders here are programmers or game devs anyways, it would be great to make sure that these things really are so complex that it's better to go with hacky solutions like water blocks. It's especially ironic since all of the shaders, models and textures are already essentially open source and can be examined at will. (I was always curious how many stolen BeamNG car models are being sold online by people who realised they can just be opened in Blender...)

    I understand the rendering part might be difficult to do, but the solution to the simulation part of it seems quite obvious, like bob mentioned.

    I too experienced wave seams, even when I lined up the blocks perfectly and matched all of the parameters.

    Lol :D
     
    #7 swift502, Jul 11, 2019
    Last edited: Jul 11, 2019
  8. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    It's literally always subdivided everywhere. Water plane gets dynamically subdivided to show the waves only under your camera position, but water blocks aren't optimised at all. It'd be insane to use them as an ocean.
    I'm faking the water with a simple mesh. It's gonna look terrible and won't behave like water but who cares I guess.

    Devs, please implement this.
     
  9. Nadeox1

    Nadeox1
    Expand Collapse
    BeamNG.Support
    Staff Member

    Joined:
    Aug 5, 2012
    Messages:
    13,152
    They simply have different use case.
    There's no suitable 'water' type for the use case you are in, and I can't think any way around it that would look good.
    A mesh would ok visually, but physically I'm not sure it would work well, even if you apply a water groundmodel to it.

    And no, water entities are special objects, you cannot use their shaders on any mesh as it will be missing data.
     
  10. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Do you literally have to create a new entity to swap shaders? In Unity you just choose a shader from a dropdown menu. :D

    Interesting, I tried "groundType = "water";" But it doesn't seem to work. I also can't see anything like water in the docs.
     
    #10 swift502, Jul 13, 2019
    Last edited: Jul 13, 2019
  11. bob.blunderton

    bob.blunderton
    Expand Collapse

    Joined:
    Apr 3, 2015
    Messages:
    2,189
    Bethesda's open-world 'Gamebryo' Engine (Elder Scrolls, Fallout 3/NV/4/76) can do a water texture on an object or world-space and the engine just flood-fills all the space directly below it with water (infinite depth), doing all the shader magic automatically.
    It would be super-duper handy if I could assign a texture 'as water' and then at run-time the game engine would just render all the water magically. The only problem with that, is you still couldn't tunnel under it. Now using a mesh object as water would fix this, I'd just have to surround it with water texture so the game engine knew that's where the water went.
    I mean, I can re-shape mesh roads and rivers (just like mesh-roads), and re-shape water blocks... So my next question is, why can't we just define any irregular mesh as a water block, and let the game engine render it as it does water blocks and rivers automatically?
    I also had bad issues with seams as the other poster mentioned when using water blocks to flood-fill an area in sheer numbers. Like Occluders they can only be so big. When you have square miles to cover (example - using Occluders in Roane County was downright a science of patience as they can only be so big!), it can be downright painful or even a complete waste of time due to performance reasons if you have dozens of square miles of lake/ocean/whatever. Water blocks are still good for swimming pools though :)

    Sorry to sound demanding, I'm not trying to be at all. However, that said, if you look at the Los Injurus City Map project, you'll likely see what I am getting at here. This isn't exactly some kid's mod-project made from mom's basement (no offense meant). I am seriously building a whole city in a modular, portable/re-usable fashion, to bring the ability for almost anyone with editor knowledge to make their own city. I have a history of easily exceeding almost any game engine that I've worked on, and is also why I was so eager to get onboard with this simulator early. This way I can help shape things for the better. That is what it's for, right?
    That being said, maybe you'll find a way to do it with 'air blocks' that over-ride water planes/blocks, for example. You could even use 'air blocks' over-top of conveyors + wind inside the block to make the conveyor move the vehicle (or seem like it is moving it). Water can move vehicles, and so can wind. Would even be useful for simulating cross-winds on truck traffic. That does cause accidents you know.

    Just my 2ยข
    --Cheers!
     
  12. Nadeox1

    Nadeox1
    Expand Collapse
    BeamNG.Support
    Staff Member

    Joined:
    Aug 5, 2012
    Messages:
    13,152
    Ok, slow down please :D
    Other engines may have cool features we don't have, but please remember that each engine works and handle entities in their own way.
    Unity, Gamebrio and here all have 'water entities', but each engine still manages them differently from each other.

    The 'water entities' in our engine provide specific data to the water shader that is required for it to work.
    This data is the one you can see in the Object Editor when you select any 'water entity'. That's why they are 'special' entities.
    Static Meshes does not contain these specific data, so it won't work.

    Groundmodels are generally meant to be used on static objects, and they are not meant to be used to replace fluids.
    For example we use them to simulate mud or similar type of terrains. I'm not sure you can get any good result trying to replicate water with them.
    A 'water' groundmodel does not exists, but you can try to get something similar using 'custom groundmodels'
    Even though, you still have other issues to deal with, such as when the car sinks in your mesh as you don't get any 'underwater' effect. Or if the water-plane is above the underwater tunnel, the groundmodel depth can still affect it.
    I don't think groundmodels is a solution for this either.


    PS. WaterBlocks can be a bit more performance hungry, but you can tune the 'GridSize' value for them.
    So you can increase/reduce their polycount as you need.
    I think the best solution right now is to use them, with a high 'GridSize' (ie. lower density grid).
    That will solve the fact that they are not dynamically tessellated like the ocean.
    Disabling reflections can also greatly help.
    About the seams, you can disable the ripple textures eventually, or trying to play with the values until it's less visible.
    Woulds still look better than a mesh IMO.

    It's a missing feature, because we did not have any use-case that required this so far.
    If we made a map that had the same issue, I'm pretty sure we would have developed something in regards.
    Many new features are developed based on what's required/needed.

    Would be a cool feature to have in the future, so I don't want to put a stone on it, but please don't hold your breath on it either.
     
    #12 Nadeox1, Jul 14, 2019
    Last edited: Jul 14, 2019
    • Agree Agree x 1
  13. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Normals or animation properties don't seem to work either on static objects, great. This truly seems to be a modern feature-rich bugless engine.
     
    #13 swift502, Jul 14, 2019
    Last edited: Jul 15, 2019
  14. bob.blunderton

    bob.blunderton
    Expand Collapse

    Joined:
    Apr 3, 2015
    Messages:
    2,189
    It's a great game engine, especially with the 4096 object limit removed in the last year. If you keep the draw call limits in mind, and don't miss breakable props (except the ones you spawn), you can make almost anything (except tunnels under the water plane).
    Animation is done with textures, such as traffic lights, it moves every so often, changing the light phase. You can make scrolling textures, too, like for LED billboards.
    DAE (collada) animation is done on the oil well / derricks on West Coast, so look to those for animation examples. There may be others. Collision is NOT animated, it is static!
    If you need animated collision, it must be a player-spawned object (or in the event of a mission or scenario, script-spawned object). Only JBeamed things have dynamic collision.
    Nadeox has made working garage doors on his desert / mountain map, they work based on proximity with a script. There's also a dynamic lighting system that he made in his VR city.
    I was half tempted to take the SNES Final Fantasy III texture for the ocean and stick it on the ocean as a mesh, to then be able to use tunnels, but I digress, that'd be plagiarism... alas I cannot do that.

    @Nadeox1 I would love to have that feature one day, for now, I guess I'll write that on the wish-list (right under 'tiled terrain') ... Thanks for the write-up though (and for your maps with many examples, I will make use of the scripted night lighting one day - with credit of course).

    --Cheers!
     
  15. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Yeah I meant scrolling textures for the water. Can I make them work? When I check the checkbox I just get a single color on my material. Is it a UV issue, or what do I need to do?
    And why do the normals not work? I plug in a texture but nothing happens.
     
    #15 swift502, Jul 15, 2019
    Last edited: Jul 15, 2019
  16. Nadeox1

    Nadeox1
    Expand Collapse
    BeamNG.Support
    Staff Member

    Joined:
    Aug 5, 2012
    Messages:
    13,152
    Can you provide screenshots of what you are trying to do please?

    Normal Maps do work on static objects, they used extensively on any official level and not only.

    The issue may be within your texture, what format are you using?
    Also note that only Normal Map on layer 0 is accepted. Normal Maps on other layers won't give any effect (despite being the possibility to add them)

    Animated textures are currently broken, it's mentioned here:
    https://www.beamng.com/threads/0-16-discussion-thread.62094/#post-1018863
    They are not used as much in official content.
     
  17. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    36
    Okay normal maps work. My bad, sorry.

    upload_2019-7-15_19-13-6.png
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice