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