Generated banner for 3d Sky Rays
Generated logo for 3d Sky Rays

3d Sky Rays

Meng ToCommunityCreated by Meng To

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Add sun shafts and crepuscular rays to a Three.js or equivalent 3D scene, using scene occlusion, a projected sun position, controlled foreground spill, and scalable post-processing. Use for rays of light from the sky, sunlight through trees or roofs, and golden-hour architectural scenes.
— the description by Meng To

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a technical guide for implementing sun shafts and crepuscular rays in 3D scenes. It covers the creation of an occlusion-aware ray pass, including masking, sun projection, and additive compositing. The approach focuses on integrating with existing renderers, managing shader logic for WebGL or WebGPU, and tuning the visual output through sample counts and thresholding to ensure rays interact correctly with scene geometry like foliage and rooflines.

What it does

  • Generates sun shafts and crepuscular rays using screen-space post-processing.
  • Creates occlusion masks to ensure rays are blocked by scene geometry.
  • Provides a shader-based accumulation algorithm for ray intensity and decay.
  • Integrates ray effects into existing linear HDR render pipelines.
  • Offers guidance on optimizing ray buffers and sample counts for different hardware.
  • Includes verification steps to ensure visual stability during camera movement.

When to use it

  • When adding atmospheric lighting effects like sunbeams through trees or roofs.
  • When developing golden-hour architectural visualizations in 3D.
  • When you need to implement custom post-processing shaders in Three.js.
  • When you need to ensure light shafts respect existing scene alpha and depth.

Advantages

  • Provides a structured approach to managing occlusion in screen-space.
  • Allows for scalable performance by adjusting sample counts and buffer resolution.
  • Maintains visual consistency by using a single normalized world-space sun direction.
  • Includes specific logic to prevent common artifacts like rectangular foliage halos.

Usage examples

“How do I implement crepuscular rays in my Three.js scene?”
The agent provides the shader logic for an occlusion-aware ray pass, instructions for creating a sky mask, and guidance on integrating the effect into your existing render pipeline.
“My sun shafts look like solid rectangles around leaves, how do I fix this?”
The agent explains how to match foliage alpha cutouts and vertex motion in the mask pass to ensure the rays are properly occluded by the leaf geometry.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/mengto/3d-sky-rays/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip 3d-sky-rays.zip -d .agents/skills

Documentation by Meng To

3D Sky Rays

Make the light appear to travel through gaps in the scene. Roof edges and foliage should shape the shafts as the camera moves.

Fit the existing renderer

Inspect the renderer version, render targets, alpha usage, depth path, tone mapping, and post-processing order. Keep the existing WebGL or WebGPU backend. The shader recipe below describes a WebGL screen-space effect; implement the equivalent in the project's node/render pipeline when using WebGPU.

Use one normalized world-space direction pointing toward the sun for the sky, ray source, and directional lighting. If the art direction deliberately offsets the visible sun from the lighting sun, document and control that offset in one place.

Build an occlusion-aware ray pass

  1. Render scene color in linear HDR. Obtain a mask identifying open sky: white for sky, black for opaque occluders. Match foliage alpha cutouts and vertex motion in the mask pass so leaves do not become solid rectangles.

  2. A dedicated sky mask is the portable default. Reusing scene alpha is an optimization only when every preceding pass preserves its meaning: sky alpha 0, opaque geometry alpha 1. Transparent glass, particles, canvas compositing, and AO can break that convention; inspect the mask directly.

  3. Project a point along the sun direction from the camera. Reject a source behind the camera before using projected coordinates. Convert NDC to UV with uv = ndc.xy * 0.5 + 0.5; account for the pipeline's texture orientation.

  4. For each ray-buffer pixel, march toward the sun UV. Sample sky visibility multiplied by sky brightness above an HDR threshold. Accumulate decaying samples and divide by the sum of weights so sample-count changes do not change exposure.

  5. Reject UVs outside the mask texture. Fade the effect as the sun moves far off-screen; clamping samples to the edge creates bright bands. A small overscan margin is useful for a sun just outside the frame.

  6. Composite the ray color additively into linear scene color before the final tone-map/output transform. Preserve the input alpha if later passes need it.

Core accumulation, expressed as pseudocode:

step = (pixelUV - sunUV) * density / sampleCount
sampleUV = pixelUV - step * jitter
sum = 0; weightSum = 0; weight = 1
repeat sampleCount times:
    sampleUV -= step
    if sampleUV is inside the texture:
        energy = max(luminance(scene(sampleUV)) - threshold, 0)
        sum += min(energy, energyCap) * skyMask(sampleUV) * weight
    weightSum += weight
    weight *= decay
rays = sum / max(weightSum, epsilon)

Use aspect-correct distance from the source for radial falloff. Keep any angular variation broad and subtle; the scene occlusion should provide most of the structure. On opaque foreground surfaces, attenuate the screen-space overlay strongly so wood and stone retain contrast. This is an artistic approximation, not a substitute for depth-integrated volumetric scattering.

Tune appearance before cost

Start with a low sun, warm neutral tint, visible gaps, and restrained intensity. View from behind a roofline and through a canopy. Whiteout usually means excessive intensity or a bad mask, not insufficient bloom.

Use roughly 24–48 samples and a half-resolution ray buffer as a starting experiment; increase only when visible banding warrants it. Seijaku's reference uses 72 samples, which is a reference choice rather than a required quality floor. Smooth noise jitter can reduce bands, but animated jitter can shimmer; use stable noise for still or reduced-motion views unless temporal accumulation is available.

Skip the pass when its contribution is zero. Resize its buffers with the drawing buffer, dispose replaced targets, and measure its incremental GPU/frame cost with rays enabled and disabled. Avoid synchronous GPU readback in the render loop.

Verify

  • Roofs and leaf silhouettes visibly interrupt shafts; no rectangular foliage halos.

  • Turning away from the sun removes the effect without a mirrored source or flash.

  • Entering an interior preserves surface contrast; unrelated emissive objects do not become suns.

  • Camera orbit, portrait resize, dusk, and a static reduced-motion frame remain stable.

  • Desktop and mobile checks include shader errors, frame time, and the actual ray-buffer size.

Reference

Read REFERENCES.md for the source and renderer documentation. In Seijaku, inspect GodRayShader, makePost, and the projected-source update. Its alpha-mask convention depends on its complete render pipeline; do not transplant that assumption alone.

Files

agents/openai.yaml

interface:
  display_name: "3D Sky Rays"
  short_description: "Occlusion-aware sunlight shafts for 3D scenes"
  default_prompt: "Use $3d-sky-rays to add sky rays shaped by the roofs and foliage in this scene."

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Meng To
Publisher
Meng To (Community)
Source
MengTo/Skills · agent-skills/3d/3d-sky-rays · commit 5ea1661
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Meng To or Meng To.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download 3d-sky-rays.zip