当前位置: 首页>>代码示例>>C++>>正文


C++ CDXUTSDKMesh::ComputeInFrustumFlags方法代码示例

本文整理汇总了C++中CDXUTSDKMesh::ComputeInFrustumFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ CDXUTSDKMesh::ComputeInFrustumFlags方法的具体用法?C++ CDXUTSDKMesh::ComputeInFrustumFlags怎么用?C++ CDXUTSDKMesh::ComputeInFrustumFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDXUTSDKMesh的用法示例。


在下文中一共展示了CDXUTSDKMesh::ComputeInFrustumFlags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

void App::Render(ID3D11DeviceContext* d3dDeviceContext, 
                 ID3D11RenderTargetView* backBuffer,
                 CDXUTSDKMesh& mesh_opaque,
                 CDXUTSDKMesh& mesh_alpha,
                 ID3D11ShaderResourceView* skybox,
                 const D3DXMATRIXA16& worldMatrix,
                 const CFirstPersonCamera* viewerCamera,
                 const D3D11_VIEWPORT* viewport,
                 const UIConstants* ui)
{
    D3DXMATRIXA16 cameraProj = *viewerCamera->GetProjMatrix();
    D3DXMATRIXA16 cameraView = *viewerCamera->GetViewMatrix();
    
    D3DXMATRIXA16 cameraViewInv;
    D3DXMatrixInverse(&cameraViewInv, 0, &cameraView);
        
    // Compute composite matrices
    D3DXMATRIXA16 cameraViewProj = cameraView * cameraProj;
    D3DXMATRIXA16 cameraWorldViewProj = worldMatrix * cameraViewProj;

    // Fill in frame constants
    {
        D3D11_MAPPED_SUBRESOURCE mappedResource;
        d3dDeviceContext->Map(mPerFrameConstants, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
        PerFrameConstants* constants = static_cast<PerFrameConstants *>(mappedResource.pData);

        constants->mCameraWorldViewProj = cameraWorldViewProj;
        constants->mCameraWorldView = worldMatrix * cameraView;
        constants->mCameraViewProj = cameraViewProj;
        constants->mCameraProj = cameraProj;
        // NOTE: Complementary Z => swap near/far back
        constants->mCameraNearFar = D3DXVECTOR4(viewerCamera->GetFarClip(), viewerCamera->GetNearClip(), 0.0f, 0.0f);

        constants->mFramebufferDimensionsX = mGBufferWidth;
        constants->mFramebufferDimensionsY = mGBufferHeight;
        constants->mFramebufferDimensionsZ = 0;     // Unused
        constants->mFramebufferDimensionsW = 0;     // Unused

        constants->mUI = *ui;
        
        d3dDeviceContext->Unmap(mPerFrameConstants, 0);
    }

    // Geometry phase
    if (mesh_opaque.IsLoaded()) {
        mesh_opaque.ComputeInFrustumFlags(cameraWorldViewProj);
    }
    if (mesh_alpha.IsLoaded()) {
        mesh_alpha.ComputeInFrustumFlags(cameraWorldViewProj);
    }

    // Setup lights
    ID3D11ShaderResourceView *lightBufferSRV = SetupLights(d3dDeviceContext, cameraView);

    // Forward rendering takes a different path here
    if (ui->lightCullTechnique == CULL_FORWARD_NONE) {
        RenderForward(d3dDeviceContext, mesh_opaque, mesh_alpha, lightBufferSRV, viewerCamera, viewport, ui, false);
    } else if (ui->lightCullTechnique == CULL_FORWARD_PREZ_NONE) {
        RenderForward(d3dDeviceContext, mesh_opaque, mesh_alpha, lightBufferSRV, viewerCamera, viewport, ui, true);
    } else {
        RenderGBuffer(d3dDeviceContext, mesh_opaque, mesh_alpha, viewerCamera, viewport, ui);
        ComputeLighting(d3dDeviceContext, lightBufferSRV, viewport, ui);
    }

    // Render skybox and tonemap
    RenderSkyboxAndToneMap(d3dDeviceContext, backBuffer, skybox,
        mDepthBuffer->GetShaderResource(), viewport, ui);
}
开发者ID:,项目名称:,代码行数:68,代码来源:


注:本文中的CDXUTSDKMesh::ComputeInFrustumFlags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。