Results 1 to 5 of 5

Thread: Adjusting the Z-buffer (DX 8.1)

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Adjusting the Z-buffer (DX 8.1)

    As I zoom out of my scene there seems to be a problem with the Z-buffer precision, see attached picture (the zig-zag lines / should be straight).

    However, how can I fix this?
    Attached Images Attached Images  
    Last edited by Fox; Mar 29th, 2004 at 04:58 AM.

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    This should help:
    VB Code:
    1. 'Check device supports hardware acceleration...
    2. On Error Resume Next
    3. D3D.GetDeviceCaps D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Caps
    4. If Err.Number = D3DERR_NOTAVAILABLE Then
    5.     'Device type "D3DDEVTYPE_HAL" not available, ie no Hardware acceleration
    6.     MsgBox "Hardware acceleration not supported!", vbCritical
    7.     Initialise = False
    8.     Exit Function
    9. Else
    10.     'Supports Hardware Acceleration...
    11.     On Error GoTo ErrHandler 'Restore the error handler because we had changed it to "Resume Next" remember
    12.     If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) = D3D_OK Then
    13.         'We can use a 32 bit Z-Buffer
    14.         D3DWindow.AutoDepthStencilFormat = D3DFMT_D32
    15.     Else
    16.         'Could not support a 32 bit Z-Buffer, try a 24 bit Z-Buffer...
    17.         If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) = D3D_OK Then
    18.             'We can use a 24 bit Z-Buffer
    19.             D3DWindow.AutoDepthStencilFormat = D3DFMT_D24X8
    20.         Else
    21.             'Could not support a 24 bit Z-Buffer, try a 16 bit Z-Buffer...
    22.             If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) = D3D_OK Then
    23.             'We can use a 16 bit Z-Buffer
    24.             D3DWindow.AutoDepthStencilFormat = D3DFMT_D16
    25.             Else
    26.                 MsgBox "Could not find a supported format for a Z-Buffer!", vbCritical
    27.                 Initialise = False
    28.                 Exit Function
    29.             End If
    30.         End If
    31.     End If
    32. End If


    What depth of Z Buffer are you already using? This should get the biggest it can work with (hopefully ). I have seen this problem occurr before when I was using a 16bit one.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Thanks, but I'm already looking for the biggest possible Z-buffer which is D3DFMT_16 on my laptop.

    I hoped there was a way to optimize the precision of the Z-buffer since my game world is nearly flat and I do exactly know in which distance I need a tighter Z-buffer...

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Which formats are you checking? My old PC Supported D32 but my new one didn't so I had to add it to check for DM24X8 which does work on my new one. There might be another one that would work on your laptop?
    I haven't heard of anything like you mentioned by changing the position of the precission before.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I'm checking those:
    VB Code:
    1. 'Find best Z-buffer
    2.     If CheckDepthBufferFormat(D3DFMT_D32) Then
    3.         DepthBufferFormat = D3DFMT_D32
    4.     ElseIf CheckDepthBufferFormat(D3DFMT_D24S8) Then
    5.         DepthBufferFormat = D3DFMT_D24S8
    6.     ElseIf CheckDepthBufferFormat(D3DFMT_D24X4S4) Then
    7.         DepthBufferFormat = D3DFMT_D24X4S4
    8.     ElseIf CheckDepthBufferFormat(D3DFMT_D24X8) Then
    9.         DepthBufferFormat = D3DFMT_D24X8
    10.     ElseIf CheckDepthBufferFormat(D3DFMT_D16) Then
    11.         DepthBufferFormat = D3DFMT_D16
    12.     ElseIf CheckDepthBufferFormat(D3DFMT_D15S1) Then
    13.         DepthBufferFormat = D3DFMT_D15S1
    14.     End If

    But that's not the point. If there's no other way it's ok since the graphics card is quite old. I was just trying to optimize existing things

    Thanks anyways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width