Sign in to follow this  

[SOLVED] Weird Texture transparency problem

This topic is 2637 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Am upgrading my old texture loader code to include features like batching , multitextures,etc. But when i got it working i found a weird texture transparency problem which you can see in following screenshots -

image1

image2

I can see things behind the terrain surface as if texture is transparent.
I haven't loaded any transparent texture or used alpha blending or anything like that. Am loading a single texture from bmp file for whole terrain, treid other formats like jpg,tga,etc too.
I am implementing this in D3D9 Fixed funtion pipeline for now.

Here are my sampler & renderstates -




chd3d->pd3dDevice->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
chd3d->pd3dDevice->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
chd3d->pd3dDevice->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);

chd3d->pd3dDevice->SetRenderState(D3DRS_LIGHTING,false);
chd3d->pd3dDevice->SetRenderState(D3DRS_ZENABLE,true);
chd3d->pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,false);

chd3d->pd3dDevice->SetTexture(0,texture->getTexture());
chd3d->pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);

chd3d->pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
chd3d->pd3dDevice->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0);
chd3d->pd3dDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
//disabling second texture till i fix this problem






Can anyone please tell me why these textures are being rendered in this weird manner ?

[Edited by - Chetanhl on September 28, 2010 3:36:12 PM]

Share this post


Link to post
Share on other sites
Looks like a z-buffer problem to me. What format is your depth-stencil buffer, and what are your near and far clip planes set to (Near clip should be as far as possible, and definitely not 0)?

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Looks like a z-buffer problem to me. What format is your depth-stencil buffer, and what are your near and far clip planes set to (Near clip should be as far as possible, and definitely not 0)?


Thanks for quick reply.

I have treid these two Depth Stencil Formats -
D3DFMT_D24S8
D3DFMT_D24X8

I also tried few near and far clip plane values. But Currently -

Near Plane - 1.0f
Far Plane - 5000.0f

D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI/2.0f, ((float)chd3d->getWidth()/(float)chd3d->getHeight()),
1.0f, 5000.0f);


Forgot to mention earlier, if it matters dimension of terrain is 2048x2048 units.

Share this post


Link to post
Share on other sites
Are you certain that your terrain is seamless? Are you applying some sort of LOD to the mesh that could cause nearer portions to be drawn with different vertices than adjacent but more distant triangles?

Share this post


Link to post
Share on other sites
Is the camera underneath the terrain? If it is then it won't look right unless you reverse D3DRS_CULLMODE (or turn it off).

You could also double check that D3DRS_ZWRITEENABLE is set, but it should be on by default.

Share this post


Link to post
Share on other sites
Quote:
Original post by Adam_42
Is the camera underneath the terrain? If it is then it won't look right unless you reverse D3DRS_CULLMODE (or turn it off).

You could also double check that D3DRS_ZWRITEENABLE is set, but it should be on by default.


Am not disabling Z-Buffer or ZWriteEnable at any point.

Camera is also above the terrain. I have implemented flexible camera class i can change it to FPS, 3rd Person, FreeLook etc and result is same as far as weird textures are concerned.

I am just trying to do following 3 things for now -

1)Load Height Map and make terrain
- Tried both my new subgrid code and a single grid for whole terrain
- Rendering terain as indexed trianglestrip
2) Load its texture
3) Render the terrain with texture

Am loading texture using this function if it helps -
D3DXCreateTextureFromFile()

But dunno what's wrong this time. I actually recoded the whole terrain class (using single grid for terrain approach) even then this problem persists.

I checked wireframe mode all tringles are being rendered without any probs.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Are you certain that your terrain is seamless? Are you applying some sort of LOD to the mesh that could cause nearer portions to be drawn with different vertices than adjacent but more distant triangles?


No am not performing any LOD for now infact the whole point of this recoding terrain loader was to include those things (subgrids,lod etc) and take it to shaders. But am stuck at first step only. -__-

For now I am just trying to achive 3 basic things mentioned in above post.

Share this post


Link to post
Share on other sites

This topic is 2637 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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