Jump to content

  • Log In with Google      Sign In   
  • Create Account


Terrain Tiled Texture Issues


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
18 replies to this topic

#1 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 22 April 2013 - 10:47 PM

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?

Attached Thumbnails

  • tiling.png


Sponsor:

#2 dxdude   Members   -  Reputation: 110

Like
0Likes
Like

Posted 23 April 2013 - 12:47 AM

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.



#3 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 23 April 2013 - 02:34 AM

I see that the the article is focusing on Unreal Engine, any pure D3D9 article?



#4 kauna   Crossbones+   -  Reputation: 2156

Like
1Likes
Like

Posted 23 April 2013 - 06:09 AM

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!



#5 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 23 April 2013 - 07:59 AM

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


#6 belfegor   Crossbones+   -  Reputation: 2362

Like
1Likes
Like

Posted 23 April 2013 - 08:10 AM

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, 23 April 2013 - 08:15 AM.


#7 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 23 April 2013 - 08:22 AM

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.


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#8 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 25 April 2013 - 08:15 PM

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



#9 belfegor   Crossbones+   -  Reputation: 2362

Like
1Likes
Like

Posted 26 April 2013 - 02:50 AM

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


#10 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 26 April 2013 - 05:15 AM

I notice few problems:

 

1. Something weird appear on the terrain:

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:

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?



#11 belfegor   Crossbones+   -  Reputation: 2362

Like
0Likes
Like

Posted 26 April 2013 - 06:16 AM

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, 26 April 2013 - 06:17 AM.


#12 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 26 April 2013 - 06:28 AM

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?



#13 belfegor   Crossbones+   -  Reputation: 2362

Like
0Likes
Like

Posted 26 April 2013 - 06:36 AM

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



#14 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 26 April 2013 - 07:09 AM

Okay, finally before we end this post

 

Here is the detail texture that I'm using:

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:

detailp.png

 

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



#15 belfegor   Crossbones+   -  Reputation: 2362

Like
1Likes
Like

Posted 26 April 2013 - 07:25 AM

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.



#16 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 26 April 2013 - 07:32 AM

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.



#17 belfegor   Crossbones+   -  Reputation: 2362

Like
1Likes
Like

Posted 26 April 2013 - 07:39 AM

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, 26 April 2013 - 07:44 AM.


#18 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 26 April 2013 - 08:32 AM

Greatly appreciate your persistent help.
 
Thank you!


#19 Norman Barrows   Crossbones+   -  Reputation: 1845

Like
0Likes
Like

Posted 27 April 2013 - 09:04 AM

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. 


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS