Skip to content

Tams3d/raytracer-cpp

Repository files navigation

raytracer-cpp

CPU raytracer in C++ with SDL3 for real-time display.

was making a terminal text editor (Kilo tutorial) using Windows Console API. scrapped it because raytracer is more interesting. kept the build system setup (GCC, clangd, clang-format, clang-tidy).

Why? What's the point in getting into C++ again?

eh I know C++, like basic algorithmic level, i started in school, actually it was a part of my CSC syllabus ukuk. pretty dumb to see the "academic version" of learning like "write a cpp program to print Fibonacci series" that kinda things i hate, felt too beginner-ish, quite sad that still clgs follow these, rather than making interesting n cool stuffs which fulfills my curiosity ig now its time for that to fuel my creative brains

useless initial thoughts of cpp

#include<iostream>
// brotha why include everything in header file? chk in compile time and import only required la?
using namespace std;
// still idk whats this std thingy... like would be better to have include {specific thing} from "somefile.h" or include "somefile.h" and using as somefile.<something> or somefile::<something>

int main(){
/*
so you main fn is a special case, return int uhh?? 0 means successful -1 means error or failure ?
 who do you acknowledge the return, also you automatically return without specifying it seems
*/

cout <<"Hello World!" << endl;
/*
what the hell is << like my ide does <<>> everytime
why not printf()? why not cout() but cout.print()?
*/

return 0;
// i talked about you return beforeee, you hit me now
}

English is a language, not knowledge

hmmm, as you seee i'm not using "Professional" corporate level, newspaper worthy english here, just raw thoughts, fck AI generated texts for personal contexts, avoid faking texting styles for impressions. Just raw friendly dm-like language connects fast ri8?

build

make          compile
make run      compile + run
make format   clang-format
make lint     clang-tidy
make check    format + lint + cppcheck
make clean    remove build/ bin/

done

  • 3D math stuff (using Eigen library)
  • ray hits sphere detection
  • camera looking at things, Z-up coordinate system
  • image on screen with SDL3
  • app window, event loop, render
  • point light with smooth falloff
  • multiple objects and lights in scene

todo

  • shadows (objects blocking light)
  • materials (shiny, diffuse, glass etc)
  • anti-aliasing (fix jagged edges)
  • BVH (speed up rendering big scenes)
  • more shapes (planes, cubes, suzzane, etc)
  • idk wat more???

disclaimer

things here are based on my understanding, doesn't need to be programmatically logically mathematically actually correct. consider C/C++ arbitrarily, i can't be specific every time the project is setup wid the help of ai, like idk how to make things what uv does in python and bun does in ts with cpp. i declare no ai was used in writing code! its my learning not a slop im following random yt tutorials, mixture of implmenetations, might follow the creator's design choice bcoz sometimes im lil blind into following tuts i would like to hear for improvements, anytime!

About

CPU RayTracer in C++ with SDL

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors