Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Bad mesh intersections.


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
8 replies to this topic

#1 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 24 March 2012 - 09:49 AM

how to make mesh intersections more smoothly?
Posted Image

Sponsor:

#2 Asesh   Members   -  Reputation: 268

Like
0Likes
Like

Posted 25 March 2012 - 06:56 AM

do you mean to render those two objects beside each other w/o any gap? you should do that in 3ds max instead instead, rather than manually modifying the world matrix for individual subsets

#3 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 25 March 2012 - 09:20 AM

Yes in this situation i can do it in 3ds Max, but - in scene will be more polygons. And if for example i have hero, i and it will can go into the water, i cannot do this in 3ds Max....so i need to know how to do it in code for all objects that i'll use.

#4 Hodgman   Moderators   -  Reputation: 30926

Like
0Likes
Like

Posted 25 March 2012 - 09:24 AM

That problem is known as "Z fighting"; it's caused by the z-buffer (depth buffer) not being precise enough to tell which of the two surfaces is in front.

As above, it's often best to fix the geometry so that this doesn't happen. You can also take measures to increase your depth-buffer precision, such as increasing your 'near plane' value.

#5 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 25 March 2012 - 12:16 PM

d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
I need to change D3DFMT_D16? when i change it to D3DFMT_D32 - program doesn't work.

#6 Asesh   Members   -  Reputation: 268

Like
0Likes
Like

Posted 25 March 2012 - 07:58 PM

try this instead:

D3DPRESENT_PARAMETERS oD3DPresentParameters = {0};
oD3DPresentParameters.BackBufferWidth = g_pMainFrame->getWindowWidth(); // Width of the back buffer
oD3DPresentParameters.BackBufferHeight = g_pMainFrame->getWindowHeight(); // Height of the back buffer
oD3DPresentParameters.BackBufferFormat = D3DFMT_A8R8G8B8; // Back buffer format
oD3DPresentParameters.Windowed = TRUE; // Windowed
oD3DPresentParameters.hDeviceWindow = g_pMainFrame->getWindowHandle(); // Handle to the main window
oD3DPresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; // Swap effect
oD3DPresentParameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; // Multisample type
oD3DPresentParameters.MultiSampleQuality = 1; // Multisample quality level
oD3DPresentParameters.BackBufferCount = 1; // No. of back buffers to use
oD3DPresentParameters.EnableAutoDepthStencil = TRUE; // Auto depth-stencil
oD3DPresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8; // Auto depth-stencil format


#7 Asesh   Members   -  Reputation: 268

Like
0Likes
Like

Posted 25 March 2012 - 08:02 PM

and when clearing the back buffer you should clear depth buffer too:

// Clear the surfaces
m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0x0, 1.0f, 0);


#8 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 26 March 2012 - 01:49 AM

Yes it works, thanks very much for help Posted Image

#9 Tom KQT   Members   -  Reputation: 1610

Like
0Likes
Like

Posted 26 March 2012 - 02:16 AM

d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
I need to change D3DFMT_D16? when i change it to D3DFMT_D32 - program doesn't work.


16bit depth buffer isn't really great, but as you noticed, D3DFMT_D32t isn't supported by all graphics adapters. D3DFMT_D24S8 (with stencil buffer) or D3DFMT_D24X8 (without stencil buffer) are very compatible and the depth buffer is 24bit.

But using better depth buffer isn't the only solution. You should be also careful with your projection matrix. You are probably using D3DXMatrixPerspectiveFovLH to create your projection matrix, am I right?
Many people simply set the last two parameters (z_near and z_far) to some "safe" values to be sure everything is visible for the camera, so near to very low value (like 0.0001f) and far to very large value (like 10000.0f). But this can cause z-fighting problems even with a large depth buffer, because those 24bits will be used in the whole range 0.0001f to 10000.0f.
The rule is to set the near value as BIG as possible and the far value as SMALL as possible. The exact numbers depend on the scale of your scene.




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