Evor 72 Posted February 2, 2019 Share Posted February 2, 2019 (edited) Hello, stuck with proper UV maps caluclation.... (yeah, rectangle too complicated figure) So, all in all i've got something like this: with that: float fWidth = m_width; float fHeight = m_height; float texReverseWidth = 1.0f / (fWidth); // TextureWidth float texReverseHeight = 1.0f / (fHeight); // TextureHeight float su = m_renderRect.left * texReverseWidth; float sv = m_renderRect.top * texReverseHeight; float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left)); float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top)); SAFE_RELEASE(m_lpd3dOriginalRenderTarget); SAFE_RELEASE(m_lpd3dOldDepthBufferSurface); TPDTVertex pVertices[4]; pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f); pVertices[0].texCoord = TTextureCoordinate(su, sv); pVertices[0].diffuse = 0xffffffff; pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f); pVertices[1].texCoord = TTextureCoordinate(eu, sv); pVertices[1].diffuse = 0xffffffff; pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f); pVertices[2].texCoord = TTextureCoordinate(su, ev); pVertices[2].diffuse = 0xffffffff; pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f); pVertices[3].texCoord = TTextureCoordinate(eu, ev); pVertices[3].diffuse = 0xffffffff; if (CGraphicBase::SetPDTStream(pVertices, 4)) { CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT); STATEMANAGER.SetTexture(0, GetRenderTargetTexture()); STATEMANAGER.SetTexture(1, NULL); STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE); STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2); } On the other hand, i've got this: with that: float fWidth = m_width; float fHeight = m_height; float texReverseWidth = 1.0f / (desc.Width); // ScreenWidth float texReverseHeight = 1.0f / (desc.Height); // ScreenHeight float su = m_renderRect.left * texReverseWidth; float sv = m_renderRect.top * texReverseHeight; float eu = texReverseWidth * (m_renderRect.left + (m_renderRect.right - m_renderRect.left)); float ev = texReverseHeight * (m_renderRect.top + (m_renderRect.bottom - m_renderRect.top)); SAFE_RELEASE(m_lpd3dOriginalRenderTarget); SAFE_RELEASE(m_lpd3dOldDepthBufferSurface); TPDTVertex pVertices[4]; pVertices[0].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top - 0.5f, 0.0f); pVertices[0].texCoord = TTextureCoordinate(su, sv); pVertices[0].diffuse = 0xffffffff; pVertices[1].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top - 0.5f, 0.0f); pVertices[1].texCoord = TTextureCoordinate(eu, sv); pVertices[1].diffuse = 0xffffffff; pVertices[2].position = TPosition(m_renderRect.left - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f); pVertices[2].texCoord = TTextureCoordinate(su, ev); pVertices[2].diffuse = 0xffffffff; pVertices[3].position = TPosition(m_renderRect.left + fWidth - 0.5f, m_renderRect.top + fHeight - 0.5f, 0.0f); pVertices[3].texCoord = TTextureCoordinate(eu, ev); pVertices[3].diffuse = 0xffffffff; if (CGraphicBase::SetPDTStream(pVertices, 4)) { CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT); STATEMANAGER.SetTexture(0, GetRenderTargetTexture()); STATEMANAGER.SetTexture(1, NULL); STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE); STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2); } I'm missing something, but this direct api makes me crazy. All help gladly appreciated. Regards! Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 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