The tiled texture can be well noticed even I'm using "mirror tiling" which make the terrain look unrealistic.
How do I make the terrain look realistic?
The tiled texture can be well noticed even I'm using "mirror tiling" which make the terrain look unrealistic.
How do I make the terrain look realistic?
There are some ways you can improved your detail texturing.
Look here for some nice description how to avoid tiling effect.
http://udn.epicgames.com/Three/TerrainAdvancedTextures.html
In my terrain render iam using slope based methode combined with a noise map and uv mixing to give more random effect to the slope based methode.
You could use a level-of-detail texture which covers bigger area (less tiling) and then modulate/overlay it with a detail texture which covers smaller area (more tiling). This should give somewhat more pleasing result.
Cheers!
@kauna: Can you give idea how to do so?
I tried something like the following but couldn't get it to work:
tex1->SetLOD(10.0f);
device->SetTexture(0, tex1);
device->SetTexture(1, tex2);
d3ddev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
d3ddev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3ddev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
d3ddev->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
d3ddev->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3ddev->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
d3d9device->SetTexture(0, detailTex);
d3d9device->SetTexture(1, terr1Tex);
d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
D3DXMATRIX detailTrans, tex1Trans;
D3DXMatrixScaling(&detailTrans, 16.f, 16.f, 1.f);
D3DXMatrixScaling(&tex1Trans, 1.f, 1.f, 1.f);
d3d9device->SetTransform( D3DTS_TEXTURE0, &detailTrans );
d3d9device->SetTransform( D3DTS_TEXTURE1, &tex1Trans );
d3d9device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
d3d9device->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
d3d9device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
d3d9device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
d3d9device->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
d3d9device->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
d3d9device->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
d3d9device->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
d3d9device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
d3d9device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3d9device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3d9device->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
d3d9device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
d3d9device->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
d3d9device->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
TerrMesh->DrawSubset(0);
d3d9device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
d3d9device->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
With detail:
Without:
Did you even search these forums ?
There have been hundreds of threads about texturing terrain in last decade here, on GameDev.net
I can assure you they contain all the information you need with all examples you need.
@belfegor: That works well and give much better results, now, I want to apply this with my current terrain with texture splatting Pixel Shader.
How do I apply the above to my current 4 textures that I'm splatting with Pixel Shader?
This is just a multiplied with detailmap texture (with scaled texcoords). I don't know how do you want this?
Add detail texture
...
d3d9device->SetTexture(5, detailTex);
// set texcoord scale
D3DXMATRIX blendScale, texScale, detailScale;
D3DXMatrixScaling(&blendScale, 1.f, 1.f, 1.f);
D3DXMatrixScaling(&detailScale, 16.f, 16.f, 1.f); // you probably want to set higher scale on detail
D3DXMatrixScaling(&texScale, 2.f, 2.f, 1.f); // then on other texs
...
d3d9device->SetTransform( D3DTS_TEXTURE5, &detailScale );
This will multiply detail with all texs
...
texld r0, t0 // scale 1
texld r1, t1 // scale 2
texld r2, t2 // scale 2
texld r3, t3 // scale 2
texld r4, t4 // scale 2
texld r5, t5 // scale 16
mul r1, r1, r0.x // multiply 1st tex with blendmap (red channel) and store result in 1st
lrp r2, r0.y, r2, r1 // lerp 2nd with 1st (blendmap green channel as factor) and store in 2nd
lrp r3, r0.z, r3, r2 // lerp 3rd with 2nd (blendmap blue channel as factor) and store in 3rd
lrp r0, r0.w, r4, r3 // lerp 4th with 3rd (blendmap alpha channel as factor) and store result in blendmap
mul r0, r5, r0 // multiply detail...
I notice few problems:
1. Something weird appear on the terrain:
[attachment=15238:weird.png]
2. The terrain appears like it's transparent, I added a sphere that intersect the terrain and I can see the bottom half of the sphere:
[attachment=15239:weird2.png]
One more thing that I want to add is 'bump map', how should update the Pixel Shader to add bump map as the 6th texture?