home/ atoms/ specular-sky-reflection

Sky specular is computed by reflecting the view ray and checking if the reflection hits the sky

A surface that is wet or slightly shiny reflects the sky. In shader rendering: compute the reflected view ray (reflect(rd, nor)), check the y-component of the reflection — if positive, the reflection hits sky; if negative, it hits ground. The sky contribution to specular is then the sky color multiplied by a smoothstep on ref.y (sharp at 0 for polished, smooth for rough). Multiply by diffuse-sky occlusion to prevent open-sky reflections in occluded areas. This avoids a full cube-map lookup; the analytic sky function is evaluated in the reflection direction.

Examples

vec3 ref = reflect(rd, nor); float skySpec = smoothstep(-0.1, 0.1, ref.y); col += skySpec * skyCol * occ;

Assessment

What visual difference do you see if you replace smoothstep(-0.1, 0.1, ref.y) with step(0.0, ref.y)? Describe the effect on a wet ground plane.

“reflect the view vector with the normal, and if this thing is going up, which means the white component is above a threshold step, let's say zero, then we have full specularity”
corpus · inigo-quilez-live-coding-happy-jumping-video · chunk 23