Skip to content

RayTracing 2D Attempt just using good (g)old C and SDL2 Gfx Library to draw objects around. The RayCasting Algorithm, in 2D, is used. SDL2 is an open source, free to use, cross platform development library. Work In Progress.

License

Notifications You must be signed in to change notification settings

RiccardoRevalor/SDL2_RayTracing2D

Repository files navigation

C, SDL2 RayTracing 2D Attempt

Libraries used: SDL2.h (version 2.32.0, download here: https://www.libsdl.org/release/), math.h

Main algorithm used: RayCasting algorithm

I draw all the rays from the light source and compute their paths, it they encounter an obstacle or exit from the screen, their path stops.
This way, obstacles shadows are cast.
Each ray is defined as a struct composed of a 2D Starting Point and an angle expressed in radiants.
Circle light sources emit rays in every direction.
Since rays are manually placed and drawn, they are finite in number so this is obviously an approximation.
By moving the mouse around and pressing the right button, you can move the light source(s) and the emitted rays will change.

alt text

About

RayTracing 2D Attempt just using good (g)old C and SDL2 Gfx Library to draw objects around. The RayCasting Algorithm, in 2D, is used. SDL2 is an open source, free to use, cross platform development library. Work In Progress.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published