Jump to content

  • Log In with Google      Sign In   
  • Create Account

Chunked LOD + texture splatting?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 September 2012 - 05:34 AM

I want my terrain to have more than four texture splats but i'm not sure how to do it. I know that i can divide my terrain into chunks (already done) and set for each chunk 4 splats so that way different chunks can have different textures. But that doesn't work with far away chunks which can be very large (covering 256km squared, represented by a 64x64 chunk), and so likely to have more than four splats itself.

Any ideas on how to approach this?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

Sponsor:

#2 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 22 September 2012 - 06:47 AM

Could you give some more details about your splat limit of 4 and how you are implementing the blend weights (I'm assuming textures)? At a guess, I'm assuming your 4 splat limit is tied to the colour channels of a weight texture that you bind for a given set of chunks and bind the different material textures to the 4 texture units of your splatting shader to pull their weights from the relevent colour channels. Does this sound about right?

By rigidly sticking to your 4 texture splatting limit you're going to have issues. For example, you could bind the most prominent textures that cover the largest area of a given chunk for LOD but then of course you'll have issues with textures popping into view. One way to rectify this would be to have intermediatory transition bands that mix between the different LOD texture sets based on distance from the viewer but then of course you'd need to splat more than 4 textures. Without knowing your implementation and constraints it's difficult to know what to suggest.

#3 L. Spiro   Crossbones+   -  Reputation: 14236

Like
0Likes
Like

Posted 22 September 2012 - 06:59 AM

How are you “mapping” your splats?
One option is to use a second pass just for the splats, in which case you don’t really need to worry about anything.

Another option is to use a routine that is specific to your terrain shaders, however as long as you keep the splat textures in the same slots for each LOD, I see no reason why the splats would not behave the same, except that they adjust “level of detail” (higher and lower resolutions) per-chunk.


If you are using a system other than these, you will need to explain it, because normally these are the main ways of tackling this obstacle, and both ways results in “acceptable” splats.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#4 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 September 2012 - 07:00 AM

Yes that's how i'm doing the splatting. I set 4 splat maps and an alpha map with weights in the RGBA channels for every chunk.

I considered assigning a priority to textures for far chunks but that would cause popping like you said.

Edit: @L. Spiro: I'm not sure how in the first option i wouldn't have to worry about anything? Do you mean use more than one alphamap per chunk?

Edited by Waaayoff, 22 September 2012 - 07:03 AM.

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#5 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 22 September 2012 - 07:11 AM

You could store the weights for each chunk of a given size in an array texture and dynamically loop to splat an arbitrary number of textures. For each chunk, you'd pass the number of textures required (edit: i.e. the number of loop iterations), along with the array texture element and colour mask (a 4D vector with the colour channel to be sampled set to 1 and the rest set to zero) edit: for each texture. Multiply the colour mask by the rgba weight sample and sum the resulting components to get the weight for a given texture. The performance might be sketchy on older hardware, especially if the max number of textures for any given chunk is quite high.

Edited by GeneralQuery, 22 September 2012 - 07:15 AM.


#6 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 September 2012 - 07:26 AM

So basically just add more alpha maps/weight channels?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#7 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 22 September 2012 - 07:31 AM

So basically just add more alpha maps/weight channels?


If you want to splat more than 4 textures for a given point on the terrain mesh then yes, unless you bypass the blend weight textures altogether and algorithmically decide what textures should be splatted onto a given point or compress multiple weights into a given colour channel. The former will restrict direct artistic control, however, unless you use your existing weight textrues for this purpose and use these as the artistic "paintable" blend weights.

#8 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 September 2012 - 07:37 AM

I'm painting the terrain in my editor so no procedural stuff. I guess i'll just add more channels then.

As a side not, wouldn't it be better performance wise to use splatting only on chunks closer to the camera and some other technique on farther ones?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#9 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 22 September 2012 - 07:44 AM

I'm painting the terrain in my editor so no procedural stuff. I guess i'll just add more channels then.

As a side not, wouldn't it be better performance wise to use splatting only on chunks closer to the camera and some other technique on farther ones?

Texture splatting is an insalenly efficient technique on modern hardware, it's basically few texture samples and LERPs per fragment. You could bake a low resolution colour texture based on your splat weights for distance stuff but I'm not convinced it's worth the time, effort and resources for marginal performance gains (if any at all, or even worse perforance!).

Edit: a common technique for texture splatting is to sample low and hi res textures, with the former being used for distant geometry. You then overlay said hi-res texture onto the low res texture for fragments within a set distance from the viewer. You'd need a transition band for this, though, otherwise there'd be a noticble circular band where the low and hi res fragments meet.

Edited by GeneralQuery, 22 September 2012 - 07:46 AM.


#10 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 September 2012 - 08:10 AM

I'll stick to texture splatting then.

One last question. I'm not sure what the colour mask is used for?
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#11 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 22 September 2012 - 08:36 AM

I'll stick to texture splatting then.

One last question. I'm not sure what the colour mask is used for?


If you have a splatting shader that has 4 texture slots for 4 texture materials but any given chunk can have any 4 textures from a set of 8 that you bind dynamically, you need a means of ensuring that the correct colour channel is sampled for an arbitrary material texture.

E.g. let's say that you have a blend weight texture array of 2 elements containing the first 4 and second 4 splat weightings for the 8 materials. If grass resides in the green channel of the second element texture then you'd pass the elemend index and colour mask for that material as a uniform for your splatting shader. Eg:


Vector4 maskGrass(0.0, 0.0, 1.0, 0.0); // Mask out the red, blue and alpha colour channels, leaving only the green channel
UInt idxGrass = 1; // 2nd element of weight array texture

SomeAPI.SetShaderUniforms(rgbaMask = maskGrass, texElement = idxGrass);

// shader code

vec3 uvCoords = vec3(FragCoords, texElement);

vec4 w= sampler2DArray(Weights, uvCoords) * rgbaMask; // Will leave us with the vector [0, 0, green, 0]

float weight = w.x + w.y + w.z + w.w; // Will leave us with just the green channel

lerp(a, b, weight); // splat our textures using the calculated blend weight for this material


That way you can send only the materials you need to the shader (which, of course, could be submitted in any order).

If you're hard coding your texture splatting, i.e. it will splat 8 textures regardless of how many are needed, then you do not need to do this.

Edited by GeneralQuery, 22 September 2012 - 08:39 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS