Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
R3F24: done. in-patched 0.9717 (drei's MeshWobbleMaterial and MeshDistortMaterial, an app's own waves kept through userData.shader) and in-reflector 0.9256 (drei's MeshReflectorMaterial, which closes R3F23) against three.js, both in tools/parity.sh; the full list of 41 passes, every other case as it was. docs/r3f.feature tags R3F23 and R3F24 @done with their status; the r3f guide lists patched materials and render targets as drawn
shinyobjectz20290ff51c97
diff --git a/docs/r3f.feature b/docs/r3f.featureindex a6242cb1..d498ef43 100644--- a/docs/r3f.feature+++ b/docs/r3f.feature@@ -488,6 +488,7 @@ Feature: React Three Fiber both ways: an R3F scene drawn by raea, a raea compositarget raea draws on its GPU (flipsY, onGpu), 0.9397 (0.9125 before); in-tsl-lit, in-lettra, in-tslpost andin-tslpost2 unchanged, in-lettrafx 0.9890 (0.9855 on main without it, its last glyph mid-wipe narrower)+ @doneScenario: R3F23. Render targets are drawn on the GPUGiven what an app draws into a render target itself (`gl.setRenderTarget(t); gl.render(scene, camera)`, drei'suseFBO, <RenderTexture>, <MeshReflectorMaterial>, <MeshPortalMaterial>, three's GPUComputationRenderer, a@@ -547,13 +548,39 @@ Feature: React Three Fiber both ways: an R3F scene drawn by raea, a raea composi# on maps and in shaders). R3F23d: in-fbo 0.9941 and in-pingpong 0.9949 against three.js at frame 12, both in# tools/parity.sh; the full list of 38 passes. Left: in-reflector, whose material's projective read is an# onBeforeCompile patch (R3F24).+ # Status (11-15, done): in-reflector 0.9256 (test/parity/patched.tsx, in tools/parity.sh) with R3F24's patched+ # program. Its mirrored camera copies the screen camera's projection into a camera of its own (fov 50, aspect 1 as+ # made), so a pass camera's lens is now its projection matrix's (passes.ts lensOf: fov, and its aspect where that+ # isn't the target's shape), kept by the engine whatever the image's shape (a rendercam's `aspect`, matchmove's+ # OffAxis). What's left of the gap is the floor, which raea lights lighter than three wherever it is that dark: a+ # plain MeshStandardMaterial of the patch's colour reads (11, 12, 13) against three's (6, 7, 9), as the reflector does.+ @doneScenario: R3F24. onBeforeCompile patchesGiven a material patched by onBeforeCompile (drei's MeshWobbleMaterial and MeshDistortMaterial, a patchedMeshStandardMaterial's vertex displacement)When raea draws itThen the patched GLSL is what runs: three's program for that material with the patch applied, translated as R3F11'sAnd in-patched: SSIM at least 0.92 against three.js+ Status (11-15): built. A MeshStandardMaterial or MeshPhysicalMaterial with an onBeforeCompile of its own is three's+ ShaderLib program handed to it as three hands it (src/input/patched.ts): the material's defines and cloned+ uniforms, patched once a program (again when its version or customProgramCacheKey changes, as three recompiles),+ so a uniform the patch shares (drei's time) or one an app keeps from the patch (userData.shader) is read each+ frame; the material's own values refreshed into it each frame as three's renderer does; the defines three's+ WebGLProgram puts in front for its maps (map, alpha, emissive, roughness, metalness, normal, bump and+ displacement), sides, vertex colours and alpha test, and its light counts at 0. Its lighting is Bevy's, as a lit+ TSL material's is (R3F21): the fragment is cut at <lights_physical_fragment> and writes base, normal and+ roughness, emission and metalness, and the point in world space to four outputs, which raea-sys-three-shader's+ lit GLSL stage returns as its surface (glsl.rs Source lit). A patch past the cut (the light, the output colour)+ is named once and left out; so are aoMap and lightMap, and a physical material's sheen, clearcoat and+ transmission. in-patched 0.9717 (drei's MeshWobbleMaterial and MeshDistortMaterial and an app's own waves kept+ through userData.shader, lit by ambient and a sun) and in-reflector 0.9256 (R3F23), both in tools/parity.sh, and+ the full list of 41 passes, every other case as it was. On+ the way: the white picture a ShaderMaterial gets for a texture with no picture (shader.ts WHITE) was a broken+ PNG (its data cut short, its CRC wrong), so every material given it was refused and drawn in its colour; now a+ decoding one, tested. Tests: test/patched.test.ts (the patched program, patched once, its uniforms each frame,+ maps, a patch past the lights named), glsl.rs a_lit_stage_returns_its_surface, test/shader.test.ts (both+ stand-in pictures decode).Scenario: R3F25. Post-processing: three's TSL passes and postprocessing's other effectsGiven three/webgpu's PostProcessing (`pass(scene, camera)` with bloom, GTAO, SSR, TRAA, DOF, film, ... nodes) ordiff --git a/sdk/guides/craft/bevy/r3f.md b/sdk/guides/craft/bevy/r3f.mdindex 6344aca8..84b4ef7a 100644--- a/sdk/guides/craft/bevy/r3f.md+++ b/sdk/guides/craft/bevy/r3f.md@@ -87,7 +87,11 @@ Drawn: meshes, groups, instanced and batched meshes, points, lines, sprites; stanormal, matcap, shadow, points and line materials; ShaderMaterial and RawShaderMaterial (their GLSL translated and runby raea); TSL node materials, unlit and lit, and TSL compute (`renderer.compute`, `computeAsync`: run on raea's GPU,its storage buffers shared with the node materials that read them, an InstancedMesh with a node material drawn as one-mesh of copies; 0.1.5); textures, environment maps, fog, the background, shadows; drei's+mesh of copies; 0.1.5); standard and physical materials patched by `onBeforeCompile` (drei's `<MeshWobbleMaterial>`,+`<MeshDistortMaterial>` and `<MeshReflectorMaterial>`, an app's own vertex displacement: three's own program with the+patch applied, its surface lit by raea); render targets an app draws itself (a `useFBO`, GPUComputationRenderer's+ping-pong, the reflector's mirrored view: drawn on raea's GPU and read by the materials that use them, 0.1.5);+textures, environment maps, fog, the background, shadows; drei's`<Text>`, `<Sky>`, `<Stars>`, `<Clouds>`, `<ContactShadows>`, `<Environment>`; @react-three/postprocessing's effectsthat raea has (bloom, vignette, depth of field and bokeh, chromatic aberration, lens distortion, SSAO,anti-aliasing, pixelation, tone mapping, brightness, contrast, hue and saturation), and, as raea frame passes running@@ -96,15 +100,17 @@ wave, LUT, ASCII and `<TiltShift2>`; three/webgpu's `PostProcessing` (`RenderPip`pass(scene, camera)` is the frame, its bloom, GTAO, depth of field, FXAA, SMAA and pixelation nodes are raea's, andits film, dot screen, RGB shift, chromatic aberration, LUT, sepia and bleach nodes are frame passes; an `Fn` of thechain's own isn't run. Close, not exact: hemisphere lights, light probes, Phong and toon materials, `<TiltShift>` and-`<GodRays>`, and bloom (raea's, added on top as three's is).+`<GodRays>`, bloom (raea's, added on top as three's is), and a very dark surface, which reads a little lighter than+three's.What raea can't draw is named once in the render's output (`raea/r3f: ...`), and the frame draws without it:- a TSL compute with an indirect dispatch, a texture or a matrix uniform: the scene is drawn without what it computes(one first dispatched after the first frame isn't run either, and points and sprites don't read its buffers yet)-- a pass drawn into a render target other than drei's contact shadows' (an FBO, a portal): the target stays empty+- a cube or 3D render target, or a target's depth texture: the target stays empty (a depth texture reads white)- three's EffectComposer in a plain program: the scene is drawn without its passes- pointer events and OrbitControls in a live play: not wired yet-- `onBeforeCompile` edits to a built-in material: drawn as the material without them+- an `onBeforeCompile` patch to a material other than standard or physical, or the part of one past three's lighting+ (its light, its output colour): drawn without itLook at the render (`raea render scene.tsx --frame 24 -o f.png`) and read its warnings: each says what was left out.diff --git a/sdk/r3f/test/parity/fixtures.tsx b/sdk/r3f/test/parity/fixtures.tsxindex 0b2d615c..2360096d 100644--- a/sdk/r3f/test/parity/fixtures.tsx+++ b/sdk/r3f/test/parity/fixtures.tsx@@ -7,6 +7,7 @@ import { ContactShadows, Environment, Float, Sky, Text, useGLTF } from "@react-timport { useMemo, useRef, type ReactNode } from "react";import * as THREE from "three";import { TARGET_INPUTS } from "./targets";+import { PATCHED_INPUTS } from "./patched";import { MeshBasicNodeMaterial } from "three/webgpu";import * as TSLTyped from "three/tsl";import { composeEffects, configureFontTexture, createText, parseFont, scramble, wipe } from "lettra/three";@@ -120,6 +121,8 @@ const clipPlane = new THREE.Plane(new THREE.Vector3(-0.3, -1, 0.2).normalize(),export const INPUTS: Record<string, InputCase> = {// render targets an app draws into itself, drawn on raea's GPU (R3F23): test/parity/targets.tsx...TARGET_INPUTS,+ // materials patched by onBeforeCompile, three's own program with the patch (R3F24): test/parity/patched.tsx+ ...PATCHED_INPUTS,instanced: {canvas: { camera: { position: [0, 3.2, 4.2], fov: 45 } },frame: 12,diff --git a/sdk/r3f/test/parity/patched.tsx b/sdk/r3f/test/parity/patched.tsxnew file mode 100644index 00000000..e12ea78a--- /dev/null+++ b/sdk/r3f/test/parity/patched.tsx@@ -0,0 +1,87 @@+// The parity cases for materials patched by onBeforeCompile (docs/r3f.feature R3F24, src/input/patched.ts): three's own+// program with the patch applied, its surface lit by raea's engine; each drawn by raea and by three.js in Chrome.+import { MeshDistortMaterial, MeshReflectorMaterial, MeshWobbleMaterial } from "@react-three/drei";+import { useFrame } from "@react-three/fiber";+import { useMemo } from "react";+import * as THREE from "three";+import type { InputCase } from "./fixtures";++/** an app's own patch: a plane's vertices raised in waves by a uniform it sets on the patched program each frame (the+ * shader kept from onBeforeCompile, as the three.js forum's examples keep it) */+function Waves() {+ const m = useMemo(() => {+ const mat = new THREE.MeshStandardMaterial({ color: "#3d8bfd", roughness: 0.45, side: THREE.DoubleSide });+ mat.onBeforeCompile = (shader) => {+ shader.uniforms.uTime = { value: 0 };+ shader.vertexShader = `uniform float uTime;\n${shader.vertexShader}`.replace(+ "#include <begin_vertex>",+ "vec3 transformed = position;\ntransformed.z += 0.18 * sin( position.x * 3.0 + uTime * 2.0 ) * cos( position.y * 2.0 + uTime );",+ );+ mat.userData.shader = shader;+ };+ return mat;+ }, []);+ useFrame(({ clock }) => {+ const s = m.userData.shader as THREE.WebGLProgramParametersWithUniforms | undefined;+ if (s) s.uniforms.uTime.value = clock.elapsedTime;+ });+ return (+ <mesh material={m} position={[0, -1.1, -0.6]} rotation={[-1.2, 0, 0]}>+ <planeGeometry args={[6, 3, 96, 48]} />+ </mesh>+ );+}++const lights = (+ <>+ <ambientLight intensity={0.4} />+ <directionalLight position={[3, 4, 2]} intensity={2.2} />+ </>+);++export const PATCHED_INPUTS: Record<string, InputCase> = {+ // drei's MeshWobbleMaterial and MeshDistortMaterial (vertex patches) and an app's own waves+ patched: {+ canvas: { camera: { position: [0, 0.6, 4.2], fov: 45 } },+ frame: 12,+ scene: () => (+ <>+ <color attach="background" args={["#14161c"]} />+ {lights}+ <mesh position={[-1.25, 0.35, 0]}>+ <torusKnotGeometry args={[0.55, 0.18, 160, 20]} />+ <MeshWobbleMaterial color="#f2a541" factor={0.8} speed={1.5} roughness={0.35} />+ </mesh>+ <mesh position={[1.25, 0.35, 0]}>+ <sphereGeometry args={[0.7, 96, 64]} />+ <MeshDistortMaterial color="#e05a8b" distort={0.45} speed={2} roughness={0.25} metalness={0.1} />+ </mesh>+ <Waves />+ </>+ ),+ },+ // drei's MeshReflectorMaterial: the scene drawn from the mirrored camera into a target (R3F23) and read through its+ // patch's projective lookup+ reflector: {+ canvas: { camera: { position: [0, 1.4, 4.4], fov: 45 } },+ frame: 12,+ scene: () => (+ <>+ <color attach="background" args={["#101218"]} />+ {lights}+ <mesh position={[-0.9, 0.6, 0]} rotation={[0.4, 0.6, 0]}>+ <boxGeometry args={[0.8, 0.8, 0.8]} />+ <meshStandardMaterial color="#f2a541" roughness={0.4} />+ </mesh>+ <mesh position={[0.9, 0.7, -0.3]}>+ <sphereGeometry args={[0.6, 48, 32]} />+ <meshStandardMaterial color="#3d8bfd" roughness={0.3} />+ </mesh>+ <mesh rotation={[-Math.PI / 2, 0, 0]}>+ <planeGeometry args={[8, 8]} />+ <MeshReflectorMaterial resolution={256} mirror={0.8} mixStrength={2} roughness={0.6} metalness={0.2} color="#3a3d46" />+ </mesh>+ </>+ ),+ },+};diff --git a/sdk/r3f/tools/parity.sh b/sdk/r3f/tools/parity.shindex 61fbb0e4..1b8c7cfc 100755--- a/sdk/r3f/tools/parity.sh+++ b/sdk/r3f/tools/parity.sh@@ -25,6 +25,9 @@ CASES+=(in-post2:6 in-post3:6)CASES+=(in-tslpost:6 in-tslpost2:6)# render targets an app draws itself, on raea's GPU: a useFBO, and GPUComputationRenderer's ping-pong (test/parity/targets.tsx, R3F23)CASES+=(in-fbo:12 in-pingpong:12)+# materials patched by onBeforeCompile (drei's wobble, distort and reflector, an app's waves): three's own program with+# the patch, lit by raea (test/parity/patched.tsx, R3F24)+CASES+=(in-patched:12 in-reflector:12)[ -z "${R3F_CASES:-}" ] || read -ra CASES <<<"$R3F_CASES"mkdir -p "$OUT"for c in "${CASES[@]}"; do