Jump to content

  • Log In with Google      Sign In   
  • Create Account


A defect in rendering


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

#1 homo   Members   -  Reputation: 105

Like
0Likes
Like

Posted 04 March 2013 - 12:43 AM

hello

    I have found a defect in rendering a model in directx9,the defect is illustrated by the following attach files.when I rotate the model,the defect disappeared.I enabled the depth testing and lighting.here is my code.

 

无标题.jpg ,

D3DLIGHT9 light;    // create the light struct
    D3DMATERIAL9 material;    // create the material struct
DefaultMaterial::getMaterial(material,JADE);
    ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
    light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
    light.Diffuse =material.Diffuse ;
light.Ambient=material.Ambient ;
light.Specular=material.Specular ;
    light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f);

    m_pDevice->SetLight(0, &light);    // send the light struct properties to light #0
    m_pDevice->LightEnable(0, TRUE);    // turn on light #0

    m_pDevice->SetMaterial(&material);    // set the globably-used material to &material

    r=m_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);    // turn on the 3D lighting
    r=m_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);    // turn on the z-buffer
   r=m_pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(250, 250, 250));    // ambient light
   m_pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESS);
   m_pDevice->SetRenderState(D3DRS_ZWRITEENABLE,true);

Does that mean I'm doing something wrong?Thanks for the help!


Edited by homo, 04 March 2013 - 12:45 AM.


Sponsor:

#2 Uberwulu   Members   -  Reputation: 150

Like
0Likes
Like

Posted 04 March 2013 - 02:24 AM

Yes, you're not using the programmable pipeline.



#3 Schrompf   Prime Members   -  Reputation: 950

Like
0Likes
Like

Posted 04 March 2013 - 03:20 AM

This might be ZFighting. If you set up your projection matrix with very high far plane distance or a near plane distance very close to zero, depth buffer precision goes kaput.


----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.

#4 Jason Z   Crossbones+   -  Reputation: 4721

Like
3Likes
Like

Posted 04 March 2013 - 06:25 AM

Yes, you're not using the programmable pipeline.

Please try to be constructive in your comments - this isn't helpful to his current problem, and you don't even provide any background to your statement.

 

I agree with Schrompf that it might be Z-fighting and could be corrected with modification of your projection parameters.



#5 mhagain   Crossbones+   -  Reputation: 7468

Like
0Likes
Like

Posted 04 March 2013 - 07:10 AM

Yes, you're not using the programmable pipeline.

Please try to be constructive in your comments - this isn't helpful to his current problem, and you don't even provide any background to your statement.

 

I agree with Schrompf that it might be Z-fighting and could be corrected with modification of your projection parameters.

 

Agreed - and also to note: if it is z-fighting then using the programmable versus the fixed pipeline will make damn-all difference.  You'll still get z-fighting.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 blueshogun96   Crossbones+   -  Reputation: 818

Like
0Likes
Like

Posted 04 March 2013 - 02:11 PM

Yup, looks like Z-Fighting to me.  Here's an article which helps explain how to fix it using various methods and render states: http://software.intel.com/en-us/articles/alternatives-to-using-z-bias-to-fix-z-fighting-issues

 

I'm going to assume you're using D3DFMT_D24S8 as your depth buffer format.  If you're using D3DFMT_D16, then you're more likely to get Z-Fighting artifacts.

 

Shogun.


Follow Shogun3D on the official website: http://shogun3d.net

 

blogger.png twitter.png tumblr_32.png facebook.png


#7 homo   Members   -  Reputation: 105

Like
0Likes
Like

Posted 04 March 2013 - 11:01 PM

Thanks for the tip.I changed D3DFMT_D16 to D3DFMT_D24X8; it works very well.

thanks!






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