Sign in to follow this  

Custom world editor?

Recommended Posts

I am looking to recreate òne real-world geographic region (say egypt or greece) and I need to create a region-map of sorts. I need to place down terrain features like rivers, woods, mountains, sea etc and other metadata (climate, temperature and so on) and export it to some resource format that I can read in the engine. Important to note I am not looking for any randomized world gen tools since I already know how the end result should look like.

 

I have two ideas in mind;

 

1. Roll my own world editor to do all this - I have a feeling it would be alot of work

2. Use some existing tool for this. It might save some time.

 

Has anyone any experience with making your own editor like this? What about some practical issues like how coupled should the editor be with the engine? should the editor use the engine for rendering?

 

 

Share this post


Link to post
Share on other sites
Have you looked at the UE4 terrain editing facilities and World editing tools plus level and asset streaming?

It seems it's all written already for you there and will save you a ton of work...

Look on YouTube for the UE4 kite demo. This was all hand rolled terrain and lots of AAA assets and is created with only the built in tools.

Hope this is helpful :)

Share this post


Link to post
Share on other sites

Have you looked at the UE4 terrain editing facilities and World editing tools plus level and asset streaming?

It seems it's all written already for you there and will save you a ton of work...

Look on YouTube for the UE4 kite demo. This was all hand rolled terrain and lots of AAA assets and is created with only the built in tools.

Hope this is helpful :)

 

Is this for use only in UE4? Can you export it and use it in your own engine?

Share this post


Link to post
Share on other sites

Have you looked at the UE4 terrain editing facilities and World editing tools plus level and asset streaming?
It seems it's all written already for you there and will save you a ton of work...
Look on YouTube for the UE4 kite demo. This was all hand rolled terrain and lots of AAA assets and is created with only the built in tools.
Hope this is helpful :)

 
Is this for use only in UE4? Can you export it and use it in your own engine?

Well there is source for the entire engine, so you could read the source and see how it's stored. It will probably be a lot of work though...

Share this post


Link to post
Share on other sites

For more free maps you could use an image editor to define various map layers, that is what games like Europa Universalis use.

 

I suppose that could be an option. Using Adobe photoshop to generate map layers and then use that to render terrain in the engine?

Share this post


Link to post
Share on other sites

For more free maps you could use an image editor to define various map layers, that is what games like Europa Universalis use.

 
I suppose that could be an option. Using Adobe photoshop to generate map layers and then use that to render terrain in the engine?

Yes, the simplest way to do this would be (IMHO) using a heightmap defined in a grayscale image, and setting a water level at a specific height below which everything is underwater.

Would this be simple enough to work with your workflow?

Share this post


Link to post
Share on other sites

KaiserJohan, on 30 Dec 2016 - 4:44 PM, said: Brain, on 30 Dec 2016 - 4:35 PM, said: Have you looked at the UE4 terrain editing facilities and World editing tools plus level and asset streaming? It seems it's all written already for you there and will save you a ton of work... Look on YouTube for the UE4 kite demo. This was all hand rolled terrain and lots of AAA assets and is created with only the built in tools. Hope this is helpful :) Is this for use only in UE4? Can you export it and use it in your own engine? Well there is source for the entire engine, so you could read the source and see how it's stored. It will probably be a lot of work though...

 

Wouldn't that be illegal?

Most engines do not allow taking their tools to create assets for your own engine. They would not see a cent for their work.

Share this post


Link to post
Share on other sites
This is a grey area I think, but to be sure, check the EULA.

UE4 supports exporting a terrain heightmap as fbx, and an fbx is an fbx, there is nothing identifying it came from UE4 once you put it through your own toolchain.

Technically your final game isn't using UE4 so it would be hard to prove you even used their tools to create it (this thread not withstanding of course!). I wouldn't really recommend this though.

If you were unsure you could speak to them about it and worst case you'd have to pay them royalties the same as if you'd used their engine.

Is there any reason you're using a home made engine btw?

Share this post


Link to post
Share on other sites

Is there any reason you're using a home made engine btw?

 

I'm doing research on unsolved problems, no actual game. A large engine would make this just harder. Maybe i'll create a plugin for those if i'm successful.

 

But even if it would be different, i think it's very good lots of AAA studios and indies still develop their own engines.

Share this post


Link to post
Share on other sites

Actually as I've already made a terrain editor in my engine (re-worked multiple times - increasing its feature set), I will follow up here with some notes. When you're talking about terrain engine you're talking actually about multiple systems - terrain geometry placement/creation, terrain geometry editing, terrain texturing and also (if you want to support it) grass support. In each of these systems you need to consider and decide what are you going to support, therefore also determining how you will do the rendering/processing in the end.

 

Terrain Geometry Placement/Creation

 

Has the largest impact on your terrain system, as in this stage you are going to decide what kind of modelling and respectively texturing methods you're going to use. So, first you decide whether you're going to use Voxel terrain representation, Height Map terrain representation or Polygon terrain. Are you going to support "infinite" terrain through chunks, or just separated terrain blocks (that could possibly be transformed/rotated/scaled)?

 

