| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <Atom/Features/SrgSemantics.azsli>
- ShaderResourceGroup PassSrg : SRG_PerPass
- {
- Texture2D<float> m_modifier;
- RWTexture2D<float4> m_inputOutput;
- Sampler LinearSampler
- {
- MinFilter = Linear;
- MagFilter = Linear;
- MipFilter = Linear;
- AddressU = Clamp;
- AddressV = Clamp;
- AddressW = Clamp;
- };
- }
- [numthreads(16,16,1)]
- void MainCS(uint3 dispatch_id: SV_DispatchThreadID)
- {
- // Get output texture dimensions
- uint2 outputDimensions;
- PassSrg::m_inputOutput.GetDimensions(outputDimensions.x, outputDimensions.y);
- uint2 outPixel = dispatch_id.xy;
- // Early out
- if(outPixel.x >= outputDimensions.x || outPixel.y >= outputDimensions.y)
- {
- return;
- }
-
- // Calculate the size of a pixel in screen UV space
- float2 pixelSize = 1.0f / float2(outputDimensions.xy);
- // Want to sample at the center of the pixel, so we need a half pixel offset
- float2 halfPixelSize = pixelSize * 0.5f;
- // Sample the modifier texture
- float2 sampleUV = mad(float2(outPixel.xy), pixelSize, halfPixelSize);
- float modifier = PassSrg::m_modifier.SampleLevel(PassSrg::LinearSampler, sampleUV, 0).r;
- // Sample the output target
- float4 sampleColor = PassSrg::m_inputOutput[outPixel].rgba;
- // Apply the modifer as a simple multiplier
- sampleColor.rgb *= modifier.xxx;
- // Write the modified value to the target
- PassSrg::m_inputOutput[outPixel] = sampleColor;
- }
|