Probably, your ColorTextureSampler
using point filtering (D3DTEXF_POINT
). Use either D3DTEXF_LINEAR
or D3DTEXF_ANISOTROPIC
to acheve desired interpolation effect.
I'm not very familiar with SlimDX 9, but you've got the idea.
BTW, nice illustration =)
Update 1 Result in your comment below seems appropriate to your code. Looks like to get desired effect you must change overall approach. It is not complete solution for you, but there is how we make it in plain 3D terrains:
- Every vertex has 1 pair (u, v) of texure coodrinates
- You have n textures to sample into (T1, T2, T3, ..., Tn) that represents different layers of terrain: sand, grass, rock, etc.
- You have mask texture(s) n channels in total, that stores blending coefficients for each texture T in its channels:
R
channel holds alpha for T1,G
channel for T2,B
for T3, ... etc. - In pixel shader you sampling your layer textures as usual, and get color values
float4 val1, val2, val3
, ... - Then you sampling masks texture(s) for corresponding blend coefficients and get
float blend1, blend2, blend3, ...
- Then you applying some kind of blending algorith, for example simple linear interpolation:
float4 terrainColor = lerp( val1, val2, blend1 ); terrainColor = lerp( terrainColor, val3, blend2); terrainColor = lerp( terrainColor, ..., blendN );
For example if your T1 is a grass, and you have a big grass field in a middle of your map, you will wave a big red field in the middle.
This algorithm is a bit slow, because of much texture sampling, but simple to implement, gives good visual results and most flexible. You can use not only mask as blend coefficients, but any values: for example height (sample more snow in mountain peaks, rock in mountains, dirt in low ground), slope (rock on steep, grass on flat), even fixed values, etc. Or mix up all of that. Also, you can vary a blending: use built-in lerp
or something more complicated (warning! this example is stupid):
float4 terrainColor = val1 * val2 * blend1 + val2 * val3 * blend2;
terrainColor = saturate(terrainColor);
Playing with blend algo is the most interesting part of this aproach. And you can find many-many techniques in google.
Not sure, but hope it helps! Happy coding! =)