Refraction Pass

A reusable two-buffer refraction render pass using backface normals and a live scene environment. Works with your own Mesh or InstancedMesh on layer 1.

Exact preview of Refraction Pass
Type
Component
Category
WebGL
Source license
MIT
Collection
Open Source Experiences

View source in the repository

Usage

// Place this example in vendor/experiences/substance/src/example.jsx.
// Use that project's isolated dependencies and Vite setup (see its README).
// Rebuild the included native runtimes with: npm run build:experiences

import { useRef } from 'react';
import { Canvas } from '@react-three/fiber';
import { RefractionPass } from './parts/RefractionPass';

function Glass() {
  const mesh = useRef();
  return <>
    <mesh position={[0, 0, -2]}><planeGeometry args={[10, 8]} /><meshBasicMaterial color="#2fe8c3" /></mesh>
    <mesh ref={mesh} layers={1}><icosahedronGeometry args={[2, 0]} /><meshBasicMaterial /></mesh>
    <RefractionPass meshRef={mesh} />
  </>;
}
export function RefractiveScene() {
  return <Canvas camera={{ position: [0, 0, 8] }}><Glass /></Canvas>;
}

License and credits

The Substance by Paul Henschel. Original upstream source

Read the original MIT license

Credits and asset notices

Third-party assets and dependencies

Diamond by RBG_illustrations (https://sketchfab.com/StarkIndustries), CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Source: https://sketchfab.com/3d-models/diamond-7acd98d5c8df4e04a73ea5d5a81c8911. Original GLB retained; centered/scaled in runtime.

Photo credits: Barry Marsh (field-01/02), author-released public domain; Cornettesax (field-03), Kleseus (field-04), NonNerd (field-05), CC0. Source and license links: /experiences/substance/photo-credits.json.

Helvetiker Bold copyright 2004 MAGENTA Ltd.; full permissive font notice included at /experiences/substance/FONT-LICENSE.txt. Original MOONGET font and unclear photographs omitted.

Keep the original source and media notices with your copy.

Explore more

  • Liquid FormExact preview of Liquid Form

    A centered silver ray-marched liquid form with authored studio reflections and pointer-responsive camera drift.

  • Boarding PassExact preview of Boarding Pass

    A live flight pass whose changed gate and times roll over like a departures board.

  • Aurora TextExact preview of Aurora Text

    Multi-colour aurora motion within a large type specimen.

Frontfield homepage