The First Real-Time On-Chain Ray Tracing Engine with Arbitrum Stylus
Live Demo: https://raystylus.vercel.app/
Contract: https://sepolia.arbiscan.io/address/0x1bd8e7e9b1d0824eb97535af61bbaed0a9dd5757
RayStylus is a high-performance on-chain graphics and computation experiment built for the Arbitrum Stylus ecosystem, designed to demonstrate what becomes possible when smart contracts are no longer constrained by traditional EVM limitations.
Instead of another DeFi primitive, RayStylus focuses on a problem long considered impossible on-chain: executing real-time 3D ray tracing, a computationally intensive graphics algorithm, fully inside a Stylus (Rust → WASM) smart contract. The system deterministically renders a 32×32 ray-traced sphere scene, computed entirely on-chain using mathematically precise ray–sphere intersection logic. Every pixel is produced through real geometric computation executed inside the contract—no off-chain rendering, no approximations, and no trusted compute.
Beyond graphics, RayStylus demonstrates that Stylus can also support adaptive, non-linear computation on-chain. The contract embeds a mini neural network (MNN) as a separate on-chain capability. This MNN accepts three aesthetic parameters—warmth, intensity, and depth—and applies non-linear neural transformations to generate RGB color values. This proves that Stylus can execute neural-style computation deterministically in a trustless environment, not merely static mathematical pipelines.
User interaction is powered by an OpenAI-integrated configuration layer. Users express intent in natural language (e.g., “make the sphere look like a sunset sun”, “night space background”). OpenRouter / GPT-4.1 translates this intent off-chain into strict, deterministic numerical parameters—including sphere color, background colors, and camera XYZ for ray tracing, as well as warmth, depth, and intensity values for neural color generation. These parameters are then sent to the smart contract and executed fully on-chain. No AI inference occurs on-chain, ensuring reproducibility, safety, and full determinism.
The frontend is built with Next.js and TypeScript, delivering a zero-lag, interactive UI that instantly visualizes the verified on-chain output.
RayStylus is intentionally positioned as a technical showcase and reference architecture, built to answer a single research-driven question:
How far can Stylus push on-chain computation beyond finance?
All ray tracing and neural computation occurs fully on-chain inside the Stylus smart contract. Ray tracing and neural color generation are independent on-chain capabilities. Off-chain components are strictly limited to intent translation and never influence execution results.
🟣 [CORE — STUDIO MODE] Fully On-Chain Ray Tracing Engine
A deterministic ray tracing engine executing ray–sphere intersection mathematics to render a 32×32 pixel scene entirely on-chain. Implemented in Rust, compiled to WASM, and executed via Arbitrum Stylus, every pixel is produced through verifiable geometric computation inside the smart contract—no off-chain rendering or approximations.
Available at the /studio page with configurable parameters: sphere color, background gradient, and camera position (XYZ).
🧠 [CORE — AESTHETIC MODE] On-Chain Mini Neural Network (MNN)
A lightweight mini neural network with a 3→4→2 architecture embedded directly in the smart contract. The MNN functions as an independent neural color generator, transforming three aesthetic control parameters—warmth (cool-to-warm palette shift), intensity (saturation and contrast), and depth (shadow-to-light balance)—through non-linear neural layers to produce RGB output.
This demonstrates that Stylus can safely execute non-linear, adaptive computation on-chain.
Available at the /aesthetic page, with a free on-chain preview via the view_aesthetic() VIEW function.
🤖 [ORCHESTRATION] AI-Powered Configuration Layer
Users interact using natural language instructions. These inputs are processed off-chain by OpenRouter / GPT-4.1, which translates intent into strict, deterministic numerical parameters.
• Studio mode: sphere color, background colors (bg1, bg2), camera XYZ
• Aesthetic mode: warmth, intensity, depth
These parameters are then executed on-chain. AI never participates in execution, preserving full determinism and verifiability.
⚡ [DELIVERY] Zero-Lag, Trustless User Experience
Near-native execution speed via Stylus WASM eliminates the need for off-chain render servers or trusted compute. Every output is reproducible, inspectable, and verifiable on-chain, ensuring both performance and trust guarantees.
🟣 STUDIO MODE — On-Chain Ray Tracing Flow
User opens the Studio page (/studio)
User selects parameters manually or instructs the AI to adjust camera position and color settings
Deterministic parameters are sent to the smart contract
→ renderScene() executes fully on-chain
Raw 32×32 ray-traced pixel data is returned from the contract
Pixels are rendered instantly to the canvas in the frontend
Result: a fully verifiable on-chain ray-traced scene, computed and validated by the Stylus contract.
🧠 AESTHETIC MODE — On-Chain Neural Color Generation Flow
User opens the Aesthetic page (/aesthetic)
User adjusts aesthetic sliders (warmth, intensity, depth) or provides natural-language intent via AI
Deterministic parameters are sent to the smart contract
→ viewAesthetic() executes as a FREE view function (no gas)
RGB color output generated by the on-chain mini neural network is returned
Color is displayed instantly as a visual swatch
(Optional) User clicks Mint to persist the generated aesthetic as an on-chain NFT
Result: a deterministic neural aesthetic output, generated and verifiable entirely on-chain.

System Architecture
Network: Arbitrum Sepolia
Smart Contract: Arbitrum Stylus Contract0x1bd8e7e9b1d0824eb97535af61bbaed0a9dd5757
Language: Rust compiled to WebAssembly (WASM) via Stylus
Ray Tracing Engine:
Deterministic 32×32 ray–sphere intersection engine executed fully on-chain
Neural Network:
Embedded Mini Neural Network (MNN) with 3 → 4 → 2 architecture
Mathematics:
Fixed-point arithmetic for precision, determinism, and gas efficiency
Framework: Next.js
Language: TypeScript
Styling: TailwindCSS
Provider: OpenRouter / OpenAI GPT-4.1
Purpose: Intent-to-parameter mapping
Function: Natural language → deterministic numerical parameters
Scope: Off-chain only
(AI never participates in on-chain execution or computation)
RayStylus is built for builders who want to see what's actually possible. It's not a pitch—it's a proof.
It works. A real Stylus contract, deployed and live, executing compute-heavy graphics logic that would never fly on standard EVM chains. Ray tracing on-chain. Neural networks on-chain. No shortcuts, no hand-waving.
It's beautiful. Interact with it, watch it render in real-time, and the experience is smooth. No lag, no weird delays—just instant visual feedback powered by Rust WASM performance.
It's different. While everyone else submits DeFi derivatives, RayStylus pushes into graphics and adaptive computation—territory no one really talks about on blockchain. That matters.
It's honest. AI handles one job: understanding what you want and turning it into numbers. The contract doesn't touch any of that. Everything that matters—every pixel, every calculation—happens on-chain, verifiable and deterministic. No magic, no trust assumptions hiding in the corners.
The point? RayStylus shows judges (and future builders) that Stylus doesn't just move money faster. It fundamentally changes what you can build. Graphics. Real computation. Logic that's too expensive for EVM but perfectly native to WASM.
This is the mental model shift: smart contracts don't just handle finance—they handle worlds.
RayStylus is not a product — it is a signal to prove Stylus superiority.
A signal that on-chain computation can move beyond transfers and swaps, toward verifiable graphics, adaptive neural logic, and high-performance execution, made possible only by Arbitrum Stylus.
By executing deterministic ray tracing and neural computation entirely on-chain, RayStylus demonstrates that smart contracts are no longer limited to moving value — they can execute, verify, and render computation itself.