Skip to content

Create light sources and setup lenses and watch ray tracing happen real time! Intended for educational purposes only.

License

Notifications You must be signed in to change notification settings

sk8ermeb/LenseRayTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LenseRayTracer

Create light sources and setup lenses and watch ray tracing happen real time! Intended for educational purposes only. alt text

How To Use This Program

This is written in C# .net universal. So you likely need visual studio and the latest .net to run it. I am using 4.6.1. First thing to note is all fields in this program are dimensionless as they are relative (except for ange/degrees). If it helps you visualize just pick whatever unit is appropraiate for your experiment. Mathmatically it will all come out sense everything is relative. Also all colors are specified in R-G-B each on a scale from 0 to 255, so "255-0-0" is entirely red.

Lense

First add the lenses you want. To do this go to Simulation ->Lenses. Positive radius is convex and Negative in concave. There is a horizontal and depth radius for the top and the bottom so that you can do unique things like focus light in only one dimension while diverging light in another. The Granulatrity is very important, and the smaller the granularity the more difficult it is to render but the better it looks. this is ray tracing so everything is numerical approximation. Lastly index of refraction is just that. The air has an index of refraction of 1, so it is relative.

Light Source

There are two kinds of light, and infinite light, and a spotlight. The infinite light is for modeling the sun. The direction is in calissic spherical coordinates. So PHI and Theta. The granularity is entirely determined by the ground plane, so you must ad a groundplane to have an infinite light. One ray is aimed toward each piece to give the simulation reasonable bounds. For the spot light the direction it is aimed provides and X, Y, and Z. -Y is directly down. You can spcify granularity by approximately how many degrees between each ray.

Lense Encountering

There are lots of shortcuts taken to speed up processing time. The most important is that the program is not aware of the side of the lense that is actually the first encounter, rather it always incounters the "top" radius first. So if the lense has been flipped 180 such that the light is hitting the bottom first your simulation will not be rendered accuratly. Once a ray has encountered the groundplane, or has nothing else to encounter it will be killed.

If the tracing is taking way to long uncheck Simulation -> Draw Rays Real Time. This option updates the rendering after each ray has been traced to help visualize what is going on.

The Reset Light option removes all rendered light to get a fresh rendering. Leacing it there gives the user to see iterative tracings.

The color of all light gets normalized by the brightness, so color 100-100-100 with brightness 100 should be rendered similaraly to 200-200-200 brightness 100.

If the radius is smaller then the lense size wierd things will start happening. You willl see the rendering not converge. I havn't bothered adjusting for that case so keep that in mind.

For control if you click an dmove the mouse it will rotate your view about the center. Scrolling with the mouse zooms. And holding shift and clicking and moving will pan. The Pan is a little messed up though so it doesn't go up and down properly!

Enjoy! I am just one guy who had need for a ray tracing program for a project I was doing because I didn't have the money for custom lenses being build so I created this. The code is not pretty nor commenented. But its a free 3d ray tracing program in C#. Feel free to contribute as well if you want.

alt text

About

Create light sources and setup lenses and watch ray tracing happen real time! Intended for educational purposes only.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages