Skip to content

MistLaw/raytrace-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RayTrace-Unity

A minimal GPU ray tracer built in Unity using a fragment shader.

Overview

This project demonstrates real-time ray tracing in Unity using the standard vertex and fragment pipeline. It renders reflective and emissive spheres entirely on the GPU.

How It Works

  • Shader (myShader.shader)
    Performs ray sphere intersections and lighting directly in the fragment shader using basic vector mathematics. Sphere data is passed as a StructuredBuffer in the shader.

  • Sphere Class (RayTracingSphere.cs)
    Defines per sphere properties such as color, reflectivity, luminosity, and emission color.

  • Camera Class (CameraScript.cs)
    Populates a C# array of Sphere structs, uploads it to the GPU using a ComputeBuffer, and draws the scene with Graphics.Blit when ray tracing is enabled.

Features

  • GPU based ray tracing using a fragment shader
  • Supports multiple reflective and emissive spheres
  • Adjustable bounce limit and accumulation for progressive blending
  • Uses a C# array uploaded to the GPU via ComputeBuffer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published