| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma anki mutator FILM_GRAIN 0 1
- #pragma anki mutator BLOOM 0 1
- #pragma anki mutator DBG 0 1
- #pragma anki mutator SHARPEN 0 1
- #pragma anki technique vert pixel
- #include <AnKi/Shaders/QuadVert.hlsl>
- #if ANKI_PIXEL_SHADER
- # include <AnKi/Shaders/Functions.hlsl>
- SamplerState g_linearAnyClampSampler : register(s0);
- Texture2D<Vec4> g_lightShadingRt : register(t0);
- Texture2D<Vec4> g_ppsBloomLfRt : register(t1);
- # if DBG
- Texture2D<Vec4> g_dbgOutlineRt : register(t2);
- # endif
- struct Constants
- {
- UVec4 m_fsrConsts0;
- F32 m_filmGrainStrength;
- U32 m_frameCount;
- U32 m_padding1;
- U32 m_padding2;
- };
- ANKI_FAST_CONSTANTS(Constants, g_consts)
- // FSR begin
- # define A_GPU 1
- # define A_HLSL 1
- # define A_HALF 1
- # include <ThirdParty/FidelityFX/ffx_a.h>
- AH4 FsrRcasLoadH(ASW2 p)
- {
- return AH4(g_lightShadingRt.Load(IVec3(p, 0)));
- }
- void FsrRcasInputH(inout AH1 r, inout AH1 g, inout AH1 b)
- {
- ANKI_MAYBE_UNUSED(r);
- ANKI_MAYBE_UNUSED(g);
- ANKI_MAYBE_UNUSED(b);
- }
- # define FSR_RCAS_H 1
- # include <ThirdParty/FidelityFX/ffx_fsr1.h>
- // FSR end
- Vec4 main(VertOut input) : SV_TARGET0
- {
- const Vec2 uv = input.m_uv;
- ANKI_MAYBE_UNUSED(uv);
- HVec3 outColor;
- # if SHARPEN
- FsrRcasH(outColor.r, outColor.g, outColor.b, input.m_svPosition.xy, g_consts.m_fsrConsts0);
- # else
- outColor = g_lightShadingRt.SampleLevel(g_linearAnyClampSampler, uv, 0.0).rgb;
- # endif
- # if BLOOM
- const HVec3 bloom = g_ppsBloomLfRt.SampleLevel(g_linearAnyClampSampler, uv, 0.0).rgb;
- outColor += bloom;
- # endif
- # if FILM_GRAIN
- const F32 dt = 1.0;
- outColor = filmGrain<F32>(outColor, uv, g_consts.m_filmGrainStrength, F32(g_consts.m_frameCount % 0xFFFFu) * dt);
- # endif
- # if DBG
- const HVec4 dbg = g_dbgOutlineRt.SampleLevel(g_linearAnyClampSampler, uv, 0.0);
- outColor = lerp(outColor, dbg.rgb, dbg.a);
- # endif
- return Vec4(outColor, 0.0);
- }
- #endif // ANKI_PIXEL_SHADER
|