| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- // 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 technique vert pixel
- #include <AnKi/Shaders/QuadVert.hlsl>
- #include <AnKi/Shaders/TonemappingFunctions.hlsl>
- #include <AnKi/Shaders/PackFunctions.hlsl>
- #include <AnKi/Shaders/Include/MiscRendererTypes.h>
- SamplerState g_nearestAnyClampSampler : register(s0);
- Texture2D<Vec4> g_inTex : register(t0);
- Texture2D<Vec4> g_inTex2 : register(t1);
- Texture2D<UVec4> g_integerTex : register(t2);
- struct Consts
- {
- U32 m_drawStyle;
- U32 m_padding0;
- U32 m_padding1;
- U32 m_padding2;
- };
- ANKI_FAST_CONSTANTS(Consts, g_consts)
- #if ANKI_PIXEL_SHADER
- Vec3 uintToColor(U32 v)
- {
- // simple integer hash → 0..1
- const F32 h = frac(sin(v * 12.9898) * 43758.5453);
- const F32 s = 0.6; // moderate saturation
- const F32 val = 0.9; // bright
- // HSV → RGB
- const Vec3 k = Vec3(1.0, 2.0 / 3.0, 1.0 / 3.0);
- const Vec3 p = abs(frac(h + k) * 6.0 - 3.0);
- const Vec3 rgb = val * lerp(1.0, saturate(p - 1.0), s);
- return rgb; // 0..1
- }
- Vec3 main(VertOut input) : SV_TARGET0
- {
- Vec4 rgba = g_inTex.SampleLevel(g_nearestAnyClampSampler, input.m_uv, 0.0);
- switch((DebugRenderTargetDrawStyle)g_consts.m_drawStyle)
- {
- case DebugRenderTargetDrawStyle::kTonemap:
- rgba.xyz = reinhardTonemap(rgba.xyz);
- break;
- case DebugRenderTargetDrawStyle::kGBufferNormal:
- rgba.xyz = unpackNormalFromGBuffer(rgba) / 2.0f + 0.5f;
- break;
- case DebugRenderTargetDrawStyle::kGBufferRoughness:
- rgba.xyz = unpackRoughnessFromGBuffer<F32>(rgba, 0.0).xxx;
- break;
- case DebugRenderTargetDrawStyle::kGBufferMetallic:
- rgba.xyz = unpackSubsurfaceAndMetallicFromGBuffer(rgba).yyy;
- break;
- case DebugRenderTargetDrawStyle::kGBufferSubsurface:
- rgba.xyz = unpackSubsurfaceAndMetallicFromGBuffer(rgba).xxx;
- break;
- case DebugRenderTargetDrawStyle::kGBufferEmission:
- {
- const Vec4 rt2 = g_inTex2.SampleLevel(g_nearestAnyClampSampler, input.m_uv, 0.0);
- const Vec4 rt1 = rgba;
- rgba.xyz = invertReinhardTonemap(Vec3(rt1.z, rt2.x, rt1.w));
- break;
- }
- case DebugRenderTargetDrawStyle::kAlphaOnly:
- rgba.xyz = rgba.www;
- break;
- case DebugRenderTargetDrawStyle::kRedOnly:
- rgba.xyz = rgba.rrr;
- break;
- case DebugRenderTargetDrawStyle::kIntegerTexture:
- {
- const UVec4 val = g_integerTex.SampleLevel(g_nearestAnyClampSampler, input.m_uv, 0.0);
- rgba = Vec4(uintToColor(val.x), 1.0);
- }
- default:
- break;
- }
- return rgba.xyz;
- }
- #endif
|