Terrain Geometry Editing

 

Based on your decision you want to implement:

  • Voxel editing - add or remove voxel (or groups of voxels using some kind of brush)
  • Heightmap editing - elevate up and down (again based on some kind of brush)
  • Polymodelling - basic polygonal modelling operations (loft, extrude, cut, subdivide, etc. etc.)

Heightmap editing or Voxel editing is probably easier here compared to polymodelling.

 

Terrain Texturing

 

Based on your geometry editing you probably want (for these 2):

  • Heightmap - texture splatting, so again using brushes you modify splat map and therefore paint different textures on the surface
  • Heightmap - virtual texturing, using one very large texture for whole terrain is an option, although probably a bit more difficult to implement than splatting
  • Heightmap - procedural texturing, is an option; although you will most likely want to combine it with details (F.e. procedural texture generation + virtual texturing works quite well)
  • Polymodelling - projection based texturing, using texture projection you write into terrain texture

Note that for polymodelling (compared to height map) you will need some automatic unwrap generator - to generate texture coordinates for the geometry.

 

Grass Placement

 

Is more advanced topic - I will followup only on height mapped version here (although there are ways to do so on polygon and voxel-based terrain), using a binary mask (0 = black = no grass model, 1 = white = grass model) you distribute grass models over the whole terrain. And again you can use brushes to add/remove grass on the terrain

 

In short conclusion - if you want to build your own terrain editing tools, you have a big advantage of having total control over your terrain creation. I'd suggest going for height maps + texture splatting, as they are very easy to implement and also quite useful. If you are interested in any stage (details + I could even post some code) feel free to ask, the subject as a whole is just way too big (and too spread) to be covered in single forum post.

Share this post


Link to post
Share on other sites

Actually as I've already made a terrain editor in my engine (re-worked multiple times - increasing its feature set), I will follow up here with some notes. When you're talking about terrain engine you're talking actually about multiple systems - terrain geometry placement/creation, terrain geometry editing, terrain texturing and also (if you want to support it) grass support. In each of these systems you need to consider and decide what are you going to support, therefore also determining how you will do the rendering/processing in the end.

 

Terrain Geometry Placement/Creation

 

Has the largest impact on your terrain system, as in this stage you are going to decide what kind of modelling and respectively texturing methods you're going to use. So, first you decide whether you're going to use Voxel terrain representation, Height Map terrain representation or Polygon terrain. Are you going to support "infinite" terrain through chunks, or just separated terrain blocks (that could possibly be transformed/rotated/scaled)?

 

Terrain Geometry Editing

 

Based on your decision you want to implement:

  • Voxel editing - add or remove voxel (or groups of voxels using some kind of brush)
  • Heightmap editing - elevate up and down (again based on some kind of brush)
  • Polymodelling - basic polygonal modelling operations (loft, extrude, cut, subdivide, etc. etc.)

Heightmap editing or Voxel editing is probably easier here compared to polymodelling.

 

Terrain Texturing

 

Based on your geometry editing you probably want (for these 2):

  • Heightmap - texture splatting, so again using brushes you modify splat map and therefore paint different textures on the surface
  • Heightmap - virtual texturing, using one very large texture for whole terrain is an option, although probably a bit more difficult to implement than splatting
  • Heightmap - procedural texturing, is an option; although you will most likely want to combine it with details (F.e. procedural texture generation + virtual texturing works quite well)
  • Polymodelling - projection based texturing, using texture projection you write into terrain texture

Note that for polymodelling (compared to height map) you will need some automatic unwrap generator - to generate texture coordinates for the geometry.

 

Grass Placement

 

Is more advanced topic - I will followup only on height mapped version here (although there are ways to do so on polygon and voxel-based terrain), using a binary mask (0 = black = no grass model, 1 = white = grass model) you distribute grass models over the whole terrain. And again you can use brushes to add/remove grass on the terrain

 

In short conclusion - if you want to build your own terrain editing tools, you have a big advantage of having total control over your terrain creation. I'd suggest going for height maps + texture splatting, as they are very easy to implement and also quite useful. If you are interested in any stage (details + I could even post some code) feel free to ask, the subject as a whole is just way too big (and too spread) to be covered in single forum post.

 

Nice post! I've been thinking about trying out Tiled (http://www.mapeditor.org/) and parse that format in my engine. Like, using it to do the same as EU4 does (build a terrain-map, a height-map for elevation and so on for stuiff like climate)

 

Alternatively, as for just setting up terrain editing tools - where did you start? Did you use some gui lib? How does rendering work inside the editor?

Share this post


Link to post
Share on other sites
Posted (edited)

Some time back I've used a custom UI (which was kind of lacking for editor-like applications - as it supports just some buttons, sliders, etc.), and since then I've touched Gtk+ and it looks like I'll touch either some Windows based widgets again in near future (as I've ported my engine from OpenGL to D3D12), or I might as well go with Imgui (but you should also be fine with Cegui for example).

 

