| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma anki mutator BLUE_NOISE 0 1
- #pragma anki mutator BLOOM_ENABLED 0 1
- #pragma anki mutator DBG_ENABLED 0 1
- ANKI_SPECIALIZATION_CONSTANT_U32(LUT_SIZE, 0u);
- ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 1u);
- ANKI_SPECIALIZATION_CONSTANT_U32(MOTION_BLUR_SAMPLES, 3u);
- #pragma anki start vert
- #include <AnKi/Shaders/QuadVert.glsl>
- #pragma anki end
- #pragma anki start frag
- #include <AnKi/Shaders/Common.glsl>
- #include <AnKi/Shaders/Functions.glsl>
- #include <AnKi/Shaders/MotionBlur.glsl>
- layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
- layout(set = 0, binding = 1) uniform sampler u_linearAnyClampSampler;
- layout(set = 0, binding = 2) uniform sampler u_trilinearRepeatSampler;
- layout(set = 0, binding = 3) uniform ANKI_RP texture2D u_lightShadingRt;
- layout(set = 0, binding = 4) uniform ANKI_RP texture2D u_ppsBloomLfRt;
- layout(set = 0, binding = 5) uniform ANKI_RP texture3D u_lut;
- layout(set = 0, binding = 6) uniform ANKI_RP texture2D u_blueNoise;
- layout(set = 0, binding = 7) uniform texture2D u_motionVectorsRt;
- layout(set = 0, binding = 8) uniform texture2D u_depthRt;
- #if DBG_ENABLED
- layout(set = 0, binding = 9) uniform ANKI_RP texture2D u_dbgOutlineRt;
- #endif
- layout(push_constant, std140) uniform b_pc
- {
- Vec3 u_padding0;
- U32 u_frameCount;
- };
- layout(location = 0) in Vec2 in_uv;
- layout(location = 0) out ANKI_RP Vec3 out_color;
- ANKI_RP Vec3 colorGrading(ANKI_RP Vec3 color)
- {
- const ANKI_RP Vec3 LUT_SCALE = Vec3((F32(LUT_SIZE) - 1.0) / F32(LUT_SIZE));
- const ANKI_RP Vec3 LUT_OFFSET = Vec3(1.0 / (2.0 * F32(LUT_SIZE)));
- color = min(color, Vec3(1.0));
- const ANKI_RP Vec3 lutCoords = color * LUT_SCALE + LUT_OFFSET;
- return textureLod(u_lut, u_trilinearRepeatSampler, lutCoords, 0.0).rgb;
- }
- void main()
- {
- const Vec2 uv = in_uv;
- if(MOTION_BLUR_SAMPLES > 0u)
- {
- out_color = motionBlur(u_motionVectorsRt, u_nearestAnyClampSampler, u_lightShadingRt, Vec2(FB_SIZE),
- u_linearAnyClampSampler, uv, MOTION_BLUR_SAMPLES);
- }
- else
- {
- out_color = textureLod(u_lightShadingRt, u_linearAnyClampSampler, uv, 0.0).rgb;
- }
- #if BLOOM_ENABLED
- const ANKI_RP Vec3 bloom = textureLod(u_ppsBloomLfRt, u_linearAnyClampSampler, uv, 0.0).rgb;
- out_color += bloom;
- #endif
- out_color = colorGrading(out_color);
- #if BLUE_NOISE
- const Vec2 bnUvw = Vec2(FB_SIZE) / Vec2(64.0) * uv;
- ANKI_RP Vec3 blueNoise = textureLod(u_blueNoise, u_trilinearRepeatSampler, bnUvw, 0.0).rgb;
- blueNoise = animateBlueNoise(blueNoise, u_frameCount);
- blueNoise = blueNoise * 2.0 - 1.0;
- blueNoise = sign(blueNoise) * (1.0 - sqrt(1.0 - abs(blueNoise)));
- out_color += blueNoise / 255.0;
- #endif
- #if DBG_ENABLED
- const ANKI_RP Vec4 dbg = textureLod(u_dbgOutlineRt, u_linearAnyClampSampler, uv, 0.0);
- out_color = mix(out_color, dbg.rgb, dbg.a);
- #endif
- }
- #pragma anki end
|