Hi,
I use the HLSL function Texture2D.Load do retrieve texture information.
These informations are 3 Texture Indicies, 3 Texture blend weights and 3 texture tiling vaulues.
Now if 2 different texture indicies are blended which have different texture tiling values there are some kind of gridlines showing and i don´t know why.
Here are some images showing the problem:
![terrainbuggitter.PNG](http://dl.dropbox.com/u/3714191/Kompex/terrainbuggitter.PNG)
And from a nearer perspective:
![terrainbuggitternah.PNG](http://dl.dropbox.com/u/3714191/Kompex/terrainbuggitternah.PNG)
Here is the HLSL code:
Texture2DArray<float4> SplatTextureArray : register(t1);
Texture2D<float4> BlendTexture : register(t2);
float2 GetBlendValAndWorldTextureSize(float val)
{
float2 ret;
ret.x = frac(val) * 10; // blend weight auslesen
ret.y = 512.f / floor(val); // UV Multiplier um die Wiederholung der Textur zu bestimmen
return ret;
}
uint3 GetIndices(uint indices)
{
uint3 retval;
retval.x = indices & 256;
retval.y = (indices>>8) & 256;
retval.z = (indices>>16) & 256;
return retval;
}
float4 GetColour(int3 index, SamplerState splattexturarraystate, float2 uv)
{
float4 blendinfo = BlendTexture.Load(index & 255);
uint3 indices = GetIndices((uint)blendinfo.w);
float2 blend = GetBlendValAndWorldTextureSize(blendinfo[0]);
float4 result = SplatTextureArray.Sample(splattexturarraystate, float3(uv * blend.y, indices[0]));
[unroll]
for(uint i = 1; i < 3; ++i)
{
blend = GetBlendValAndWorldTextureSize(blendinfo[i]);
if(blend.x)
{
result = lerp(result, SplatTextureArray.Sample(splattexturarraystate, float3(uv * blend.y, indices[i])), blend.x);
}
}
return result;
}
float4 TerrainFragmentShader(TerrainVSOutput inputval, uniform SamplerState splattexturarraystate : TEXUNIT1) : SV_TARGET
{
float2 uv = inputval.sPosition.xz / 511;
int3 index = int3((int2)(frac(inputval.sTexCoords) * 256), 0);
float4 tl = GetColour(index, splattexturarraystate, uv);
float4 tr = GetColour(index + int3(1, 0, 0), splattexturarraystate, uv);
float4 bl = GetColour(index + int3(0, 1, 0), splattexturarraystate, uv);
float4 br = GetColour(index + int3(1, 1, 0), splattexturarraystate, uv);
float2 lf = frac(inputval.sTexCoords * 256);
float4 result = lerp(lerp(tl, tr, lf.x), lerp(bl, br, lf.x), lf.y);
return result;
}
If i take out the "* blend.y" part it doesn´t show up but then i can´t use different tiling values for the textures.
The value in blend.y should be right, because i already tested if it got the right value and colored it red if it isn´t(which shows nothing) if i test it the error doesn´t show up btw.
If someone has an idea or knows what the problem it, your help would be appreciated.
Replies
Thanks for mentioning that it´s a mipping issue, we got it to work
We just did this: