#version 330 uniform sampler2D texture0; uniform vec2 resolution; uniform float time; // Screen-space UV of the sun — kept off in a corner like a low sun rather // than dead center, so the rays read as directional light rather than a // starburst sitting on top of the view. This shader samples the already- // rendered scene texture (RenderPostFX draws it via a source rect with a // negative height to correct raylib's render-texture V-flip for texture0 // itself), but fragTexCoord's V still runs top-of-screen=0 in that same // flipped sense — so a Y near 0 here actually lands near the BOTTOM of // what's on screen; 0.88 is what puts the sun near the top. uniform vec2 sunScreenPos = vec2(0.82, 0.88); uniform float rayCount = 10.0; uniform float raySharpness = 3.0; uniform float rayStrength = 0.35; uniform float raySpeed = 0.03; in vec2 fragTexCoord; out vec4 finalColor; void main() { vec2 uv = fragTexCoord; vec4 baseColor = texture(texture0, uv); // Cheap screen-space light shafts: no scene depth/occlusion to sample, // so this fakes them as angular streaks radiating from the sun position // that fade out with distance, rather than true raymarched shafts. vec2 aspectFix = vec2(resolution.x / resolution.y, 1.0); vec2 toSun = (uv - sunScreenPos) * aspectFix; float dist = length(toSun); float angle = atan(toSun.y, toSun.x); float streaks = sin(angle * rayCount + time * raySpeed) * 0.5 + 0.5; streaks = pow(streaks, raySharpness); float falloff = clamp(1.0 - dist * 0.9, 0.0, 1.0); falloff *= falloff; vec3 rayColor = vec3(1.0, 0.92, 0.75) * streaks * falloff * rayStrength; finalColor = vec4(baseColor.rgb + rayColor, baseColor.a); }