Creating textures on the fly?
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
Creating textures on the fly?
Hi everyone,
I'm trying to figure out how to create terrain textures on the fly for my terrain solution. What I want to be able to do is start with a simple vector shape (i.e. a rectangle) then use mid point displacement to modify it into one of those classic fractal coastline type images, then just map it onto a simple plane (which I'll then also manipulate with a height map) as a texture.
Here is an example of what I mean:
http://polymer.bu.edu/java/java/coastli ... pplet.html
I've been looking at cairographics, GDI and even had a quick look at magiclibrary. It looks like it might be a bit of a long painful journey though, so I thought I'd better check here first in case there was a quicker easier way of doing it that I'd just missed...
I'm trying to figure out how to create terrain textures on the fly for my terrain solution. What I want to be able to do is start with a simple vector shape (i.e. a rectangle) then use mid point displacement to modify it into one of those classic fractal coastline type images, then just map it onto a simple plane (which I'll then also manipulate with a height map) as a texture.
Here is an example of what I mean:
http://polymer.bu.edu/java/java/coastli ... pplet.html
I've been looking at cairographics, GDI and even had a quick look at magiclibrary. It looks like it might be a bit of a long painful journey though, so I thought I'd better check here first in case there was a quicker easier way of doing it that I'd just missed...
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Just take an array of vectors (2d or even 3d) or S3DVertex points right away. Make it large enough for the maximal number of vertices and preallocate those. Then simply Make your displacement for each midpoint iteratively. This should easily get you to the coastline.
Question is how you want to map the heightmap onto the terrain. Do you want to remove those areas, which are marked as sea, or do you want to shrink those such that the coastline can be less coarse? You also have to think about how to get the terrain to the sea-level without too steep slopes. This could happen if you just use a rectangle heightmap which does not know about the coast line.
Question is how you want to map the heightmap onto the terrain. Do you want to remove those areas, which are marked as sea, or do you want to shrink those such that the coastline can be less coarse? You also have to think about how to get the terrain to the sea-level without too steep slopes. This could happen if you just use a rectangle heightmap which does not know about the coast line.
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
Hi Hybrid,
I'm not too worried about the array or the coding to determine all the segments in the mid point displacement (that seems fairly straight forward). The thing I'm strugging with is how to take the resulting vector shape and use it to paint a texture that I can then use for heightmaps and splatting etc.
I've seen that you can get and set individual vertices in a texture, should I learn how to code rasterization of a vector shape natively in irrlicht (to a texture) or would it be smarter to learn how to integrate an external library that already has functions for doing that in it? (or more to the point, which way is most likely to be quickest?)
I'm not too worried about the array or the coding to determine all the segments in the mid point displacement (that seems fairly straight forward). The thing I'm strugging with is how to take the resulting vector shape and use it to paint a texture that I can then use for heightmaps and splatting etc.
I've seen that you can get and set individual vertices in a texture, should I learn how to code rasterization of a vector shape natively in irrlicht (to a texture) or would it be smarter to learn how to integrate an external library that already has functions for doing that in it? (or more to the point, which way is most likely to be quickest?)
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
Woohoo
Been hammering code for a week now and *finally* managed to get some basic output going to show off my fractal islands system. Below is a an animated gif that shows several randomly generated (from a simple square) fractal shapes. Now that I've got the basic system going, the idea is that I can build large maps out of a simple grid of squares, and this will randomize the edges to make it look like (semi) natural coastlines.
Been hammering code for a week now and *finally* managed to get some basic output going to show off my fractal islands system. Below is a an animated gif that shows several randomly generated (from a simple square) fractal shapes. Now that I've got the basic system going, the idea is that I can build large maps out of a simple grid of squares, and this will randomize the edges to make it look like (semi) natural coastlines.
Wow some of those look like parts of New Zealand/Australia
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
2.4?ultramedia wrote:AGG 2.5 is GNU GPL, AGG 2.4 is Modified BSD
Guess which version I used
My company: http://www.kloena.com
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
My blog: http://www.zhieng.com
My co-working space: http://www.deskspace.info
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
Hi. in the first and 2nd rendering it's obvious that the initial shape was a square, there are some artifacts. maybe you could start from a circle.
for the later renders, hm it reminds me of a heightmap and the same result could be produced with a diamond style subdivision for an area, coloring in blue whatever is below value X and in grey whatever is above that. maybe that could give you some ideas.
for the later renders, hm it reminds me of a heightmap and the same result could be produced with a diamond style subdivision for an area, coloring in blue whatever is below value X and in grey whatever is above that. maybe that could give you some ideas.
-
- Posts: 175
- Joined: Wed Dec 20, 2006 12:04 pm
Hi Mirror, yeah the single cell is just a test case. Re squares vs circles - or any other shape for that matter - it's a good point, but there are a bunch of extra things I can do with squares and the way they stack that I can't do with more freeform shapes. For example splitting the continents up into different ecotopes (i.e. mountains, hills, plains, deserts etc), see below for an (old) example diagram:
It also means I only have to generate pseudo random values for the coastal and ecotope borders, instead of the entire surface of the terrain. For the heightmaps inside the various different ecotope masks, I'm just going to use generic tiling bitmaps overlaid at a couple of different scales (or even better, I can patchwork together random bits of generic satellite height maps for a super realistic look). For instance, the dark blocks above might be used as a mask to reveal a multi ridged perlin noise texture to make that part of the terrain high and mountainous, and the lighter blocks might alternate between mostly flat and mildly hilly height maps.
Another benefit of a cubic layout, is how it lets me do simple but effective looking river and road networks (also in the diagram above).
It also means I only have to generate pseudo random values for the coastal and ecotope borders, instead of the entire surface of the terrain. For the heightmaps inside the various different ecotope masks, I'm just going to use generic tiling bitmaps overlaid at a couple of different scales (or even better, I can patchwork together random bits of generic satellite height maps for a super realistic look). For instance, the dark blocks above might be used as a mask to reveal a multi ridged perlin noise texture to make that part of the terrain high and mountainous, and the lighter blocks might alternate between mostly flat and mildly hilly height maps.
Another benefit of a cubic layout, is how it lets me do simple but effective looking river and road networks (also in the diagram above).
Last edited by ultramedia on Thu Jan 13, 2011 11:47 am, edited 1 time in total.