Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Dynamic Terrain (updated, now with downloadable demo)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Dynamic Terrain (updated, now with downloadable demo)

    As of today (19th October 2014) you can find a demo of the project here: http://bit.ly/1wdM19b

    Long story short, I've implemented a dynamic terrain system entirely with UnrealScript. Before I go into details here's a video demonstration:




    The motivation behind it were some questions related to dynamic terrain in the Programming and Unrealscript section here on the forums. This was also one of the first things I wanted to do with UT3 and opened a new thread for it as well. But I was a little bit disappointed when I only got the response it wasn't possible.


    So here's a list of core features, the system is designed so that it is easily extendable:
    • dynamic terrain can be saved and loaded including all deformation applied over the course of the game
    • heightmap can be generated from existing Terrain/Landscape (or procedurally or in any other way you want)
    • heightmap can be modified at runtime/gametime
    • ingame editor tools (brushes) for dynamic terrain modification are available


    Saving and loading is done with BasicSave/LoadObject. There's a brush to raise/lower an area, to add random noise to it, to flatten or to smooth as demonstrated here: UDK - ingame dynamic terrain editor. The diffuse corresponds to the triangle normals which are computed in the Material.

    Dynamic terrain generated based on existing Landscape and some more editing can be seen here: UDK - dynamic terrain from Landscape.

    This video shows a more 'realistic' terrain textured procedurally based on height, slope and normal: UDK - WakeIsland2142 using dynamic terrain. Credit for the heightmap goes to DICE, I only converted the one used in the level WakeIsland to g16 format and applied it to a regular terrain which has 1024x1024 patches. The dynamic terrain is again generated from that existing terrain created in the editor.

    The last video related to this shows a custom MaterialFunction-based PNTriangle implementation after the paper linked on the UDN "Curved PN Triangles" by Alex Vlachos, Jörg Peters, Chas Boyd and Jason L. Mitchell which can be found here http://alex.vlachos.com/graphics/CurvedPNTriangles.pdf. And the video: UDK - PNTriangles implementation with MaterialFunctions and MTM_FlatTessellation.


    The requirements for this to work are DX11 and UDK July 2012 Beta2, Changelist 1340247 (and later, although not tested).


    I hope you like it, cheers
    UE

    Note: Since only 1 video was allowed in the message I've only linked the others. You can also find them on my youtube here or via the signature below. Subscribe, like and favorite

    #2
    Update: New Video, custom tessellation with dynamic terrain

    I've finally found the time to fix the flickering issue and improve the procedural texturing by smoothing the normals used to blend between the different textures.

    For tessellation, the same approach as in the PNTriangles with MaterialFunctions video applies here. In addition to that I also implemented a custom flat tessellation mode.

    So here is the video:

    Comment


      #3
      This is pretty amazing, and I have to admit I didn't think it was possible with Unrealscript. (Nice to be proven wrong)

      A question that came to mind while watching: Is collision being updated as you change things or are you using per-poly collision?

      Comment


        #4
        Originally posted by isathar View Post
        A question that came to mind while watching: Is collision being updated as you change things or are you using per-poly collision?
        Unfortunately per-poly collision doesn't work with StaticMeshes deformed by WorldDisplacement. Or actually it does but it does not take the deformation into account for the collision. So if I were to use that here, the collision would just be a simple plane at height 0 of the terrain. So the player doesn't collide with the deformed geometry they can see.

        Instead I am building and updating the required collision manually with seperate StaticMeshes that use per-poly collision. Collision is built for patches that were not required last tick but are required this tick, patches are updated when they are still required and the underlying heightmap value changed for that patch (any of the four corners/vertices). If a patch is no longer required, collision for it is removed again, otherwise alot of individual patches needed collision and performance would be absolutely terrible.

        Comment


          #5
          I was trying to think of ways you would have accomplished this, and wasn't sure if you had found a way to somehow modify LandscapeComponents in-game or using static meshes. Seeing that it's done in the material with WorldDisplacement makes this even more impressive in my opinion.
          Thanks for the explanation, by the way. I spent a while last night trying to figure out how you went about creating collision on the terrain like your videos demonstrate and came up with nothing.

          Comment


            #6
            You're welcome, I'm just glad you like it and open to answer any other questions anyone may have.


            Maybe my explanation wasn't precise enough before, it's not exclusively done with WorldDisplacement if that's what you thought now. The heightmap is still computed in Unrealscript and then written to textures that are passed to the MaterialInstance via parameters. This material is applied to one or more StaticMeshes that are visible and do not collide. Only the last step of reading from these textures, converting that into a height value and applying that as the WorldDisplacement (for "None" tessellation mode) is done in the Material. Both Flat and PN tessellation modes not only require the height of the current vertex but the other two vertices of that triangle as well. Even worse the normals of the vertices are necessary for PN but aren't available by default and so they also have to be computed in the material. The same holds for "FlatNormals" if that mode is used.

            The collision has nothing to do with that though, when a patch is determined to be required for collision (for example because a player, vehicle, projectile, etc. is near it, it just reads the height values for that patch from the datastructure in Unrealscript and creates/updates the invisible, per-poly colliding StaticMeshes accordingly. This happens entirely in Unrealscript.


            The older video showing my PNTriangles implementation does not have any related Unrealscript in the background but also no collision. The heightmap for that demonstration is computed in the material. The WorldPosition x/y feeds a sine node each which basically replaces the heightmap generation in Unrealscript.

            Comment


              #7
              Hi UnrealEverything,

              Truly amazing work m8. Its nice to see terrain still being used opposed to landscape. Id be very interested to try and get this
              working but it is way beyond my programming skills. NO RETURN uses Terrains, all be it with few patches.

              If you get chance download the game and maybe suggest if you think your system could be implemented in it.
              NO RETURN : http://www.indiedb.com/games/scotland3d

              I had given up on finding a solution and had started to look to voxels for some environment interaction but if
              this works it could be the answer. Have you managed to do anything about foliage in this system. For example
              have you managed to effect foliage layer z values in real time. I presumed the foliage layer was locked and
              you couldn't effect any layer or specific object values after game start.

              I would be very interested to give this a go. Will any source be made available or a basic tutorial for those with
              basic unrealscript knowledge?

              Keep at it as it looks very promising.

              Comment


                #8
                It's very sad that it's using DX11 : (, else i would defintively use it, anyways it's really interesting looking towards using it in UE4, since UE4 it's dx 11 oriented.

                Comment


                  #9
                  Originally posted by Neongho View Post
                  It's very sad that it's using DX11 : (, else i would defintively use it, anyways it's really interesting looking towards using it in UE4, since UE4 it's dx 11 oriented.
                  UE4 also falls back to DX10 if DX11 isn't supported, and can even fall back to OpenGL for (for even WinXP) so I would still not code such a core feature targetting only DX11
                  in any case for UE4 why not code a proper dynamic terrain system?

                  Comment


                    #10
                    UE4 also falls back to DX10 if DX11 isn't supported, and can even fall back to OpenGL for (for even WinXP) so I would still not code such a core feature targetting only DX11
                    in any case for UE4 why not code a proper dynamic terrain system?
                    You mean code it from scratch, and add it to your custom UE4 editor build? hehe... that's hard. " else tell me where would i start if what i understand what you mean it's go code it on the source code of UE4 ".
                    Thanks for that info much relevant hard to find or get for me.

                    Also for techniques like defferred lighting wich is now kind of the replacement of the UE3 dynamic lighting wich is the forward lighting that ue4 mainly did" well atleast that's what the ue4 documentation says" , don't get me wrong maybe i don't understand it, does it work on open GL and DX10 ?

                    What if your project uses dynamic lighting on UE4 and DX10 or OpenGL it's chosen as the rendering libraries, rendere " or whatever", will it still work even if dx 11 ain't working ?

                    Comment


                      #11
                      Originally posted by Chosker View Post
                      UE4 also falls back to DX10 if DX11 isn't supported, and can even fall back to OpenGL for (for even WinXP) so I would still not code such a core feature targetting only DX11 in any case for UE4 why not code a proper dynamic terrain system?
                      That would have been the method of choice but we all know there is no such thing in UDK other than UnrealScript. I was quite surprised by the release of UE4. It felt a bit rushed to me. It wasn't not long after I finished what you can see in the videos.


                      Originally posted by Neongho View Post
                      You mean code it from scratch, and add it to your custom UE4 editor build? hehe... that's hard. " else tell me where would i start if what i understand what you mean it's go code it on the source code of UE4 ".
                      Thanks for that info much relevant hard to find or get for me.

                      Also for techniques like defferred lighting wich is now kind of the replacement of the UE3 dynamic lighting wich is the forward lighting that ue4 mainly did" well atleast that's what the ue4 documentation says" , don't get me wrong maybe i don't understand it, does it work on open GL and DX10 ?

                      What if your project uses dynamic lighting on UE4 and DX10 or OpenGL it's chosen as the rendering libraries, rendere " or whatever", will it still work even if dx 11 ain't working ?
                      Sure why should deferred lighting not work with DX10 and/or Open GL? At least deferred shading is around for quite some time now. From what I can tell, the "only" limitation is the number of render targets that you can render to at the same time. The german wikipedia article claims that because of this limitation at least "Shader Model 3.0 (Open GL since Version 2, DirectX since Version 9)" must be supported.

                      I believe there are a few attempts to do such a thing with UE4, not necessarily implemented from scratch but modifications for Landscape to allow for dynamic control. Try the search on the other forum


                      Originally posted by Scotland3d View Post
                      Hi UnrealEverything,

                      Truly amazing work m8. Its nice to see terrain still being used opposed to landscape. Id be very interested to try and get this
                      working but it is way beyond my programming skills. NO RETURN uses Terrains, all be it with few patches.

                      If you get chance download the game and maybe suggest if you think your system could be implemented in it.
                      NO RETURN : http://www.indiedb.com/games/scotland3d

                      I had given up on finding a solution and had started to look to voxels for some environment interaction but if
                      this works it could be the answer. Have you managed to do anything about foliage in this system. For example
                      have you managed to effect foliage layer z values in real time. I presumed the foliage layer was locked and
                      you couldn't effect any layer or specific object values after game start.

                      I would be very interested to give this a go. Will any source be made available or a basic tutorial for those with
                      basic unrealscript knowledge?

                      Keep at it as it looks very promising.
                      Thanks for the kind words. It is compatible to both Terrain and Landscape. Or you can edit/create the dynamic terrains heightmap from scratch ingame. Which ever way you prefer as you can see in the videos.
                      The system works well for Terrains because of the simple grid structure for the vertices of the terrainmesh. Any other shaped mesh would require some more work. Since it's completely implemented in UnrealScript and replaces Terrain and/or Landscape you'd have to implement a custom foliage system as well which destroys trees as the terrain gets deformed. A tutorial, especially a basic one is out of question. You can probably understand that I don't just want to give code and assets away like that, especially since nobody else seems to have achieved this very thing. This doesn't mean that I am not willing to share it at all. I don't really like the idea of not being able to control where it will end up though. I could try to create a small demo from what I show in my videos. So you can test and evaluate whether it is still off interest for you.

                      I'll try to update with a demo as soon as possible.

                      Comment


                        #12
                        People who can't do this will want your work if you post it, if you don't share it then you are merely using the forums for shameless self-promotion.
                        You have been here for 6 years, you don't need to do the latter, your work speaks for itself, but you should accept that people will want this if they cannot do it themselves, if you withhold it, they will no longer show an interest.

                        - It's a natural double -edge from development that we all face at one time. Unless you seek profit or employment i suggest you make it open source.

                        - maybe consider creative commons for a starting point, at least then you can share it and stick it under the umbrella of intellectual property + you have us (the community) to back you up if anybody tries to steal your work or profit of it.
                        That's what being a community is and should be ...
                        Tis a cool project

                        Comment


                          #13
                          People who can't do this will want your work if you post it, if you don't share it then you are merely using the forums for shameless self-promotion.
                          You have been here for 6 years, you don't need to do the latter, your work speaks for itself, but you should accept that people will want this if they cannot do it themselves, if you withhold it, they will no longer show an interest.

                          - It's a natural double -edge from development that we all face at one time. Unless you seek profit or employment i suggest you make it open source.

                          - maybe consider creative commons for a starting point, at least then you can share it and stick it under the umbrella of intellectual property + you have us (the community) to back you up if anybody tries to steal your work or profit of it.
                          That's what being a community is and should be ...
                          Tis a cool project
                          So what is finally the key on this kind of dynamic terrain wich, is using for what i can see" tessallation "? nope?, you need to create a kind of weird material and change it's parameters in runtime then assign it to the landscape ?

                          Comment


                            #14
                            @UnrealEverything
                            Kudos! Is your work applicable to UE4 and procedural game generation in general? (Beyond Construction Scripts and in-Editor Procedural utilities in UE4 at present)

                            If the release of 'No Man's Sky' next year is a game changer, then maybe just maybe this type of functionality will show up on Epic's radar. Sadly at the moment it isn't a priority. Procedural helps level the playing field between smaller teams and Triple-AAA studios, because doing everything statically all of the time just takes too long with a small team...

                            Comment


                              #15
                              Originally posted by TKBS View Post
                              People who can't do this will want your work if you post it, if you don't share it then you are merely using the forums for shameless self-promotion.
                              [...]
                              - It's a natural double -edge from development that we all face at one time. Unless you seek profit or employment i suggest you make it open source.
                              sadly the days seem over, when threads like this served as inspiration for others, but it wasn't always like this. there used to be plenty of examples where it would inspire others and these others would ask for the info, then the OP would explain the rough general method in a pretty non-technical language. in fact my blog has quite a few posts like this

                              but like you suggest, posts like this nowadays feel like showing off and only evoke "give me, I want" replies. this is especially obvious in the UE4 forums

                              curious thing, art forums don't suffer from this. people look for critiques and comments and the community helps (or the post goes unnoticed), but all the community gets in return for their help is eyecandy and inspiration

                              Comment

                              Working...
                              X