blob: 3f4beddffd6c3b8981f84eac49398c5543854bb0 [file] [log] [blame]
layout(local_size_x = 16, local_size_y = 16) in;
layout(rgba32f, binding=0) writeonly texture2D dest;
void main () {
half4 pixel = half4(0.0, 0.0, 0.0, 1.0);
float max_x = 5.0;
float max_y = 5.0;
float x = (float(sk_GlobalInvocationID.x * 2 - textureWidth(dest)) / float(textureWidth(dest)));
float y = (float(sk_GlobalInvocationID.y * 2 - textureHeight(dest)) / float(textureHeight(dest)));
float3 ray_origin = float3(0.0, 0.0, -1.0);
float3 ray_target = float3(x * max_x, y * max_y, 0.0);
float3 sphere_center = float3(0.0, 0.0, -10.0);
float sphere_radius = 1.0;
float3 t_minus_c = ray_target - sphere_center;
float b = dot(ray_origin, t_minus_c);
float c = dot(t_minus_c, t_minus_c) - sphere_radius * sphere_radius;
float bsqmc = b * b - c;
if (bsqmc >= 0.0) {
pixel = half4(0.4, 0.4, 1.0, 1.0);
}
textureWrite(dest, sk_GlobalInvocationID.xy, pixel);
}