#include <metal_stdlib>
using namespace metal;

kernel void compute_astral_aura(
    texture2d<float, access::write> outTexture [[texture(0)]],
    constant float &time [[buffer(0)]],
    uint2 gid [[thread_position_in_grid]]
) {
    if (gid.x >= outTexture.get_width() || gid.y >= outTexture.get_height()) return;
    float2 center = float2(outTexture.get_width(), outTexture.get_height()) * 0.5;
    float dist = length(float2(gid) - center);
    float glow = exp(-dist * 0.03) * (0.8 + 0.2 * sin(time * 4.0));
    float4 color = float4(0.9, 0.7, 0.2, glow);
    outTexture.write(color, gid);
}
