Trial 234 Posted December 24, 2022 Share Posted December 24, 2022 Quote 1. Textures blurring out when prompting any UAC check. This happens because the "Anisotropic Texture Filtering" is only applied when instancing "CStateManager" (CStateManager::SetDevice) it must be applied again after losing/resetting the D3D device. This could be done by moving this code below from "CStateManager::SetDevice" to "CStateManager::SetDefaultState" D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); so that "CStateManager::SetDevice" looks like this void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice) { StateManager_Assert(lpDevice); lpDevice->AddRef(); if (m_lpD3DDev) { m_lpD3DDev->Release(); m_lpD3DDev = NULL; } m_lpD3DDev = lpDevice; SetDefaultState(); } (I know the "m_dwBestMagFilter" and "m_dwBestMinFilter" setting part does not need to be called every time device is reset, you are free to edit the code at your will, I kept things simple for the post) alternatively these lines could be moved to a new method that will be called in "CStateManager::SetDevice" and wherever there is D3D device reset. Although I recommend first solution. 4 1 1 4 Link to comment Share on other sites More sharing options...
Active Member ReFresh 2349 Posted December 25, 2022 Active Member Share Posted December 25, 2022 (edited) 14 hours ago, Trial said: D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); So could it be placed at the end of the 'CStateManager::SetDefaultState' function? Or it should be placed somewhere else in 'CStateManager::SetDefaultState' function? So it will look like this? Spoiler void CStateManager::SetDefaultState() { m_CurrentState.ResetState(); m_CopyState.ResetState(); m_ChipState.ResetState(); m_bScene = false; m_bForce = true; D3DXMATRIX Identity; D3DXMatrixIdentity(&Identity); SetTransform(D3DTS_WORLD, &Identity); SetTransform(D3DTS_VIEW, &Identity); SetTransform(D3DTS_PROJECTION, &Identity); D3DMATERIAL8 DefaultMat; ZeroMemory(&DefaultMat, sizeof(D3DMATERIAL8)); DefaultMat.Diffuse.r = 1.0f; DefaultMat.Diffuse.g = 1.0f; DefaultMat.Diffuse.b = 1.0f; DefaultMat.Diffuse.a = 1.0f; DefaultMat.Ambient.r = 1.0f; DefaultMat.Ambient.g = 1.0f; DefaultMat.Ambient.b = 1.0f; DefaultMat.Ambient.a = 1.0f; DefaultMat.Emissive.r = 0.0f; DefaultMat.Emissive.g = 0.0f; DefaultMat.Emissive.b = 0.0f; DefaultMat.Emissive.a = 0.0f; DefaultMat.Specular.r = 0.0f; DefaultMat.Specular.g = 0.0f; DefaultMat.Specular.b = 0.0f; DefaultMat.Specular.a = 0.0f; DefaultMat.Power = 0.0f; SetMaterial(&DefaultMat); SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_LINEPATTERN, 0xFFFFFFFF); SetRenderState(D3DRS_LASTPIXEL, FALSE); SetRenderState(D3DRS_ALPHAREF, 1); SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); SetRenderState(D3DRS_ZVISIBLE, FALSE); SetRenderState(D3DRS_FOGSTART, 0); SetRenderState(D3DRS_FOGEND, 0); SetRenderState(D3DRS_FOGDENSITY, 0); SetRenderState(D3DRS_EDGEANTIALIAS, FALSE); SetRenderState(D3DRS_ZBIAS, 0); SetRenderState(D3DRS_STENCILWRITEMASK, 0xFFFFFFFF); SetRenderState(D3DRS_AMBIENT, 0x00000000); SetRenderState(D3DRS_LOCALVIEWER, FALSE); SetRenderState(D3DRS_NORMALIZENORMALS, FALSE); SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE); SetRenderState(D3DRS_CLIPPLANEENABLE, 0); SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE); SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE); SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF); SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE); SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF); SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); SetRenderState(D3DRS_FOGENABLE, FALSE); SetRenderState(D3DRS_FOGCOLOR, 0xFF000000); SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_NONE); SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); SetRenderState(D3DRS_ZENABLE, TRUE); SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); SetRenderState(D3DRS_ZWRITEENABLE, TRUE); SetRenderState(D3DRS_DITHERENABLE, TRUE); SetRenderState(D3DRS_STENCILENABLE, FALSE); SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); SetRenderState(D3DRS_CLIPPING, TRUE); SetRenderState(D3DRS_LIGHTING, FALSE); SetRenderState(D3DRS_SPECULARENABLE, FALSE); SetRenderState(D3DRS_COLORVERTEX, FALSE); SetRenderState(D3DRS_WRAP0, 0); SetRenderState(D3DRS_WRAP1, 0); SetRenderState(D3DRS_WRAP2, 0); SetRenderState(D3DRS_WRAP3, 0); SetRenderState(D3DRS_WRAP4, 0); SetRenderState(D3DRS_WRAP5, 0); SetRenderState(D3DRS_WRAP6, 0); SetRenderState(D3DRS_WRAP7, 0); SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT); SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(2, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(3, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(3, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(3, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(3, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(4, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(4, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(4, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(4, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(5, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(5, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(5, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(5, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(5, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(5, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(6, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(6, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(6, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(6, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(6, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(6, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(7, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(7, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(7, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(7, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(7, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(7, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 2); SetTextureStageState(3, D3DTSS_TEXCOORDINDEX, 3); SetTextureStageState(4, D3DTSS_TEXCOORDINDEX, 4); SetTextureStageState(5, D3DTSS_TEXCOORDINDEX, 5); SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 6); SetTextureStageState(7, D3DTSS_TEXCOORDINDEX, 7); SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(4, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(4, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(5, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(5, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(6, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(6, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(7, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(7, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(2, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(3, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(4, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(5, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(6, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(7, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTexture(0, NULL); SetTexture(1, NULL); SetTexture(2, NULL); SetTexture(3, NULL); SetTexture(4, NULL); SetTexture(5, NULL); SetTexture(6, NULL); SetTexture(7, NULL); SetPixelShader(0); SetVertexShader(D3DFVF_XYZ); D3DXVECTOR4 av4Null[STATEMANAGER_MAX_VCONSTANTS]; memset(av4Null, 0, sizeof(av4Null)); SetVertexShaderConstant(0, av4Null, STATEMANAGER_MAX_VCONSTANTS); SetPixelShaderConstant(0, av4Null, STATEMANAGER_MAX_PCONSTANTS); m_bForce = false; #ifdef _DEBUG int i, j; for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++) m_bRenderStateSavingFlag[i] = FALSE; for (j = 0; j < STATEMANAGER_MAX_TRANSFORMSTATES; j++) m_bTransformSavingFlag[j] = FALSE; for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j) for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i) m_bTextureStageStateSavingFlag[j][i] = FALSE; #endif _DEBUG D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); } Edited December 25, 2022 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
Forum Moderator Gurgarath 2523 Posted December 25, 2022 Author Forum Moderator Share Posted December 25, 2022 The main post have been updated with many fixes have been added on multiple bugs that were fixed overtime! If you find any new bug or new fix, do not hesitate to report or share them! 14 hours ago, Trial said: This happens because the "Anisotropic Texture Filtering" is only applied when instancing "CStateManager" (CStateManager::SetDevice) it must be applied again after losing/resetting the D3D device. This could be done by moving this code below from "CStateManager::SetDevice" to "CStateManager::SetDefaultState" D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); so that "CStateManager::SetDevice" looks like this void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice) { StateManager_Assert(lpDevice); lpDevice->AddRef(); if (m_lpD3DDev) { m_lpD3DDev->Release(); m_lpD3DDev = NULL; } m_lpD3DDev = lpDevice; SetDefaultState(); } (I know the "m_dwBestMagFilter" and "m_dwBestMinFilter" setting part does not need to be called every time device is reset, you are free to edit the code at your will, I kept things simple for the post) alternatively these lines could be moved to a new method that will be called in "CStateManager::SetDevice" and wherever there is D3D device reset. Although I recommend first solution. Exactly! Thank you for the fix. I wondered why I hadn't the bug for a while but shrugged it off. When adding your fix I noticed I did add Anisotropic on SetDefaultState when I was doing MSAA. Excellent! 21 minutes ago, ReFresh said: So could it be placed at the end of the 'CStateManager::SetDefaultState' function? Or it should be placed somewhere else in 'CStateManager::SetDefaultState' function? So it will look like this? Hide contents void CStateManager::SetDefaultState() { m_CurrentState.ResetState(); m_CopyState.ResetState(); m_ChipState.ResetState(); m_bScene = false; m_bForce = true; D3DXMATRIX Identity; D3DXMatrixIdentity(&Identity); SetTransform(D3DTS_WORLD, &Identity); SetTransform(D3DTS_VIEW, &Identity); SetTransform(D3DTS_PROJECTION, &Identity); D3DMATERIAL8 DefaultMat; ZeroMemory(&DefaultMat, sizeof(D3DMATERIAL8)); DefaultMat.Diffuse.r = 1.0f; DefaultMat.Diffuse.g = 1.0f; DefaultMat.Diffuse.b = 1.0f; DefaultMat.Diffuse.a = 1.0f; DefaultMat.Ambient.r = 1.0f; DefaultMat.Ambient.g = 1.0f; DefaultMat.Ambient.b = 1.0f; DefaultMat.Ambient.a = 1.0f; DefaultMat.Emissive.r = 0.0f; DefaultMat.Emissive.g = 0.0f; DefaultMat.Emissive.b = 0.0f; DefaultMat.Emissive.a = 0.0f; DefaultMat.Specular.r = 0.0f; DefaultMat.Specular.g = 0.0f; DefaultMat.Specular.b = 0.0f; DefaultMat.Specular.a = 0.0f; DefaultMat.Power = 0.0f; SetMaterial(&DefaultMat); SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); SetRenderState(D3DRS_LINEPATTERN, 0xFFFFFFFF); SetRenderState(D3DRS_LASTPIXEL, FALSE); SetRenderState(D3DRS_ALPHAREF, 1); SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); SetRenderState(D3DRS_ZVISIBLE, FALSE); SetRenderState(D3DRS_FOGSTART, 0); SetRenderState(D3DRS_FOGEND, 0); SetRenderState(D3DRS_FOGDENSITY, 0); SetRenderState(D3DRS_EDGEANTIALIAS, FALSE); SetRenderState(D3DRS_ZBIAS, 0); SetRenderState(D3DRS_STENCILWRITEMASK, 0xFFFFFFFF); SetRenderState(D3DRS_AMBIENT, 0x00000000); SetRenderState(D3DRS_LOCALVIEWER, FALSE); SetRenderState(D3DRS_NORMALIZENORMALS, FALSE); SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE); SetRenderState(D3DRS_CLIPPLANEENABLE, 0); SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, FALSE); SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE); SetRenderState(D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF); SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE); SetRenderState(D3DRS_COLORWRITEENABLE, 0xFFFFFFFF); SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); SetRenderState(D3DRS_FOGENABLE, FALSE); SetRenderState(D3DRS_FOGCOLOR, 0xFF000000); SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_NONE); SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); SetRenderState(D3DRS_ZENABLE, TRUE); SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); SetRenderState(D3DRS_ZWRITEENABLE, TRUE); SetRenderState(D3DRS_DITHERENABLE, TRUE); SetRenderState(D3DRS_STENCILENABLE, FALSE); SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); SetRenderState(D3DRS_CLIPPING, TRUE); SetRenderState(D3DRS_LIGHTING, FALSE); SetRenderState(D3DRS_SPECULARENABLE, FALSE); SetRenderState(D3DRS_COLORVERTEX, FALSE); SetRenderState(D3DRS_WRAP0, 0); SetRenderState(D3DRS_WRAP1, 0); SetRenderState(D3DRS_WRAP2, 0); SetRenderState(D3DRS_WRAP3, 0); SetRenderState(D3DRS_WRAP4, 0); SetRenderState(D3DRS_WRAP5, 0); SetRenderState(D3DRS_WRAP6, 0); SetRenderState(D3DRS_WRAP7, 0); SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT); SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(2, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(2, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(2, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(2, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(3, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(3, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(3, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(3, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(3, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(3, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(4, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(4, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(4, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(4, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(4, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(4, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(5, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(5, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(5, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(5, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(5, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(5, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(6, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(6, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(6, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(6, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(6, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(6, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(7, D3DTSS_COLOROP, D3DTOP_DISABLE); SetTextureStageState(7, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(7, D3DTSS_COLORARG2, D3DTA_DIFFUSE); SetTextureStageState(7, D3DTSS_ALPHAOP, D3DTOP_DISABLE); SetTextureStageState(7, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SetTextureStageState(7, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1); SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 2); SetTextureStageState(3, D3DTSS_TEXCOORDINDEX, 3); SetTextureStageState(4, D3DTSS_TEXCOORDINDEX, 4); SetTextureStageState(5, D3DTSS_TEXCOORDINDEX, 5); SetTextureStageState(6, D3DTSS_TEXCOORDINDEX, 6); SetTextureStageState(7, D3DTSS_TEXCOORDINDEX, 7); SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(2, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(3, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(4, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(5, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(6, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MINFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); SetTextureStageState(7, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(3, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(3, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(4, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(4, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(5, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(5, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(6, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(6, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(7, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); SetTextureStageState(7, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(2, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(3, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(4, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(5, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(6, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTextureStageState(7, D3DTSS_TEXTURETRANSFORMFLAGS, 0); SetTexture(0, NULL); SetTexture(1, NULL); SetTexture(2, NULL); SetTexture(3, NULL); SetTexture(4, NULL); SetTexture(5, NULL); SetTexture(6, NULL); SetTexture(7, NULL); SetPixelShader(0); SetVertexShader(D3DFVF_XYZ); D3DXVECTOR4 av4Null[STATEMANAGER_MAX_VCONSTANTS]; memset(av4Null, 0, sizeof(av4Null)); SetVertexShaderConstant(0, av4Null, STATEMANAGER_MAX_VCONSTANTS); SetPixelShaderConstant(0, av4Null, STATEMANAGER_MAX_PCONSTANTS); m_bForce = false; #ifdef _DEBUG int i, j; for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++) m_bRenderStateSavingFlag[i] = FALSE; for (j = 0; j < STATEMANAGER_MAX_TRANSFORMSTATES; j++) m_bTransformSavingFlag[j] = FALSE; for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j) for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i) m_bTextureStageStateSavingFlag[j][i] = FALSE; #endif _DEBUG D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); } You can do like this indeed! 3 3 3 Gurgarath coming soon Link to comment Share on other sites More sharing options...
Active Member Draveniou1 721 Posted April 26, 2023 Active Member Share Posted April 26, 2023 (edited) for fix pstition 2. Any character being automatically attacked by another character is unable to move, to run away or to attack (Pre-fix in Spoilers) there will be enough problems if a player has low internet ? how could this be solved with no short? it's a fix I'm trying to make on my own server but I don't want to short and with this method Edited April 26, 2023 by Draveniou1 Link to comment Share on other sites More sharing options...
[TiTAN] 33 Posted December 27, 2023 Share Posted December 27, 2023 For 1. Textures blurring out when prompting any UAC check. : Problem is indeed the device reset on UAC how Trial stated, but even if we reapply anisotropic the outcome will be the same! (blurry textures and shadows) The reason for that is (at least in my case) the path and shadow textures will be sampled using D3DTEXF_LINEAR wich we are only using for MIP not for MAG nor MIN! The fix? Get rid of that statements: if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMagFilter = D3DTEXF_LINEAR; if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; else m_dwBestMinFilter = D3DTEXF_LINEAR; And initialize m_dwBestMinFilter and m_dwBestMagFilter directly with D3DTEXF_ANISOTROPIC like: CStateManager::CStateManager(LPDIRECT3DDEVICE9 lpDevice) : m_lpD3DDev(NULL) { m_bScene = false; m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; SetDevice(lpDevice); } Late Merry Christmas to everyone! 3 Link to comment Share on other sites More sharing options...
Active Member ReFresh 2349 Posted December 27, 2023 Active Member Share Posted December 27, 2023 (edited) 4 hours ago, [TiTAN] said: And initialize m_dwBestMinFilter and m_dwBestMagFilter directly with D3DTEXF_ANISOTROPIC like: CStateManager::CStateManager(LPDIRECT3DDEVICE9 lpDevice) : m_lpD3DDev(NULL) { m_bScene = false; m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; SetDevice(lpDevice); } So that function will look like this? Spoiler void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice) { StateManager_Assert(lpDevice); lpDevice->AddRef(); if (m_lpD3DDev) { m_lpD3DDev->Release(); m_lpD3DDev = NULL; } m_lpD3DDev = lpDevice; D3DCAPS8 d3dCaps; m_lpD3DDev->GetDeviceCaps(&d3dCaps); m_bScene = false; m_dwBestMinFilter = D3DTEXF_ANISOTROPIC; m_dwBestMagFilter = D3DTEXF_ANISOTROPIC; SetDevice(lpDevice); DWORD dwMax = d3dCaps.MaxAnisotropy; dwMax = dwMax < 4 ? dwMax : 4; for (int i = 0; i < 8; ++i) m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax); SetDefaultState(); } And CStateManager::SetDefaultState function will be set to default? So that means I won't do changes, which @Trial did? Correct me please, if I'm mistaken somewhere. Thanks Edited December 27, 2023 by ReFresh Core X - External 2 Internal I'll be always helpful! Link to comment Share on other sites More sharing options...
[TiTAN] 33 Posted December 27, 2023 Share Posted December 27, 2023 @ ReFresh You should keep the code in CStateManager::SetDefaultState because in case of a reset anisotropic won't be reapplyed if the code it's located in CStateManager::SetDevice (SetDevice is called only on client launch) Link to comment Share on other sites More sharing options...
Active Member ReFresh 2349 Posted December 27, 2023 Active Member Share Posted December 27, 2023 (edited) @[TiTAN] Thanks. Now it's clear. Edited December 27, 2023 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now