Sign in to follow this  
r_bewick

dx9 c++ trackmania style track editor

Recommended Posts

Hi, I am making a racing game track editor similar to trackmanias, so I have a grid and a set of pieces of 3d models of road which I place in a specific order to make a track. My pieces are exactly 50 units wide and long, and 10 units high. The textures on the pieces are completely seamless.

The problem I am having is that when I place the pieces next to eachother, from most camera angles I can see a line between them which does not look good at all (like they overlap or something - but they don't)


The line is actually small black triangles, since the track pieces are mostly grey they are easy to see and make me believe the problem could be Z fighting or something similar.

Please can you give me your ideas on this and a way to fix the problem.
Thanks,

heres an image: please tell me if it doesn't work
http://www.chaosreef.com/zbuffer.jpg

r_bewick

Share this post


Link to post
Share on other sites
Link doesn't seem to work for me (Times out).

What are your near and far clip planes set to (They're parameters to D3DXMatrixPerspectiveFOV*())?

What format is your z-buffer?

How wide are the black triangles? If it's 1 pixel, it might just be floating point rounding errors, and you could scale your pieces by 1.0001 or something similar to make them overlap slightly, which might help, or you could build the pieces so the track overlaps (Put a sharp ramp down at the end of the piece and make the raps overlap).

Share this post


Link to post
Share on other sites
Hi Evil Steve, thankyou very much for the reply.

I uploaded it again somewhere else, hopefully this works:
http://www.freeimagehosting.net/image.php?fea5347c40.jpg

my near clip is set to 1.0f, and far is set to 1000.0f.

I am not exactly sure what format my ZBuffer is.

//I clear my ZBuffer like this:
m_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, _dwColour, 1.0f, 0);

//Heres some of my DirectX Creation code: (for a non-fullscreen window)
m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
m_d3dpp.BackBufferWidth = 0;
m_d3dpp.BackBufferHeight = 0;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
m_d3dpp.BackBufferCount = 1;
m_d3dpp.EnableAutoDepthStencil = TRUE;
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
vertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING;

m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, true);



Unfortunately the black triangles are a lot bigger than 1 pixel so the methods you gave me did not work. I have tried scaling the meshes but the z fighting is still there.


Thanks again,
r_bewick

Share this post


Link to post
Share on other sites
What Specialist84 said.

If the issue still persists, try making the pieces trapezoids if viewed from the side, instead of rectangles:

Like this: Not this:
+-----+ +---------+
/ \ | |
+---------+ +---------+

Two side-by-side pieces would then intersect:
+-----++-----+
/ /\ \
+------+--+------+
That should hide the edges quite well so long as the pieces have similar edges.

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