Sign in to follow this  
Followers 0
Medo Mex

Terrain Tiled Texture Issues

18 posts in this topic

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?

0

Share this post


Link to post
Share on other sites

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!

1

Share this post


Link to post
Share on other sites

@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 );
0

Share this post


Link to post
Share on other sites
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:

trianglepick-2013-04-23-.png

 

Without:

trianglepick-2013-04-23-.png

Edited by belfegor
1

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

@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?

0

Share this post


Link to post
Share on other sites

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...
1

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

I don't see what is the problem on first image, might be same as second. When you draw something with some states enabled you might want them to be disabled for other things that you render afterwards. Without seeing some code it is hard to tell where did you messed up.

 

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?

Seriously? You can not expect one to solve all your problems?

Maybe its time for you to experiment and research on your own, don't you think?

Edited by belfegor
0

Share this post


Link to post
Share on other sites

Seriously? You can not expect one to solve all your problems?

Maybe its time for you to experiment and research on your own, don't you think?

 

I have been doing research for awhile, I wouldn't be able to accomplish all of that if I didn't.

 

I think a bump map can be applied by multiplying another texture in Pixel Shader? Am I right?

0

Share this post


Link to post
Share on other sites

Its not just multiply, there is a bunch of other things that must be set to "enable bump mapping".

0

Share this post


Link to post
Share on other sites

Okay, finally before we end this post

 

Here is the detail texture that I'm using:

[attachment=15240:Detail.jpg]

 

 

Code for scaling detail map and others textures:

D3DXMatrixScaling(&texScale, 20.0f, 20.0f, 20.0f);
D3DXMatrixScaling(&detailScale, 2000.0f, 2000.0f, 2000.0f); // ***** If I used a smaller value, I would get a blurry quality *****

The results:

[attachment=15241:detailp.png]

 

As you can see, the detail map tiling is noticeable, what's your advise to improve that?

0

Share this post


Link to post
Share on other sites

To reduce tiling "noticeability"

1. Partition your terrain mesh into multiple pieces (be careful with texcoords at "borders"), each with its own blendmap and/or detailmap

2. Add grass, buildings, trees, rocks...

3. Use different materials/shaders

...

 

img01.jpg

 

img02.jpg

 

You might want to subdivide it more then shown on image.

1

Share this post


Link to post
Share on other sites

Isn't there any way to do that without creating more than one terrain?

 

I only want to be working on one single blending map.

0

Share this post


Link to post
Share on other sites

I see you have huge terrain, so with one blend map you then need very high resolution texture for result to be somewhat acceptable, apart some other issue that will occur. All in all i would not recommend that approach.

When you partition terrain mesh you also partition blend map into multiple textures that tile/repeat are "connected" seamlessly, i don't see problem with this.

 

There is probably other solutions, but i didn't research much about terrain rendering so i would not know.

Edited by belfegor
1

Share this post


Link to post
Share on other sites

i use a very different approach and get very good results.

 

the ground is drawn one 10 x 10 quad at a time.  a "pattern map" says which quad gets which texture. with just 4 tileable textures, i can get really nice results. no seams, no moire' patterns, no blending, no shaders, just fixed function pipeline. 

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0