Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Advanced Terrain....updating the terrain texture on-the-fly?

Author
Message
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 1st Nov 2012 21:24
Is there a tutorial out there that can show me how to actively "paint" on a terrain surface with a smaller texture, such as painting a road line on the terrain with the mouse as well as saving that updated terrain texture to be reloaded for next time?

Is this even possible?

Thanks

Home is where my souped-up computer is...
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Nov 2012 01:45
Why not just use a modelling application?

JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 2nd Nov 2012 03:07
because a modeling application would have to run seperately from the project I am working on.....my project calls for changing the terrain texture while the program is running.....think of it as painting a small gravel image on a much larger grass landscape.

Home is where my souped-up computer is...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Nov 2012 13:13 Edited at: 2nd Nov 2012 13:15
You could try using a single "gravel map" image for the whole terrain and update that continually. Then use the blend mapping commands. For example, you might start with a blank map with zero alpha then paint your small gravel image to the relevant parts of that and change the alpha of those parts to full alpha. Then use one of the blend mapping options to blend using the alpha (I think one of the modes does that - if not I can help you get it working).

The only problem with that approach is that you might need a high resolution image. A better solution might be to do the same thing but only update the blending part of the image and use black/white rather full/no alpha and use that to blend between your original terrain texture and the gravel texture. Since you're only updating a few pixels in the blending map per sync it should perform fast enough. Resolution could still be a problem though.

A more heavy weight solution could use a separate blending map for each limb of the terrain. That would overcome the resolution issue but would need many blending maps - up to one per limb. Of course, if your path or road occurs on only a few limbs then you won't need too many maps. The details would be messy compared to the single blend map image method.
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 3rd Nov 2012 05:15
Gandalf, I don't really need a super-high res image for the gravel path, but I would need a good tutorial on how to use the blendmapping command. I can't really find a good forum thread on this. Also can blend-mapping display different terrains at different altitudes?

Thanks again-

Home is where my souped-up computer is...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Nov 2012 12:33 Edited at: 3rd Nov 2012 13:20
Quote: "but I would need a good tutorial on how to use the blendmapping command"


Yes, one is needed - especially for the undocumented extended features which you'll probably need. Have a look at the "Lerping Textures" project in your DBPro Project/Snippets folder.

That snippet shows how you can blend two textures according to the values of a third blending image - ideal for combining a single terrain texture with a path texture for example. Unfortunately the extra entries required for the blend mapping command are not clearly explained - but if you carefully experiment with the code you'll probably get what you want. Blending several textures that way rapidly becomes awkward or impossible and a shader solution is probably simplest. You're constrained by the DX9 limit of 8 textures which doesn't leave much scope for blending several textures - each new terrain texture will need a new blending map texture unless I've missed something in the DX9 docs.

With this approach it might be possible to blend up to four textures using corresponding blend maps, i.e. three for the main terrain textures and one for the road texture. The limit might be a bit less if some of the eight available blending stages need to be used for blending the results of earlier stages. I won't be sure till I try though.

With a shader you can reduce the number of textures required by storing up to four blend maps in a single blending texture, i.e. one in each colour channel. You still have the overall limit of 8 textures per limb though. Since that limit applies per limb your terrain could use more than 8 textures overall as long as any given limb stays within the 8 limit. The details will be a bit messy but could be very effective. As an extreme cae you might be able to design your terrain so that no limb uses more than two terrain textures.

Anyway, enough for now. Have a look at the LerpingTextures snippet and see how you get on.

[I posted an example a while back which used several blending stages. I'll edit this post with the link later.]

Edit Here's the link. As it happens I've shown how to add a road in one of the demos - there's a screenshot a few posts down that thread.

blend mapped terrains
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Nov 2012 18:09
OK, tried to put my money where my mouth is.

Here's a "simple" new demo showing you one way of combining four textures using blend maps and then applying lighting. This is similar to my earlier demo but I've made changes to the code to make it a bit easier to see what's going on. I've added a few comments.

Notice in particular how the blend maps are in a particular sequence. You could use a succession of three blend maps based on an initial heightmap and a final road blend map for your roads. There are probably other ways of doing this.
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 4th Nov 2012 03:16
love the demo you provided, it's very close to what I am looking for. Is there a command to add to the program that can let me alpha blend the different textures togeather instead of being a sharp transition to the next texture?


Also, Lets say I placed a pavement road model on the surface of the road like in a city simulation, I would like add a dirt contour on the edges of the road on the terrain while the programs is running.

How would I place the alpha blended dirt texture at specific co-ordinates on the terrain while the program is running?

No need to rush on this, just seeing what is possible. So far I'm hopeful with the results.

Home is where my souped-up computer is...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 4th Nov 2012 04:30
GG, I found a dark basic program on youtube that seems to answer all my questions I have posted here. Just search at youtube the phrase "Extended Terrain XYZ Open Source" and you'll find it....it's a great demo if you haven't seen it yet.

Home is where my souped-up computer is...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Nov 2012 13:08
Sounds good.

Regarding your question about sharp transitions, there's no need for the blending textures to be black and white - just blur the edges a bit so you get a gradual transition from black to white.

Login to post a reply

Server time is: 2026-07-11 03:55:44
Your offset time is: 2026-07-11 03:55:44