Tiling a heightmap

Started by
18 comments, last by kauna 12 years, 3 months ago
I´ve used a volume texture in .dds format now.
But directx isn´t interpolating between the different textures.
Which filter should i use for interpolating? I tried D3DX_FILTER_LINEAR or D3DX_FILTER_TRIANGLE.
On the attached screenshot you can see what i get.
Advertisement
solved with

m_pd3dDevice->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
m_pd3dDevice->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);


I used mip maps:

m_pd3dDevice->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);

[attachment=6589:terrain_mipmaps.png]
But the problem is that there aren´t created mip maps for every texture.
The mipmaps are an interpolation of all 4 textures and that looks like the attached screen.
I think you should be able to create mip maps for a volume texture in the program you used to create the volume texture.

D3DTEXF_LINEAR Should be correct filtering mode.



It seems that there may be device based limitations on the volume textures. Some devices may not support volume texture mip maps and all blending modes may not be implemented.

It starts to feel like bad idea to use a volume texture.

[color=#000000][size=2]Cheers!

I used Directx Texturing Tool. I can create mip maps but the lower i get in the mip map level the less mip maps are there.
For example:
I use 4 textures and 9 mip map levels:
first level: 4 maps
second level: 2 maps
third level and below: only 1 map. And this is the bug, but how can i improve this?

And this is the bug, but how can i improve this?


Hi, actually I think that this is the expected behavior and one other point against using volume textures for terrain texturing.

I can see that you are using d3d9 level hardware and that you may not use texture arrays. The effect you show on your screen shots may be done easily with separated textures too and you may expand the technique to use texture splatting later for example.

Thank you for your efforts.

Best regards!
Can´t this be done with volume textures? I only want to reduce the flicker of terrain parts far away from the camera when moving. Isn´t there any possibility to remove this?
Should i use geometry shader for this?(I dunno if shader model 3 supports this)

It just had been so easily with a volume texture. :(

Thank you and i hope you can help me!
Should i use geometry shader for this?(I dunno if shader model 3 supports this)[/quote]
No and no.

You can use a mip mapped texture atlas but it's not easy to get right and you'll end up wasting some texture space. Also if you going to use displacement mapping, texture atlas will become really expensive. A multipass technique might be the best choice.
So should i use a vertexshader to determine which 2 textures i should use and set it?
You said a multipass technique should be the best choice. Should i use one for interpolation between dirt&grass, one for interpolation between grass&stone, etc.
Please don´t throw in some names of techniques cause I am not familiar with them, and wikipedia alone doesn´t seem to help me with this.
I know what a multipass technique is, but I don´t know what should this technique do?

Thank you ;)
I hope you´ll explain it to me
In a multi-pass technique you would render one texture per pass with additive blending and use an alpha-map or some other indication to define the alpha value of the pixel drawn. Research texture splatting (kauna already mentioned it), there are a lot of good resources about it.

Btw: You can do the same in a single pass by reading all terrain materials in the same pass. You'll potentially have more texture look-ups this way though.
Using vertex and pixel shaders will give you more freedom about how to manage the blending between textures. I strongly suggest to use them.

Depending on your graphics hardware, you may perform pretty many texture look ups per pixel without loss of performance.For example, at this moment I do something like 14 texture lookups (2 alpha, 4 base texture, 4 detail texture, 4 normal) per pixel in my terrain shader and it doesn't slow down that much.

Simple splatting pixel shader (D3D11) goes something like this (the code won't work directly)

float4 Alpha = Alphatexture.Sample(sampler,Tex.xy); //Read 4 alpha values from a rgba texture

float4 Color1 = Texture1.Sample(sampler,Tex.xy); //read diffuse texture 1
float4 Color2 = Texture2.Sample(sampler,Tex.xy); //read diffuse texture 2
float4 Color3 = Texture3.Sample(sampler,Tex.xy); //read diffuse texture 3
float4 Color4 = Texture4.Sample(sampler,Tex.xy); //read diffuse texture 4

float4 FinalColor = lerp(Color1,Color2,Alpha.r);
FinalColor = lerp(FinalColor,Color3,Alpha.g);
FinalColor = lerp(FinalColor,Color4,Alpha.b);


This code blends 4 textures based on the values stored in the alpha texture. 1 alpha texture is enough for blending 5 texture maps actually.
There is a way to blend 8 textures with 1 RGBA-map, but that's a different story.

Good luck!

This topic is closed to new replies.

Advertisement