d3d Z-Buffer? menu

User Tag List

Results 1 to 5 of 5
  1. #1
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    d3d Z-Buffer?

    Good time everyone!

    I'm trying to work with Direct3DDevice9 (vtable).

    Faced with the problem of displaying 3d primitives, it seems that I did something wrong with the z-buffer. Can anyone suggest something? The code works without throwing any errors.

    d3d Z-Buffer?-nky1c-jpg
    https://i.imgur.com/7OFi9.jpg

    Set render states:
    Code:
    device.SetRenderState(D3DRenderStateType.ZENABLE, 1);
    device.SetRenderState(D3DRenderStateType.ZWRITEENABLE, 1);
    device.SetRenderState(D3DRenderStateType.ZFUNC, (int)D3DCmp.LESSEQUAL);
    
    device.SetRenderState(D3DRenderStateType.ALPHABLENDENABLE, 1);
    device.SetRenderState(D3DRenderStateType.SRCBLEND, (int)D3DBlend.SRCALPHA);
    device.SetRenderState(D3DRenderStateType.DESTBLEND, (int)D3DBlend.INVSRCALPHA);
    
    device.SetRenderState(D3DRenderStateType.LIGHTING, 0);
    device.SetRenderState(D3DRenderStateType.CULLMODE, 0);
    world
    Code:
    Matrix worldMatrix = Matrix.Translation(vector) * Matrix.RotationYawPitchRoll(yaw, pitch, roll);
    device.SetTransform(D3DTransformStateType.World, &worldMatrix);
    view
    Code:
    Camera camera = Camera.GetCamera();
    
    Matrix matrix;
    if ( camera == null )
                matrix = Matrix.Identity();
    else 
    {
                Vector3 eye = camera.Position;
                Vector3 at = eye + camera.Forward();
                Vector3 up = Vector3.Up;
    
                matrix = Matrix.LookAtRH( eye, at, up );
    }
    
    device.SetTransform( D3DTransformStateType.VIEW, &matrix );
    projection
    Code:
    Camera camera = Camera.GetCamera();
    
    Matrix matrix;
    if ( camera == null )
                matrix = Matrix.Identity();
    else 
    {
                float fov = camera.GetFov();
                matrix = Matrix.PerspectiveFovRH( fov * 0.6f, camera.Aspect, camera.NearZ, camera.FarZ );
    }
    
    device.SetTransform( D3DTransformStateType.PROJECTION, &matrix );
    viewport
    Code:
    D3DViewport viewport = device.GetViewport();
    viewport.MinZ = 0;
    viewport.MaxZ = 0.94f;
    
    device.SetViewport(viewport);
    MinZ = 0
    MaxZ = 0.94 (got it using hooking HRESULT SetViewport( D3DVIEWPORT9 * pViewport )
    other values, seems, for UI and etc (nameplates?)

    ---
    hooked a setViewport and draw but all drawn on game plane :\
    anyone had that issue?
    Last edited by Wildbreath; 03-10-2012 at 06:18 AM.

    d3d Z-Buffer?
  2. #2
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    noone knows?
    still unsolved

  3. #3
    boredevil's Avatar Active Member
    Reputation
    46
    Join Date
    Feb 2008
    Posts
    166
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could try near-/farZ 0.2 1600.0. That works perfect for me. i fail to get correct results using the camera´s values, which were 0/1 when i checked the last time.
    i´m counting viewportcalls with min == 0 and max == 1 every frame, then render my stuff in numMaxCalls -2. basically works from -5 to -2.
    it´s not perfect, as it hides some of the ui text, and "flickers" when the number of viewport calls changes. but the geom is perfectly in place, that´s what is important for me.

    here´s my mess:
    Code:
    void WowWorldRenderCtx::setDeviceStates()
    {
    
    
    
    	    // check if device supports alphablend
    	    bool bSupportsAlphaBlend = true;
    	    LPDIRECT3D9 pd3d9 = NULL;
    	    if( SUCCEEDED( m_pD3dDevice->GetDirect3D( &pd3d9 ) ) )
    	    {
    	        D3DCAPS9 Caps;
    	        D3DDISPLAYMODE Mode;
    	        LPDIRECT3DSURFACE9 pSurf = NULL;
    	        D3DSURFACE_DESC Desc;
    	        m_pD3dDevice->GetDeviceCaps( &Caps );
    	        m_pD3dDevice->GetDisplayMode( 0, &Mode );
    	        if( SUCCEEDED( m_pD3dDevice->GetRenderTarget( 0, &pSurf ) ) )
    	        {
    	            pSurf->GetDesc( &Desc );
    	            if( FAILED( pd3d9->CheckDeviceFormat( Caps.AdapterOrdinal, Caps.DeviceType, Mode.Format,
    	                D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_SURFACE,
    	                Desc.Format ) ) )
    	            {
    	                bSupportsAlphaBlend = false;
    	            }
    	            SAFE_RELEASE( pSurf );
    	        }
    	        SAFE_RELEASE( pd3d9 );
    	    }
    
    
    
    	    if(bSupportsAlphaBlend)
    	    {
    	        m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    	        m_pD3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
    	        m_pD3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
    	    }
    	    else
    	    {
    	        m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
    	    }
    
    
    		m_pD3dDevice->SetRenderState( D3DRS_CULLMODE , 0);
    		m_pD3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    		m_pD3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
    
    	    m_pD3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
    	    m_pD3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    
    	    m_pD3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
    	    m_pD3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
    
    	    m_pD3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
    
    }
    Code:
    void WowWorldRenderCtx::beginDrawing()
    {
        D3DXMATRIX 		 projMatrix;
        D3DXMATRIX 		 viewMatrix;
        D3DXMATRIX 		 worldMatrix;
    
        // make that stuff member variables..
        float m_AspectRatio = 1680.0 / 1050.0;	// get values from client...
        float m_fFovYMulti = 0.6;
        float m_ZNearPlane = 0.2;
        float m_ZFarPlane = 1600.0;
    
    
    	CameraInfo* cam = CGWorld::getActiveCamera();
    
    	D3DXMatrixPerspectiveFovRH(&projMatrix, cam->fFov * m_fFovYMulti , m_AspectRatio ,m_ZNearPlane, m_ZFarPlane);
    
    	D3DXVECTOR3 eye = cam->fPos;
    
        float ppos[3];
        ppos[0] = eye[0] + cam->fViewMat[0][0] ;
        ppos[1] = eye[1] + cam->fViewMat[0][1] ;
        ppos[2]= eye[2] + cam->fViewMat[0][2]  ;
    
    
    
        D3DXVECTOR3 at = ppos ;
        D3DXVECTOR3 upVec(0, 0, 1);
    	D3DXMatrixLookAtRH(&viewMatrix, &eye, &at, &upVec);
    
    
        // set Transformation matix
        m_pD3dDevice->SetTransform(D3DTS_VIEW, &viewMatrix);
        m_pD3dDevice->SetTransform(D3DTS_PROJECTION, &projMatrix);
    
        //  move somewhere other/
        D3DXMatrixIdentity(&worldMatrix);
        D3DXMatrixTranslation(&worldMatrix, 0, 0, 0);
        m_pD3dDevice->SetTransform(D3DTS_WORLD, &worldMatrix);
    
    
        // setup viewport
        D3DVIEWPORT9 Viewport;
    	m_pD3dDevice->GetViewport(&Viewport);
    	Viewport.MinZ = m_ZViewPortNearPlane;
    	Viewport.MaxZ = m_ZViewPortFarPlane;
    	m_pD3dDevice->SetViewport(&Viewport);
    
    	if(m_bWireFramed)
    	{
    		m_pD3dDevice->SetRenderState( D3DRS_FILLMODE,   D3DFILL_WIREFRAME );
    		m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
    	}
    	else
    	{
    		m_pD3dDevice->SetRenderState( D3DRS_FILLMODE,   D3DFILL_SOLID );
    		m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    	}
    }

  4. #4
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your advice, I'll check in the evening and report back. Wasn't know what farZ could be greater than 1 :confused:

  5. #5
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank very much, solved.

    https://i.imgur.com/r1DeX.jpg

    +rep ofc

Similar Threads

  1. [Release]Buffer npc lua
    By Noobcraft in forum WoW EMU General Releases
    Replies: 8
    Last Post: 10-04-2008, 07:20 AM
  2. [Release] Healer, Morpher + Buffer NPC [LUA]
    By Syrup in forum WoW EMU General Releases
    Replies: 3
    Last Post: 09-07-2008, 04:57 PM
  3. [Release] Buffer Item, SkillNPC, HealNPC for ALL Compiles
    By LordJedi in forum World of Warcraft Emulator Servers
    Replies: 16
    Last Post: 05-24-2008, 07:24 PM
  4. [Release]Portable Buffer
    By Pragma in forum World of Warcraft Emulator Servers
    Replies: 19
    Last Post: 03-03-2008, 03:10 AM
  5. Stackable Buffers
    By Matt in forum World of Warcraft Exploits
    Replies: 0
    Last Post: 05-02-2006, 01:15 PM
All times are GMT -5. The time now is 08:09 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search