Sign in to follow this  

Texture splatting

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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