Qt Quick 3D - Scene Effects Example
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float value;
};
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
#define TWO_PI 6.28318530718
void main()
{
vec2 st = qt_TexCoord0;
vec4 color = vec4(1.0);
// Use polar coordinates instead of cartesian
vec2 toCenter = vec2(0.5)-st;
float angle = atan(toCenter.y,toCenter.x);
float radius = length(toCenter)*2.0;
if (radius <= 1.0) {
color.rgb = hsv2rgb(vec3((angle/TWO_PI)+0.5,radius,value));
} else {
discard;
}
fragColor = color * qt_Opacity;
}