| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <!--
- 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="COLOR_TEXTURE" values="0 1"/>
- <mutator name="DITHERED_DEPTH_TEST" values="0 1"/>
- </mutators>
- <inputs>
- <input name="INSTANCE_COUNT" type="uint" const="1"/>
- </inputs>
- <shaders>
- <shader type="vert">
- <source><![CDATA[
- #include "shaders/Common.glsl"
- layout(location = 0) in vec3 in_position;
- #if COLOR_TEXTURE == 1
- layout(location = 1) in vec2 in_uv;
- layout(location = 0) out vec2 out_uv;
- #endif
- layout(ANKI_UBO_BINDING(1, 0), row_major) uniform u0_
- {
- mat4 u_mvp[INSTANCE_COUNT];
- vec4 u_color;
- };
- out gl_PerVertex
- {
- vec4 gl_Position;
- };
- void main()
- {
- #if COLOR_TEXTURE == 1
- out_uv = in_uv;
- #endif
- gl_Position = u_mvp[gl_InstanceID] * vec4(in_position, 1.0);
- }
- ]]></source>
- </shader>
- <shader type="frag">
- <source><![CDATA[
- #include "shaders/Common.glsl"
- #if COLOR_TEXTURE == 1
- layout(location = 0) in vec2 in_uv;
- layout(ANKI_TEX_BINDING(1, 0)) uniform sampler2D u_tex;
- #endif
- layout(ANKI_UBO_BINDING(1, 0), row_major) uniform u0_
- {
- mat4 u_mvp[INSTANCE_COUNT];
- vec4 u_color;
- };
- // NOTE: Don't eliminate the binding because it confuses the descriptor set creation
- #if DITHERED_DEPTH_TEST == 1 || 1
- layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_depthRt;
- #endif
- layout(location = 0) out vec4 out_color;
- void main()
- {
- // Check if we should skip the frag
- #if DITHERED_DEPTH_TEST == 1
- vec2 uv = gl_FragCoord.xy / vec2(textureSize(u_depthRt, 0));
- float depthRef = textureLod(u_depthRt, uv, 0.0).r;
- bool depthTestFailed = gl_FragCoord.z >= depthRef;
- ivec2 fragCoordi = ivec2(gl_FragCoord.xy);
- if(depthTestFailed && ((fragCoordi.x + fragCoordi.y) % 8) != 0)
- {
- discard;
- }
- #endif
- // Write the color
- #if COLOR_TEXTURE == 1
- out_color = texture(u_tex, in_uv) * u_color;
- #else
- out_color = u_color;
- #endif
- }
- ]]></source>
- </shader>
- </shaders>
- </shaderProgram>
|