# Texture splatting

This topic is 3964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I have implemented texture splatting for my terrain (at least I tried to;) This is how it looks now: Solid: Wireframe: In the application I have 3 layers: One basis layer (the sand texture), layer1 (the gras texture) and layer2 (the brownish rock texture). For layer1 and layer2 I defined a height range, where each layer is active: layer1: min=0, max=10, avg=5 layer: min=10, max=30, avg=25 So this means layer1 is active between 0 and 10 units. The average is at 5 units. I automatically calculate the alphamap (R=alpha for layer1,G=alpha for layer2) for my heightmap with this algorithm: 1) I create an alpha texture with the dimension of my heightmap (so if I have a 100x100 vertices heightmap I create a 100x100 alphamap. 1 Texel for each vertex) 2) I loop through all texels and check, if the corresponding vertex is between one of the two height ranges. For example if a vertex has a height of 2.5 it is in layer1. To get the alpha value for that texel (=vertex) I make an interpolation from min (=0) to avg (=1) and again to (max=0). So a height of 2.5 would be an alpha value of 0.5, a height of 5 would be alpha=1 and height of 7.5 would be 0.5 again (so its increasing from min to avg and decreases from avg to max). Now I have two problems: 1) Obviously I dont have "smooth" layer bands over my mountains (the green layer looks "edged". I think it has to do that my triangles are relatively huge and my alphamap only stores 1 texel for each vertex. But I have no idea how I should increase the alphamap resolution. For example how should I create an alphamap of 200x200 for a 100x100 vertices terrain? Every second texel has no corresponding vertex and I cant calculate the alpha values. Or is there a better solution to get "smoother" layers? 2) In the screenshot actually I wanted to have a smooth transition from gras to rock (gras from 0 to 10 and rock from 10 to 30). But with my method I interpolate linear and so at the start and end of a new layer my alpha values are 0 (and slowly increase to 1 if they reach avg). Is there a simple solution to this? Maybe an exponential interpolation (so that the alpha value is fast at an value of 1)? Thanks for all answers!

##### Share on other sites
Use a texture for the alphamap instead of vertex values. You'll get more alpha values per triangle and you'll be able to more easily control the smoothness (simple gaussian blur).

##### Share on other sites
Uhm, did you even read my posting?

I have written that I create a alpha texture with the size of the vertex terrain grid and every texel is based on the corresponding vertex height.

Now I have solved problem 2, so there is only problem 1) left:

As you can see I dont have a "ring like" transition from gras to rock and you can see the hard edges of the triangles. I think the reason is that the triangle vertices are "skewed" and so left and right neighbours can get different alpha values because they have different heights.
Anyone else got this problem? Should I try to make my terrain grid more regular? Or shoudl I tweak my alpha texture? :/

##### Share on other sites
Then double your alpha map resolution and perform a simple averaging blur across the map. That will smooth out the edges.

##### Share on other sites
he is right, or you could move your computations to pixel shader. just pass position or something from vertex shader and it will get interpolated, and you can compute height there.

##### Share on other sites
also with texture approach you could implement painting on terrain, which is very nice but a bit of work

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013759
×