Solved Need help setting up the "roads_tutorial_v2" blender file.

Discussion in 'Mod Support' started by DePains, Sep 26, 2018.

  1. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Hello everyone,

    I'm currently trying to do a new map. The first one is unpublished : it's a mess, because I've done the roads in a weird way. So for the new one, I want to make things properly and use LJFHutch tutorial on making heightmap for roads in Blender.

    Reading the tutorials (https://www.beamng.com/threads/tutorial-adding-heightmap-roads-using-blender.16356/, https://www.beamng.com/threads/tutorial-adding-heightmap-roads-with-blender-v2.39903/ and https://www.beamng.com/threads/tutorial-map-in-a-month.49287/) did not help with everything.

    Surely that's just because I'm such a noob with Blender. I tried to apply this to my first map, didn't make it work and ended up with an unpublished mod because I did not ask for help.


    So, here I am. Actual questions are in bold for those of you in a hurry.

    I've made my terrain heightmap in L3DT. Then I downloaded the "roads_tutorial_v2" folder, replaced the "height_source.png" file with my heightmap (converted from BMP to PNG with photoshop). Then I open the add_roads_blender.blend file. I find my rendered (as in 3D) heightmap as Plane.004. Preview layer shows me LJFHutch's map.

    Then I want to change the scale, because LJFHutch's map is set to 120m of height while mine is supposed to be 4100m. Checking "SCALE" and "SCALE.001" objects in the "add_road' layer to change it puzzled me. I am guessing I have to change the "scale z" value to 4100, but SCALE and SCALE.001 have different x and y "scale" values.
    Is "scale z" of "SCALE" object the value to tweak altitude scale ?
    If so, why are the x and y "scale" value different for SCALE and SCALE.001 ?

    Then, I re-generated the preview according to my heightmap : "add_road" layer, "rander layers" tab --> select all (roads, RenderLayer, ambient_occlusion and vertical_scale). Then Render --> render image. Save and update textures.

    And the magic happened :
    Capturedcran43.png
    The map seems flattened compare to what I get in BeamNG but if I import the generated heightmap to BeamNG things look OK. But the output .png heightmap is only 1024*1024. As are every "terrain sized" object in the blend file, including the Plane.004 resulting from my L3DT heightmap.
    The latter is 2048*2048, and imported in BeamNG with 3m/pixel and 4100m altitude. Yes, huge and tall. So question :
    What do I need to change in Blender to import my L3DT heightmap in 2048 [and then export in 2048 or 4096] ?

    Thank you !

    EDIT
    :

    1 - I found how to change resolution export.

    2 - Don't know if the scale thing is working but things are working so...

    3 - Found how to adjust .blend for my map : increase render area to 4096*4096*4100 ("extents" in the render_terrain_ao_etc layer), increase Plane.004 size to 4096*4096*4100, adjust camera settings in layer "add_road" (position z = 4100 ; then in camera tab > ortho scale = 4096 ; clippind end = 4600 ; depth of field distance = 4100). Now I can see my level with it's proportions in blender (which for road building while controlling slope is useful...). By the way, to see the map while placing the spline, I click/dropped road1, road1_002 or road1_003 on the "render_terrain_ao_etc" layer. That made I "linked" copy (not sure of the term) that when modified see its changes applied to it's sister spline in the "add_road" layer.
    Is there a better way to see the map while placing the splines ?

    Thank you !
     
    #1 DePains, Sep 26, 2018
    Last edited: Oct 2, 2018
  2. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Back again here with need of help with a non planed use of the roads_tutorial_v2 blend file...

    I am using it to mould a 3D model of a track (cleaned of building, bushes and other non surface mesh as much as I could) onto an heightmap of the corresponding area from terrain.party :
    Capturedcran47.png Capturedcran48.png

    Everything has been adapted to the track and it's size. And it's working pretty well. As seen on the first capture I have painted the entire model with the "roadmat_dirt" material and then selected the track and assigned it the "roadmat".

    And the splat maps are bugged :
    asphalt2.png Image0097.png

    The asphalt mat is missing a segment, replaced by dirt. I could easily paint the "small" missing part but I can't find why the dirt is replacing the asphalt for this segment only.

    Any idea ?
     
  3. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    I think your 3d model have holes because you can see the orange/yellow outline of blender in the middle of the model.
    I think you need to merge some vertex and check that all normal point the same way.
    upload_2018-10-2_15-43-3.png

    About the missing part, did you check if you can see Z fighting when you move the view camera around
     
  4. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105

    Thanks for the reply thomatoes50.

    For the holes no issue here,that came along when I deleted the non surface meshes. It's just putting me the input heightmap height in those case. I just have to smooth it in BeamNG.
    Normals are all up, no differences for the road faces when the splat stops.

    And what do you mean by "Z fighting" ?
     
  5. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    as the road and the terrain mesh are at the same height or really close, when the camera is really far away some artifacts can happen

    In this example it in the same height so even close this glitch happen.


    In your case you need to check there is no face bellow the road or that it's far away enough
     
    • Like Like x 1
  6. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Ah ok, thanks for that. Very clear and nice video !

    But I might have already checked Z fighting :
    Capturedcran53.png
    This is not far from where the asphalt splat stops being outputted, the view is from beneath the model. That's a bridge the track is going onto. --> I'll clean this and every mesh beneath the road.
    I selected those there and change their material to "roadmat". When I re-rendered the scene, the splat map was the same.
    But as far as Z fighting would go here, wouldn't that affect only the concerned faces (as opposed to here, an entire segment) ?

    And fun unrelated fact, I just draw the decalroad in BeamNG and :
    Capturedcran52.png
    The decalroad texture (because I forgot the about max lenght thing) stops approximatively 10m from were the asphalt splat stops... o_O

    Edited for clarity
     
    #6 DePains, Oct 2, 2018
    Last edited: Oct 2, 2018
  7. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    I'm not sure i understood everything, you can try to clean the mesh to remove all the face below the road
    or try to modify the nodes so it priorities the road over the ground
     
    • Agree Agree x 1
  8. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Thanks, I'll try those tomorrow and report.
     
  9. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Well, I went the lazy way and assign a new material (no setting) to the mesh that had the "roadmat_dirt". The asphalt splat was then complete.

    As I will do the other splats (grass, forest and city grounds) manually from a OSM overview, I'll do the dirt splat by expending the asphalt splat and then subtracting it to its expended version.

    Thanks again thomatoes50 !
     
    • Like Like x 1
  10. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Hum, "new" issue.

    After having moulded the track onto the terrain from terrain.party, I obviously wanted to put some roads through roads_tutorial_V2.

    Yesterday I tried to do that directly with the outputted heightmap including the moulded track and drawing a spline following the terrain. And I got a variable vertical offset, the road being above the terrain. I though it might just be my settings, something not at [0,0,0] or the scale not being set up properly. And the track did loose smoothness.

    So, today I took the original tutorial archive and restarted on the heightmap from terrain.party without the track (I'll mould it at the end), and re-set it. And got the same result :
    Image0002.png Capturedcran54.png

    I obviously have a scaling issue between the two render layers. The 3D model of the track is 1:1 (7011*6918 in blender units) so I wanted to work on my 8*8 km terrain in blender as a 8000*8000 plane. I have checked that the heightmap max and min altitude are respectively above and below the track max and min altitude. So final altitude range is the one given by the terrain.party readme file : 478m. Could someone check what I've changed in the original .blend file :

    1 - changed height_source.png with my own heightmap
    2 - open .blend, set "Plane.004" dimensions to real size : 8000*8000 and adjust its "Displace" modifier strength to obtain real z dimension, so 478. I end up with Plane.004 scale being [15.625,15.625,1]
    3 - adjust "extents" dimensions accordingly : 8000*8000*600 (scale = [4000,4000,300])
    4 - move "camera" to z=600, change ortho scale to 8000, focus to 600, clipping to 600
    5 - change "SCALE" z dimension to 600 (visually the two scale objects look like they are actually bounding the z of the "extents")

    And then I create a spline in the "add_road" layer, drop it on the "render_terrain_ao_etc" to draw it while seeing the terrain (I'm deleting it when I'm done drawing). I assign the spline to "Plane.002" modifiers as I want it in asphalt. Check the road and render.

    The spline, its plane and the terrain plane are at [0,0,0]. The spline and it's plane have a scale of [1,1,1].

    In the included "roads_tutorial_v2.zip" file, "road1_001" and "Plane.002" are my road.

    What am I missing ?

    Thank you !
     

    Attached Files:

  11. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    I realised that by increasing the z dimension of the "SCALE" object I changed its scale from [256,1,1] to [256,1,5] and thought that might be the source of my current issue. I reverted the z scale of "SCALE" to 1 and in edit mode I increased its z dimension to 600 while keeping the scale at [256,1,1].

    This did not solve my error. I then realised that "SCALE.001" plane is actually at z=120, went in edit mode and moved it to 600. Same result.
     
  12. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Meanwhile, searching how to make a minimap, I activate AI path on the track and recorded the AI doing a lap (sorry for the bad quality, win10 screen recorder...).



    10:02.765 for 20.8 Km, not bad !

    As for me :


    I'd say 8:15.500ish as the chrono did not stop.
     
    #12 DePains, Oct 5, 2018
    Last edited: Oct 7, 2018
    • Like Like x 1
  13. DePains

    DePains
    Expand Collapse

    Joined:
    Nov 27, 2017
    Messages:
    105
    Well, I finally put the finger on it.

    I just had to normalize the heightmap from terrain.party. I realised that when I add 2 small roads in the "add_roads" layer/scene. One at z=0 and one at z=600. I endend up with a dark and a white spot. As expected and that showed me that the issue wasn't on that side but on the terrain's. My 277m to 734m terrain was a grayscale going from 2664 to 31726 (16 bits).

    Rather than "calculating" the altitudes corresponding to the white and the dark points for this heightmap to adjust the grayscale of the road through the "SCALE" objects, I decided to normalize the heightmap, putting the 277m as black and 734 as white (and not greyish).

    Then instead of 600 as a value for z-positions of camera, scale, extents, etc... I use 457m, the actual altitude range of my map (and not 478m as I stated before). I adjusted the "strengh" of the displace modifier of Plane.004 to 457, replaced the now rather off road and... voilĂ .
    Capturedcran58.png

    The only issue I have here is to correctly normalize the heightmap. I've done this quickly in photoshop (image>adjustement>equalize) and it clipped the white and the black. Obviously. SO I have to find a better way. But this thread is solved.

    EDIT
    So I have found a better way of normalizing the heightmap : imagemagick (win and unix) with its "-auto-level" command. By the way, that software is also the simplest way of getting min and max pixels values for a heightmap among other (all ?) informations for the inputted image (-identify -verbose). See below the comparison between the original, the photoshop "equalize" and the imagemagick "auto-level".
    1.png 2.png 3.png

    Cheers
     
    #13 DePains, Oct 8, 2018
    Last edited: Oct 9, 2018
    • Like Like x 3
  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