Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 40% OFF Pavtube DVD Ripper for Mac
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:54

 DVD Ripper with 40% off
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:22

 Get DVD Ripper Wind/Mac + $14 Coupon
  Posted by: VIKIVannessa
  When: 19/04/2014 at 02:02:03

 Backup DVD Escape Plan
  Posted by: Applefly
  When: 17/04/2014 at 06:00:12

 Disney DVDs to MP4
  Posted by: Applefly
  When: 17/04/2014 at 05:56:07

 DVD movies through media streamer
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:25:09

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:20:51

 Blu-ray to Apple ProRes
  Posted by: Applefly
  When: 12/04/2014 at 00:47:46

 HD H.264 MP4 format
  Posted by: Applefly
  When: 12/04/2014 at 00:43:23

 DVD collection to computer
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:13:33

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD Ripper to populate
  Posted by: Applefly
  When: 04/04/2014 at 05:01:35

 kids and family watch DVD
  Posted by: Applefly
  When: 04/04/2014 at 04:59:21

 Blu-ray movie for your lovely kids
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:47:49

 DVD to DNxHD Converter for Mac
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:46:04

 play HD Videos on Galaxy
  Posted by: Applefly
  When: 01/04/2014 at 03:16:39

 video on iPhone 6
  Posted by: Applefly
  When: 01/04/2014 at 03:15:18

 MessageBox
  Posted by: net777
  When: 31/03/2014 at 03:34:55

 Play MVI/MKV/AVI on Galaxy NotePro 12.2
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:30:21




Topic: Terrain Painting



  
Goto parent category
  
Create a new user account


   Terrain Painting
 Poster : Extrakun
 Posts: 34
 Country : Singapore
 City: Singapore

  
Posted by Extrakun on 09/07/2007 at 23:05:32
This is a great tutorial!

Right now, the weight-age of each texture blending is determined by height. But let say I want to let the user be able to define the texture, sort of like painting the texture onto the terrain (like the WC3 Map Editor), how should I go about doing that?
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 20/10/2007 at 14:01:47
It might be kind of hard to do with 4 textures, but I was thinking you could create another colored image to use as the texture weights. You could then set the three different color channels (Red, Green, Blue) to stand for the different texture weights. Thats not really a super way, but it would be fairly easy to implement since we have done most of the code needed to do it already (load an image from a bitmap, read the color data, etc) Sorry I don't have any code to copy paste to try, just theories for now :) -cr125rider
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 13/08/2008 at 06:39:45
I would love to know how to be able to paint different textures on also.

This tutorial has a max of 4 textures that painted using heights. So what about a tutorial on how to allow infinite textures in a terrain painted on using a colormap?

I think people would much prefer a tutorial on how to paint textures onto the terrain (editing a color map) and allowing textures to replace the colors on the color map.
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 13/08/2008 at 15:00:29
Only the power and age of your graphics card is limiting the number of textures you can blend in. Usually, instead of using fixed weights, the weights are stored in a separate image. In each of the 4 components of this image, you can store a weight. Therefore, usually 4 or 8 textures are blended over each other, requiring 5 or 10 total textures.

Using this approach, you can simply edit the color values in your weight maps.
 Poster : Quasar
 Posts: 121
 Country : Australia
 City: Brisbane

  
Posted by Quasar on 13/08/2008 at 16:19:20
This is part of the shader from my Dynamic LOD project: it handles the multi texturing using a blend texture.

HLSL:
    float3 blender = tex2D(BlendSampler, input.TextureUV);
    
    //MultiTexturing
    float RWeight = blender[0];
    float GWeight = blender[1];
    float BWeight = blender[2];    
    float BaseWeight = 1-((RWeight+BWeight+GWeight));
    
    float3 RColour = tex2D(RSampler, input.TextureUV*100/diffuseScale);
    float3 GColour = tex2D(GSampler, input.TextureUV*100/diffuseScale);
    float3 BColour = tex2D(BSampler, input.TextureUV*100/diffuseScale);
    float3 BaseColour = tex2D(BaseSampler, input.TextureUV*100/diffuseScale);
    
    float3 diffuse = (((RColour*RWeight)+(BColour*BWeight)+(GColour*GWeight)+(BaseColour*BaseWeight))/4);


As riemer indicated, you could import a second blend texture, and extend the diffuse equation to make use of it.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 23/08/2008 at 14:48:07
Sorry, you've both lost me.

I understand that age and power of a graphics card limits the number of textures. However do not unstand this blending stuff you guy are talking about here.

As it stands right now my terrain only uses colours, reason this is, is because I am trying to now replace the colour bits with texture bits.

I've created and loaded a colour map, so normally sand is at the very lowest height...However i've painted sand over the middle of the mountain in a blob.

I use...Sand:Blue, Grass:Green, Red:Rock, and White:Snow. Its shows the colours where they should be, but now to replace the colours with textures.

I am fine with sticking to four textures, but it would be great if the four textures can be painted anywhere on any height, stored in a colour map.
 Poster : vToMy
 Posts: 37
 Country : Israel
 City: NA

  
Posted by vToMy on 23/08/2008 at 16:20:51
I see you missed the point of the blend texture. It contains 4 values: RGBA where each value represents the "weight" of the texture that should be... for example a pixel (which represents a vertex) of the color (0,0,1,0) would have a complete sand texture (as sand is blue). a vertex with the color of (0,0.5,0.5,0) is half the weight if sand and half the weight of grass (green).
Pay attention that their sum need to be equal one.
In Quasar's example he didn't use the alpha channel and instead the color channels sum isn't 1. He uses the the equation of (1-sum of all channels) to indicate the base texture weight. Then the color is produced by multiplying the colors of the textures by their weight and summing it. The division by 4 in Quasar's example is for further lighting calculations...
Hope this makes sense.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 24/08/2008 at 09:00:26
Thankyou so much guys, I know understand.

I will get around to coding this up tonight. For now I've got tons of college work to finish off.

Cheers guys!
:-)

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)