Skip to content

Visualizing Raytracing in unity, sole purpose of this project is to visualize my first raytracer from scratch in a better prespective using a engine.

Notifications You must be signed in to change notification settings

j-2k/VisualizeRaytracingInUnity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visualizing my raytracer from scratch in unity

The sole purpose of this project is to visualize my first raytracer from scratch in a better prespective using a engine.

Playing The Project / Instructions

When in the game view (IN PLAYMODE) of the project press space to view the hit positions on the sphere & they should be displayed in the scene view.
This was not made with a high focus on optimization but just optimized decently.
You can also click the raytracer object in playmode & view the script attached to it. You can change many things such as the radius of the sphere, show rays, show hit positions, change alpha of rays that hit nothing & etc.
Project made in Unity > BIRP > Version 2021.3.16f1
Here are all the parameters you can control, explanation is below the image.
Screenshot_2

  • Width & Height resemble the density of rays & is essentially just resolution (Aspect ratio taken into account).
  • Length is just simply the magnitude of the ray.
  • Radius is the radius of the sphere to raytrace (the white gizmo sphere).
  • Forward offset to move the ray origin on the Z axis.
  • Main Light can be anything but just takes its direction its pointing @ to calculate shading.
  • Root 0 Alpha is the color alpha of the rays not hitting the sphere 0 is nothing/transparent 1 is max/opaque.
  • The next 3 bools are to show rays, show the hit positions as gizmos, & showing the position of the raytraced sphere as a gizmo.
  • Reload Gizmos Key, Press the reload key to see gizmo hit positions, & always keep pressing it when changing values.
  • Finally, just gizmo sphere size.

The last 4 lists all dont need to be tampered with & are there for debugging purposes.

Pull requests!

I also don't know of a method to draw gizmos in the update method if you know a good method tell me about it.
I never found a "good way" of drawing gizmos dynamically (i did have a dynamic method but it was very laggy when increasing radius because of the # of gizmos that would need to be drawn on the screen.) so if you have a better method maybe do a pull req or tell me about it, thanks.

Project Images

Here are some gif & images below to see the project without downloading.

About

Visualizing Raytracing in unity, sole purpose of this project is to visualize my first raytracer from scratch in a better prespective using a engine.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published