# Material Spotlight

**Group:** 3D and WebGL scenes  
**Recording:** [https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/material-spotlight.mp4](https://s4xw77gvirailb62.public.blob.vercel-storage.com/lab/material-spotlight.mp4)  
**Source:** [https://ui.aryank.space/components/material-spotlight](https://ui.aryank.space/components/material-spotlight)  
**Human:** https://blankinterfaces.com/lab/material-spotlight

---

## What it is

A cursor-driven material reveal on a 3D model. A near-matte standard material lit by a room-environment IBL gets a shader patch that carves a soft sphere of low-roughness, darker diffuse around the pointer's world-space hit — a wet, polished spotlight that follows the cursor and eases away. Three.js + WebGL.

## Behaviour

### A patch, not a new shader

onBeforeCompile splices four small chunks into MeshStandardMaterial — it keeps all of the standard PBR lighting and only overrides roughness and diffuse inside the sphere of influence.

### World-space, ray-picked

The cursor is ray-cast onto a plane to get a world point; the fragment shader measures distance to it, so the spotlight sticks to the surface in 3D rather than sliding across the screen.

### Eased, never snapped

Both the hit point and the activation amount lerp every frame, so the spot glides to the cursor and fades out smoothly when the pointer leaves.

---

[View all content](https://blankinterfaces.com/sitemap.md)
