glslang/Test/coord_conventions.frag
ZhiqianXia 438999d24f 1. refine the check for "origin_upper_left" and "pixel_center_integer"
2. gl_FragCoord can be used at ogl140 with extension "GL_ARB_fragment_coord_conventions".




Signed-off-by: ZhiqianXia <xzq0528@outlook.com>
2022-03-01 15:06:04 +08:00

36 lines
720 B
GLSL

#version 140
#extension GL_ARB_fragment_coord_conventions: require
#extension GL_ARB_explicit_attrib_location : enable
#ifdef GL_ES
precision mediump float;
#endif
in vec4 i;
layout (origin_upper_left,pixel_center_integer) in vec4 gl_FragCoord;
layout (location = 0) out vec4 myColor;
const float eps=0.001;
void main()
{
myColor = vec4(0.2);
if (gl_FragCoord.y >= 10) {
myColor.b = 0.8;
}
if (gl_FragCoord.y == trunc(gl_FragCoord.y)) {
myColor.g = 0.8;
}
if (gl_FragCoord.x == trunc(gl_FragCoord.x)) {
myColor.r = 0.8;
}
vec4 diff = gl_FragCoord - i;
if (abs(diff.z)>eps)
myColor.b = 0.5;
if (abs(diff.w)>eps)
myColor.a = 0.5;
}