Skip to content
Skills Library
Science & research · Learning & explanation

raytracing-mathematics

/raytracing-mathematics

Use this skill when the user says 'raytracing math', 'ray-sphere intersection', 'BVH', 'ray-triangle', 'path tracing math', 'acceleration structure'. Explains the geometry and acceleration structures behind ray tracing. Do NOT use for: GPU compute setup (use niche/graphics-math/webgpu-compute-shaders) or game render pipelines (use game/game-engine/render-graph).

Licence
MIT
Last repository change
10.11.2026

Assessment and security

95/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content30 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 10.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill when the user says 'raytracing math', 'ray-sphere intersection', 'BVH', 'ray-triangle', 'path tracing math', 'acceleration structure'. Explains the geometry and acceleration structures behind ray tracing. Do NOT use for: GPU compute setup (use niche/graphics-math/webgpu-compute-shaders) or game render pipelines (use game/game-engine/render-graph).

Triggers from the description

raytracing mathray-sphere intersectionBVHray-trianglepath tracing mathacceleration structure
Original author description

Use this skill when the user says 'raytracing math', 'ray-sphere intersection', 'BVH', 'ray-triangle', 'path tracing math', 'acceleration structure'. Explains the geometry and acceleration structures behind ray tracing. Do NOT use for: GPU compute setup (use niche/graphics-math/webgpu-compute-shaders) or game render pipelines (use game/game-engine/render-graph).

How it works

  1. Purpose
  2. Agent Protocol
  3. Core Mechanics
Original SKILL.md headings · 71 lines, 293 words
SKILL.md preview
---
name: raytracing-mathematics
description: >
  Use this skill when the user says 'raytracing math', 'ray-sphere intersection', 'BVH', 'ray-triangle', 'path tracing math', 'acceleration structure'. Explains the geometry and acceleration structures behind ray tracing. Do NOT use for: GPU compute setup (use niche/graphics-math/webgpu-compute-shaders) or game render pipelines (use game/game-engine/render-graph).
version: "1.0.0"
author: "j4flmao"
license: "MIT"
tags: [niche, graphics, raytracing, math, geometry]
---

# Raytracing Mathematics

## Purpose
Explain the core mathematics of ray tracing: parametric ray equations, ray-primitive intersection (sphere, triangle), and acceleration structures (BVH) that make tracing tractable.

## Agent Protocol

### Trigger
User phrases: "ray-sphere intersection", "BVH traversal", "ray-triangle test", "path tracing math".

### Input Context
- Primitive types and scene scale.
- Precision/perf constraints.

### Output Artifact
Derivations and intersection/accel-structure guidance.

### Response Format
```
Problem: {intersection / traversal}
Formula: {P(t)=O+tD, discriminant, ...}
Accel: {BVH / grid}
```


## Core Mechanics

Raytracing simulates the physical behavior of light to generate photorealistic images. It traces paths of light backwards from the camera into the 3D scene.

### 1. Ray-Sphere Intersection
A Ray is defined mathematically as `P(t) = O + tD` (Origin + time * Direction).
A Sphere is defined as `(P - C)·(P - C) = r^2`.
Substituting the Ray into the Sphere equation yields a quadratic equation (`at^2 + bt + c = 0`). Solving for `t` determines if, and exactly where, the ray hits the sphere.

### 2. Bounding Volume Hierarchies (BVH)
Checking every ray against millions of triangles is computationally impossible. A BVH wraps complex models in simple boxes. If a ray misses the big box, we immediately skip checking all the complex triangles inside it.

### Raytracing Flow Map

```mermaid
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
flowchart TD
    subgraph Camera ["Virtual Camera"]
        A["Shoot Ray through Pixel(x,y)"]
    end
    
    subgraph BVH ["Spatial Acceleration (BVH)"]
        B{"Intersect Root Bounding Box?"}
        C{"Intersect Child Bounding Box?"}
    end
    
    subgraph Math ["Geometry Mathematics"]
        D["Calculate Ray-Triangle Intersection"]
        E["Calculate Surface Normal"]
    end
    
    subgraph Shading ["Light Transport"]
        F["Bounce Ray (Reflection/Refraction)"]
        G["Calculate Color & Shadow"]
    end
    
    A --> B
    B -->|"Yes"| C
    B -->|"No"| H["Render Skybox (Miss)"]
    C -->|"Yes"| D
    D -->|"Hit"| E
    E --> F
    F --> G
```

Versions

The database has no other skills named raytracing-mathematics.

Database snapshot: 13.11.2026 · package version d95e1e2f89bf (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95webgpu-compute-shaders
    Use this skill when the user says 'WebGPU', 'compute shader', 'WGSL', 'workgroup', 'GPGPU in browser', 'storage buffer'. Explains WebGPU compute pipelines, WGSL compute shaders, and workgroup/shared-memory design. Do NOT use for: WebGL rendering, or raytracing geometry math (use…
  • 87roguesquadron-raytracing
    Ray-traced lighting in RogueSquadron64Recomp (RT64's RS64 light pass on top of the game's prelit N64 image). Use for ANY work on RT lights, light presets (roguesq_lights.json, src/video/default_lights.json, the F1 Lights tab), mesh / sprite / level / lamp presets, explosion and…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.