-
Notifications
You must be signed in to change notification settings - Fork 405
DualPostProcess
DirectXTK | PostProcess |
---|
Performs basic post-processing with a built-in set of shaders which operate using two input textures.
#include "PostProcess.h"
Construction requires a Direct3D 12 device, a shader selection parameter, and state description:
std::unique_ptr<DualPostProcess> postProcess;
RenderTargetState rtState(m_deviceResources->GetBackBufferFormat(),
m_deviceResources->GetDepthBufferFormat());
postProcess = std::make_unique<DualPostProcess>(device, rtState, DualPostProcess::Merge);
For exception safety, it is recommended you make use of the C++ RAII pattern and use a std::unique_ptr
or std::shared_ptr
DualPostProcess can be configured to use various pixel shaders when creating the instance:
- Merge: Combines two images using provided weights.
- BloomCombine: Combines the bloom texture produced by BasicPostProcess in a final pass with the original scene texture.
-
SetSourceTexture
,SetSourceTexture2
is used to set the input texture as a Shader Resource View Descriptor. -
SetMergeParameters
is used to set the two weights for the Merge shader. Setting these to 0.5,0.5 will blend two images, while setting them both to 1.0 will add the two images together. -
SetBloomCombineParameters
sets the various parameters for the BloomCombine shader as the final pass of implementing a bloom effect.
A simple use of the Merge effect would be to dissolve between two textures (either or both of which could be render textures):
ppMerge = std::make_unique<DualPostProcess>(device, rtstate, DualPostProcess::Merge);
// Texture1 is SRV descriptor for the first texture
// Texture2 is SRV descriptor for the second texture
// Both must be in D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE state
ppMerge->SetSourceTexture(m_resourceDescriptors->GetGpuHandle(Descriptors::Texture1));
ppMerge->SetSourceTexture2(m_resourceDescriptors->GetGpuHandle(Descriptors::Texture2));
// Smoothly animate the value t from 0.0 to 1.0 over the time you want the dissolve to take.
ppMerge->SetMergeParameters(t, 1.f - t);
ppMerge->Process(commandList);
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Xbox One
- Xbox Series X|S
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- MinGW 12.2, 13.2
- CMake 3.20