1
2/*
3Copyright (c) 2019 The Khronos Group Inc.
4Use of this source code is governed by an MIT-style license that can be
5found in the LICENSE.txt file.
6*/
7
8
9#ifdef GL_ES
10#ifdef GL_FRAGMENT_PRECISION_HIGH
11precision highp float;
12#else
13precision mediump float;
14#endif
15#endif
16varying vec4 color;
17
18void main (void)
19{
20	const float M_PI = 3.14159265358979323846;
21	float x = 2.0 * (color.g - 0.5);
22	float y = 2.0 * (color.b - 0.5);
23	const float epsilon = 1.0e-4;
24	gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
25
26	// Avoid evaluating atan(0, x) for x < epsilon because it's implementation-dependent
27	if(x > epsilon || abs(y) > epsilon)
28	{
29		gl_FragColor = vec4(atan(y, x) / (2.0 * M_PI) + 0.5, 0.0, 0.0, 1.0);
30	}
31}
32