Chunked LOD + texture splatting?

Started by
9 comments, last by GeneralQuery 11 years, 7 months ago

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.

This topic is closed to new replies.

Advertisement