I started off with 3D viewport and terrain grid (defined with 2 parameters - size and resolution), the first setup rendered terrain in wireframe. The controls were without GUI - just WASD + mouse movement for flying around, and space pressing switched to edit mode - where you could just WASD around, but mouse was free + clicking left button elevated up, clicking right button elevated down. Using a simple brush. That was the start, and I built on top of this. Also, upon exiting the height map was saved (into simple file - resolution and then single float for every pixel). So the first prototype I made was even without any GUI library.

 

In terms of pseudo code:

void Render()
{
    SetupCamera();
    RenderTerrain();
}

void Process()
{
    if (editMode)
    {
        ProcessCameraMovement(false);
        ProcessEditing();
    }
    else
    {
        ProcessCameraMovement(true);
    }
}

void ProcessEditing()
{
    if (Mouse::LeftButton || Mouse::RightButton)
    {
        Ray r = Ray(camera, Mouse::Position.x, Mouse::Position.y);
        IntersectResult res = Scene::Trace(r);
        if (res.hit)
        {
            int2 coords = FromWorldToHeightMapCoordinates(res.position);
            heightMap.applyBrush(coords.x, coords.y, Mouse::LeftButton ? 1.0f : -1.0f);
        }
    }
}

Where 'applyBrush' does something like:

for (i = -brushSize; i <= brushSize; i++)
{
    for (j = -brushSize; j <= brushSize; j++)
    {
        float dx = i / (float)brushSize;
        float dy = j / (float)brushSize;
        float strength = max(0.0f, 1.0f - sqrt(dx * dx + dy * dy)) * direction;
        this.elevateAt(x + i, y + j, strength);
    }
}

Synchronize();

Where 'x', 'y' and 'direction' are arguments of that function. Of course the strength can be a function, or you could technically read a texture there for example (so that it would indeed be a brush). Actually you can do both - use a function and multiply a brush texture with that (might be the best idea - with option of disabling either).

 

Note, the 'Synchronize' copies the data hold in RAM into VRAM - through Map/Unmap in my old (GL) case. I'm still not decided how to solve this efficiently in D3D12, but Map/Unmap will work too.

Edited by Vilem Otte

Share this post


Link to post
Share on other sites

Some time back I've used a custom UI (which was kind of lacking for editor-like applications - as it supports just some buttons, sliders, etc.), and since then I've touched Gtk+ and it looks like I'll touch either some Windows based widgets again in near future (as I've ported my engine from OpenGL to D3D12), or I might as well go with Imgui (but you should also be fine with Cegui for example).

 

I started off with 3D viewport and terrain grid (defined with 2 parameters - size and resolution), the first setup rendered terrain in wireframe. The controls were without GUI - just WASD + mouse movement for flying around, and space pressing switched to edit mode - where you could just WASD around, but mouse was free + clicking left button elevated up, clicking right button elevated down. Using a simple brush. That was the start, and I built on top of this. Also, upon exiting the height map was saved (into simple file - resolution and then single float for every pixel). So the first prototype I made was even without any GUI library.

 

In terms of pseudo code:

void Render()
{
    SetupCamera();
    RenderTerrain();
}

void Process()
{
    if (editMode)
    {
        ProcessCameraMovement(false);
        ProcessEditing();
    }
    else
    {
        ProcessCameraMovement(true);
    }
}

void ProcessEditing()
{
    if (Mouse::LeftButton || Mouse::RightButton)
    {
        Ray r = Ray(camera, Mouse::Position.x, Mouse::Position.y);
        IntersectResult res = Scene::Trace(r);
        if (res.hit)
        {
            int2 coords = FromWorldToHeightMapCoordinates(res.position);
            heightMap.applyBrush(coords.x, coords.y, Mouse::LeftButton ? 1.0f : -1.0f);
        }
    }
}

Where 'applyBrush' does something like:

for (i = -brushSize; i <= brushSize; i++)
{
    for (j = -brushSize; j <= brushSize; j++)
    {
        float dx = i / (float)brushSize;
        float dy = j / (float)brushSize;
        float strength = max(0.0f, 1.0f - sqrt(dx * dx + dy * dy)) * direction;
        this.elevateAt(x + i, y + j, strength);
    }
}

Synchronize();

Where 'x', 'y' and 'direction' are arguments of that function. Of course the strength can be a function, or you could technically read a texture there for example (so that it would indeed be a brush). Actually you can do both - use a function and multiply a brush texture with that (might be the best idea - with option of disabling either).

 

Note, the 'Synchronize' copies the data hold in RAM into VRAM - through Map/Unmap in my old (GL) case. I'm still not decided how to solve this efficiently in D3D12, but Map/Unmap will work too.

 

Great post.

I'm at the point where I extracted world pos successfully, the question is how do I obtain heigthmap coords from that?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this