 	}
 	#endif // ENABLE_whirl
 
+	#ifdef ENABLE_fisheye
+	{
+		vec2 vec = (texcoord0 - kCenter) / kCenter;
+		float r = pow(length(vec), u_fisheye);
+		float angle = atan(vec.y, vec.x);
+		// TODO: tweak this algorithm such that texture coordinates don't depend on conditionals.
+		// see: https://www.opengl.org/wiki/Sampler_%28GLSL%29#Non-uniform_flow_control
+		if (r <= 1.0)
+		{
+			texcoord0 = kCenter + r * vec2(cos(angle), sin(angle)) * kCenter;
+		}
+	}
+	#endif // ENABLE_fisheye
+
 	gl_FragColor = texture2D(u_skin, texcoord0);
 
-	// TODO: See if we can/should use actual alpha test.
-	// Does bgfx offer a way to set u_alphaRef? Would that help?
 	if (gl_FragColor.a == 0.0)
 	{
 		discard;

		}
		#endif // ENABLE_color

		gl_FragColor.rgb = convertHSV2RGB(hsv);
	}
	#endif // defined(ENABLE_color) || defined(ENABLE_brightness)
}

#endif

uniform sampler2D u_skin;
#define u_pixelate_half vec2(0.5,0.5) // TODO

varying vec2 v_texCoord;

#if defined(ENABLE_color) || defined(ENABLE_brightness)
vec3 convertRGB2HSV(vec3 rgb)
{
	float maxRGB = max(max(rgb.r, rgb.g), rgb.b);
