| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <!--
- Copyright (C) 2009-2018, Panagiotis Christopoulos Charitos and contributors.
- All rights reserved.
- Code licensed under the BSD License.
- http://www.anki3d.org/LICENSE
- -->
- <shaderProgram>
- <mutators>
- <mutator name="TYPE" values="0 1"/> <!-- 0: write to depth&color, 1: write to depth -->
- <mutator name="SAMPLE_RESOLVE_TYPE" values="0 1 2"/> <!-- 0: average, 1: min, 2: max -->
- <mutator name="COPY_TO_CLIENT" values="0 1"/>
- </mutators>
- <shaders>
- <shader type="vert">
- <source><![CDATA[
- #include "shaders/QuadVert.glsl"
- ]]></source>
- </shader>
- <shader type="frag">
- <source><![CDATA[
- #include "shaders/Common.glsl"
- #define AVG 0
- #define MIN 1
- #define MAX 2
- #if COPY_TO_CLIENT
- struct PushConsts
- {
- uvec4 textureSize;
- };
- ANKI_PUSH_CONSTANTS(PushConsts, u_regs);
- layout(std430, ANKI_SS_BINDING(0, 0)) writeonly buffer s1_
- {
- float u_clientBuf[];
- };
- #endif
- layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_depthRt;
- layout(location = 0) in vec2 in_uv;
- layout(location = 0) out float out_color;
- void main()
- {
- vec4 depths = textureGather(u_depthRt, in_uv, 0);
- #if SAMPLE_RESOLVE_TYPE == MIN
- vec2 mind2 = min(depths.xy, depths.zw);
- out_color = min(mind2.x, mind2.y);
- #elif SAMPLE_RESOLVE_TYPE == MAX
- vec2 max2 = max(depths.xy, depths.zw);
- out_color = max(max2.x, max2.y);
- #elif SAMPLE_RESOLVE_TYPE == AVG
- out_color = dot(depths, vec4(1.0 / 4.0));
- #else
- # error See file
- #endif
- #if TYPE == 0
- gl_FragDepth = out_color;
- #endif
- #if COPY_TO_CLIENT
- u_clientBuf[uint(gl_FragCoord.y) * u_regs.textureSize.x + uint(gl_FragCoord.x)] = out_color;
- #endif
- }
- ]]></source>
- </shader>
- </shaders>
- </shaderProgram>
|