locked
Depth test problem

    Question

  • The depth test of my project is not working and I dont know why.
    I thought I solved this in a previous forum question, but just stopped working and I already spent a lot of time researching to try to solve before asking for help.

    I'll be very happy if someone take a look at my "Project"(im really just learning).

    Project at: https://s3.amazonaws.com/bitbrusher/Direct3DApp.zip

    Regards



    Dhiogo Brustolin

    Tuesday, January 15, 2013 1:30 PM

Answers

All replies

  • Hello,

     

    I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 6:13 AM
    Moderator
  • Thank you very much.

    I'm still stuck on this issue.

    Regards


    Dhiogo Brustolin

    Thursday, January 17, 2013 8:03 PM
  • Hi Dhiogo,

    I ran your sample and I was able to run it fine with 2 cubes getting displayed, the smaller one overlapping the first one. I am not sure what exactly your problem is. In your project, can you point out the line of code that is apparently not working as expected?

    As a general guidance, the following link goes over the steps of configuring Dept-Stencil functionality: http://msdn.microsoft.com/en-us/library/bb205074(VS.85).aspx if that helps at all.

    Thanks,

    Prashant.

    Friday, January 18, 2013 11:30 PM
    Moderator
  • That's the problem, the two cubes are the same size, one appears smaller because it is farther than the other, and because of that it should be randerized partially, just the portion that is not being blocked by the other.

    Dhiogo Brustolin

    Friday, January 18, 2013 11:44 PM
  • To render the second cube farther away from the first cube, you can either swap the rendering of cube2 before cube1 like this:

     XMStoreFloat4x4(&constantBufferData.model,XMMatrixTranspose(XMMatrixTranslation(0,0,-3.0f)));
     devcon->UpdateSubresource(constantBuffer.Get(),0,NULL,&constantBufferData,0,0);
     cube2->Render(devcon); 

     XMStoreFloat4x4(&constantBufferData.model,XMMatrixTranspose(XMMatrixIdentity()));
     devcon->UpdateSubresource(constantBuffer.Get(),0,NULL,&constantBufferData,0,0);
     cube1->Render(devcon);

    or you can keep the same code and use positive values for the x,y,z axis to get the desired behavior:

     XMStoreFloat4x4(&constantBufferData.model,XMMatrixTranspose(XMMatrixIdentity()));
     devcon->UpdateSubresource(constantBuffer.Get(),0,NULL,&constantBufferData,0,0);
     cube1->Render(devcon);

     XMStoreFloat4x4(&constantBufferData.model,XMMatrixTranspose(XMMatrixTranslation(0,0,3.0f)));
     devcon->UpdateSubresource(constantBuffer.Get(),0,NULL,&constantBufferData,0,0);
     cube2->Render(devcon); 

    Monday, January 21, 2013 8:43 PM
    Moderator
  • I want the dept test to work, not just this project to run. Cause is just a test, when I create something bigger I don't want to have to worry with render order.

    Dhiogo Brustolin

    Thursday, January 24, 2013 8:24 PM
  • Try setting the viewport.MinDepth and viewport.MaxDepth values to 0 and 1 respectively. Then you don't have to worry about the rendering order.

    Thanks,

    Prashant.

    Thursday, January 24, 2013 10:55 PM
    Moderator
  • Dhiogo,

    I am marking this issue as resolved, since it works for the specific scenario you posted. If you need further help for your specific scenario, I would recommend that you open a support case with Microsoft support. You can visit this link to see the various support options that are available to better meet your needs: http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone or use your developer account to open a case with Support.

    Thanks,

    Prashant.

    Friday, February 01, 2013 1:13 AM
    Moderator