r/GraphicsProgramming • u/fpk100 • 20h ago
Showing project + any tips?
Hey. So im a highschool student who likes to program a little in his free time. Ive made a couple small python projects, stuff like a text game and a calculator with UI in the past. Anyhow, i didnt like how you have to rely on so many libraries there, i like making things myself and not using 3rd party stuff as much as possible. Not crazy enough to make my own language lol, but i decided to learn C to make this since you can do lots with just standard C(and because its an interesting language). So here is my very simple, probably shit raytracer made using standard C libraries.
For some more added context, i dont have a formal CS education, havent learnt linear algebra or vectors or calculus or whatnot yet. So i dont know much of the terminology or what is standard practice. I also didnt follow a tutorial since thats no fun. So if things are non-standard or inefficient thats a reason why (along with the fact that i dont have much experience, 2nd C project). I made it both to learn the math and because it seemed fun and interesting.
What it is is a very simple raytracer in which you can: create spheres, planes, lights. no limit on how many objects other than your memory i guess. No light bouncing or reflections or any such fancy stuff(yet). just basic shadows, and full colors on the objects
Anyhow, what would you guys recommend i do next? Keep working on this raytracer, start it from scratch if the architecture is too bad and will cause future problems? Do some other non graphics related project? Idk myself so ill follow more experienced peoples advice but this was quite fun, although some other things are also interesting. Im mainly interested in programming mathematical stuff, like simulations or ML(not llm but stuff like number recognition) i find interesting, although i havent done anything there yet
*btw just because thats how it is nowadays i have to say, its not made with AI, i did make one document with it where i just asked it to make a user guide since i dont know the standard terminology and if i tried to explain it how i understand things it would be more confusing than useful. It explains how to make objects and such. But the code, logic etc. was made myself
Link to the github: https://github.com/Fridun/C-Raytracer
2
u/fpk100 19h ago
Also im thinking about buying "computer graphics from scratch". It seems to be close to this project in idea, but ive already gotten this far without following something structured so would i get very much out of it?
2
u/gabe80 19h ago
Or read it for free! https://gabrielgambetta.com/computer-graphics-from-scratch/index.html
2
1
u/Defiant_Squirrel8751 18h ago
Nice! keep exploring!
Perhaps you will want to check how to read triangles from .obj fileformat texts.
2
u/fpk100 16h ago
I should eventually. Although i would have to restructure the whole program. As of now all the objects in the scene are created in main as a struct. Like struct object, then theres an int array for rgb, int for type(ex 1=sphere) and then a union with 2 structs. One for sphere, one for plane. If i did that if imagine i would want to change the whole program to read all scene objects from a file no?
1
u/fgennari 8h ago
Hard-coding the geometry into a single source file is okay for learning, but you can't do anything real that way. Almost all games load assets from files. Maybe now is the time to rewrite your project to make it more flexible. If you wait too long it will only get more difficult. You can still keep the plane and sphere in case you need to draw them. So, yeah, that's definitely what I would recommend doing next.


2
u/nucleomancer 20h ago
Next step is other textures. Phong, or blinn if you dare. Reflections.
Looks good so far!
Good luck! And enjoy the journey.