本文整理汇总了C++中Mat4x4::Transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::Transpose方法的具体用法?C++ Mat4x4::Transpose怎么用?C++ Mat4x4::Transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::Transpose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VGenerateVelocityMap
///////////////////////////////////////////////
//Motion Blur
///////////////////////////////////////////////
AVOID DeferredRenderer::VGenerateVelocityMap(CameraPtr pCamera, Renderer* pRenderer, const Mat4x4 & viewproj)
{
//set screen-aligned quad
m_pVertices->Set(0, 0);
//set shaders
m_pVelocityMapShaders->VBind();
//set shader resources
m_gbuffer.BindPositionTex(0, ST_Pixel);
//set render target
m_pVelocityRTV->Set();
//set constant buffers
//bind matrix constant buffer to the pipeline
Mat4x4 trans;
//trans.CreateTranslation(pCamera->GetLookAt() + 10000 * pCamera->GetDir());
trans.CreateTranslation(pCamera->GetPosition() + 500* pCamera->GetDir());
Mat4x4 rot;
rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());
Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 1.0f, 1000.0f);
WVP.Transpose();
m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
m_pMatrixBuffer->Set(0, ST_Vertex);
//set previous frame view-projection transform
Mat4x4 currViewProj = viewproj;
Mat4x4 prevViewProj = pCamera->GetPrevView() * pCamera->GetPrevProjection();
//prevViewProj = pCamera->GetView() * pCamera->GetProjection();
//prevViewProj = pCamera->GetProjection();
currViewProj.Transpose();
prevViewProj.Transpose();
//m_pcbPrevViewProj->UpdateSubresource(0, NULL, &prevViewProj, 0, 0);
//m_pcbPrevViewProj->Set(0, ST_Pixel);
struct TwoMatrices
{
Mat4x4 prevViewProj;
Mat4x4 currViewProj;
};
TwoMatrices temp;
temp.prevViewProj =prevViewProj;
temp.currViewProj = currViewProj;
m_pcbWorldPlusWVP->UpdateSubresource(0, nullptr, &temp, 0, 0);
m_pcbWorldPlusWVP->Set(0, ST_Pixel);
//Finally render velocity map
Draw(6, 0);
//unbind views
UnbindShaderResourceViews(0, 1, ST_Pixel);
UnbindRenderTargetViews(1);
}
示例2: CalculateAmbientOcclusion
///////////////////////////////////////////////
//Ambient occlusion
///////////////////////////////////////////////
AVOID DeferredRenderer::CalculateAmbientOcclusion(CameraPtr pCamera)
{
m_pSSAOShaders->VBind();
m_pVertices->Set(0, 0);
//bind matrix constant buffer to the pipeline
Mat4x4 trans;
trans.CreateTranslation(pCamera->GetLookAt());
Mat4x4 rot;
rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());
Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 0.1f, 1000.0f);
WVP.Transpose();
m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
m_pMatrixBuffer->Set(0, ST_Vertex);
//camera params
Vec cameraParams = Vector(pCamera->GetFrustum().GetNearWidth(), pCamera->GetFrustum().GetNearHeight(), 0.0f, 0.0f);
m_pcbFrustumSize->UpdateSubresource(0, NULL, &cameraParams, 0, 0);
m_pcbFrustumSize->Set(0, ST_Pixel);
//depth buffer params
Vec depthBufferParams = Vector(1.0f / SCREEN_WIDTH, 1.0f / SCREEN_HEIGHT, 0.0f, 0.0f);
m_pcbDepthBuffer->UpdateSubresource(0, NULL, &depthBufferParams, 0, 0);
m_pcbDepthBuffer->Set(1, ST_Pixel);
//camera view matrix
Mat4x4 View = pCamera->GetView();
View.Transpose();
m_pcbView->UpdateSubresource(0, NULL, &View, 0, 0);
m_pcbView->Set(2, ST_Pixel);
//send SSAO params
//Vec ssaoParams = Vector(20.0f, 2.0f, 5.0f, 2.0f);
//m_pcbSSAOParams->UpdateSubresource(0, NULL, &ssaoParams, 0, 0);
//m_pcbSSAOParams->Set(2, ST_Pixel);
m_pDepthDisableStencilDisable->Set(0);
//m_pDepthSRV->Set(0, ST_Pixel);
m_gbuffer.m_SRVList.SetView(2, 0, ST_Pixel);
m_gbuffer.m_SRVList.SetView(5, 1, ST_Pixel);
m_pSSAORTV->Set();
//set sampler states
//AnisotropySampler16()->Set(0, ST_Pixel);
PointClampSampler()->Set(0, ST_Pixel);
D3D11DeviceContext()->Draw(6, 0);
//Unbind render target view
UnbindRenderTargetViews(1);
//m_pSSAOSRV->Set(5, ST_Pixel);
UnbindShaderResourceViews(0, 2, ST_Pixel);
GetRenderTargetView()->Set();
}
示例3: VPrepareToGenerateShadowMap
AVOID Light::VPrepareToGenerateShadowMap(const Mat4x4 & world, Renderer * pRenderer)
{
//Set depth stencil view
if (pRenderer->m_bVarianceShadows)
{
m_pVarianceShadowRTV->Set(*m_pShadowMapDSV);
//m_pVarianceShadowRTV->Set();
}
else
{
SetDepthStencilView(m_pShadowMapDSV);
}
//GetRenderTargetView()->Set(*m_pShadowMapDSV);
//set constant buffer with orthographic projection
Vec pos = m_pData->m_pos * m_worldTransform;
Vec dir = Vector(m_pData->m_dir.x, m_pData->m_dir.y, m_pData->m_dir.z, 0.0f);
Mat4x4 view = CreateViewMatrixLH(pos, dir, Vector(0.0f, 1.0f, 0.0f, 0.0f));
Mat4x4 ortho = CreateOrthoProjectionLH(m_iShadowMapWidth * 1.5f, m_iShadowMapHeight * 1.5f, 0.5f, m_r32Range);
//Mat4x4 ortho = CreateOrthoProjectionLH(m_iShadowMapWidth, m_iShadowMapHeight, 2.0f, 60.0f);
//Mat4x4 ortho = CreatePerspectiveProjectionLH( 0.25f * 3.14f, (AREAL)SCREEN_WIDTH / (AREAL)SCREEN_HEIGHT, 0.5f, 30.0f);
m_view = view;
m_viewProjection = view * ortho;
Mat4x4 WVP = world * m_viewProjection;
WVP.Transpose();
if (pRenderer->m_bVarianceShadows)
{
Mat4x4 WorldView = world * view;
WorldView.Transpose();
struct MatrixBuffer
{
Mat4x4 WorldView;
Mat4x4 WVP;
};
MatrixBuffer buffer;
buffer.WorldView = WorldView;
buffer.WVP = WVP;
pRenderer->m_pcbWorldPlusWVP->UpdateSubresource(0, NULL, &buffer, 0, 0);
pRenderer->m_pcbWorldPlusWVP->Set(0, ST_Vertex);
}
else
{
pRenderer->m_pcbWVP->UpdateSubresource(0, NULL, &WVP, 0, 0);
pRenderer->m_pcbWVP->Set(0, ST_Vertex);
}
//Actually stores length of light frustum
Vec frustumSize = Vector(m_r32Range - 0.5, m_r32Range -0.5, m_r32Range - 0.5, m_r32Range - 0.5 );
pRenderer->m_pcbCameraPos->UpdateSubresource(0, NULL, &frustumSize, 0, 0);
pRenderer->m_pcbCameraPos->Set(0, ST_Pixel);
}
示例4: Adjoint
/**
Gets the adjoint matrix: The transpose of the matrix's cofactor.
*/
Mat4x4 Adjoint(const Mat4x4& m)
{
//Another huge pain!
//Build a new 4x4 matrix from cofactors.
//C(i, j) = (-1)^(i+j)*det(submatrix(i,j))
Mat4x4 result = Mat4x4::Zero();
for (int i = 0; i < MAT4X4_NUM_CELLS; i++)
{
for (int j = 0; j < MAT4X4_NUM_CELLS; j++)
{
result(i, j) = pow(-1.0f, i + j) * GetSubmatrix(m, i, j).Determinant();
}
}
result.Transpose();
return result;
}
示例5: PrepareForLightPass
AVOID DeferredRenderer::PrepareForLightPass(CameraPtr pCamera)
{
//set vertex buffer with positions
m_pVertices->Set(0, 0);
//set vertex buffer with texture data
m_pTexCoords->Set(1, 0);
//bind matrix constant buffer to the pipeline
Mat4x4 trans;
//trans.CreateTranslation(pCamera->GetLookAt() + 10000 * pCamera->GetDir());
trans.CreateTranslation(pCamera->GetPosition() + 500* pCamera->GetDir());
Mat4x4 rot;
rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());
Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 1.0f, 1000.0f);
WVP.Transpose();
m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
m_pMatrixBuffer->Set(0, ST_Vertex);
struct CameraBuffer
{
Mat4x4 inverseViewProjection;
Vec pos;
};
CameraBuffer cameraBuffer;
Mat4x4 inverseViewProjection = pCamera->GetViewProjection();
inverseViewProjection.Inverse();
cameraBuffer.pos = pCamera->GetPosition();
cameraBuffer.inverseViewProjection = inverseViewProjection;
cameraBuffer.inverseViewProjection.Transpose();
m_pcbCameraPos->UpdateSubresource(0, nullptr, &pCamera->GetPosition(), 0, 0);
//m_pcbCameraPos->UpdateSubresource(0, NULL, &cameraBuffer, 0, 0);
m_pcbCameraPos->Set(0, ST_Pixel);
//pCamera->SetViewport();
SetGlobalViewport();
//set shader resources
m_pSSAOBlurredSRV->Set(6, ST_Pixel);
m_pDepthSRV->Set(8, ST_Pixel);
//set blending functionality
//this->BlendLightPass()->Set(nullptr);
}
示例6: VRenderSky
AVOID DeferredRenderer::VRenderSky(CameraPtr pCamera, const Mat4x4 & viewproj)
{
m_gbuffer.BindRenderTarget(3);
//m_pSkyShaders->VBind();
m_pAtmoShaders->VBind();
Mat4x4 trans;
trans.CreateTranslation(pCamera->GetPosition());
Mat4x4 scale;
scale.CreateScaling(1, 1, 1);
//Mat4x4 worldViewProj = trans * viewproj;
Mat4x4 worldViewProj = scale * viewproj;
worldViewProj.Transpose();
m_pcbWVP->UpdateSubresource(0, nullptr, &worldViewProj, 0, 0);
m_pcbWVP->Set(1, ST_Vertex);
struct WorldData
{
Mat4x4 wvp;
//Vec cameraPos;
};
WorldData worldData;
worldData.wvp = worldViewProj;
//worldData.cameraPos = pCamera->GetPosition();
//m_pcbAtmoWorld->UpdateSubresource(0, nullptr, &worldData, 0, 0);
//m_pcbAtmoWorld->Set(1, ST_Vertex);
m_pSphereMesh->SetPositionBuffer();
m_pSphereMesh->SetIndexBuffer();
this->NoCullingStandardRasterizer()->Set();
this->m_pDepthDisableStencilDisable->Set(0xFF);
//m_pSkySRV->Set(0, ST_Pixel);
m_pSphereMesh->VRender(this);
UnbindRenderTargetViews(1);
UnbindShaderResourceViews(0, 1, ST_Pixel);
}