1layout(local_size_x = 16, local_size_y = 16) in; 2 3layout(rgba32f, binding=0) writeonly texture2D dest; 4 5void main () { 6 half4 pixel = half4(0.0, 0.0, 0.0, 1.0); 7 8 float max_x = 5.0; 9 float max_y = 5.0; 10 float x = (float(sk_GlobalInvocationID.x * 2 - textureWidth(dest)) / float(textureWidth(dest))); 11 float y = (float(sk_GlobalInvocationID.y * 2 - textureHeight(dest)) / float(textureHeight(dest))); 12 float3 ray_origin = float3(0.0, 0.0, -1.0); 13 float3 ray_target = float3(x * max_x, y * max_y, 0.0); 14 15 float3 sphere_center = float3(0.0, 0.0, -10.0); 16 float sphere_radius = 1.0; 17 18 float3 t_minus_c = ray_target - sphere_center; 19 float b = dot(ray_origin, t_minus_c); 20 float c = dot(t_minus_c, t_minus_c) - sphere_radius * sphere_radius; 21 float bsqmc = b * b - c; 22 23 if (bsqmc >= 0.0) { 24 pixel = half4(0.4, 0.4, 1.0, 1.0); 25 } 26 27 textureWrite(dest, sk_GlobalInvocationID.xy, pixel); 28} 29