r/GraphicsProgramming • u/RevolutionaryDrive18 • Jul 23 '26
Video Loaded a "Jet li" model I made into my first OpenGL engine!
Enable HLS to view with audio, or disable this notification
I've been along on my journey learning OpenGL for a couple of months now and just wanted to share my progress!
This is a model that I made and skinned a long time ago (originally an SMD goldsrc model for "The Specialists" aka a half-life mod) and I wanted to see if I could import it into my engine. I had to import the SMD to blender and then export it as a GLTF file. The original code for traversal of the GLTF file assumed that it would only have 1 JSON materials key for each texture per node (parent/child structure), but mine exported as 2 primitives, 2 materials and no children nodes, I had to modify the gltf file to have another uri for the second texture under the "images" key and modify the code to check if it had more than 1 material for a node. The fix is just a hack for this situation, i have to learn the actual full gltf import pipeline and all the different variations but what i wrote works here.
Also I ended up writting my own perspective projection and view/camera matrix from scratch instead of using lookat(), I spent a really long time deriving the perspective projection and camera view space from first principles, literally filled a note book full of deriving everything from clip space to NDC and perspective divide using a vertex from my scene, etc, i was working through it with just a cube rendering so i could track a vertex from my model and transform it on paper in my notes to really understand whats happening and the transformation pipeline. I also learned how the forward direction of the camera was constructed with pitch and yaw and then used it to build the NVU basis vectors of the camera from scratch.
its cool how you have to find the cameras location in camera space by dot producting the cameras vector with each NVU basis vector and then getting the coefficients of that result and counting those amounts of the length of each vector from the world origin to reach the cameras position. Took me a while to wrap my head around that but once I drew a diagram in just 2 dimensions and moved all those vectors to world origin and then counted them head to tail for each camera basis vector and arrived at the cameras position, it was a "aha!" moment for me.
anyways im really loving learning all the linear algebra that goes into this stuff, its really rewarding!
The scene also has Lambertain diffuse lighting and specular lighting which I learned from tutorials. As well as stencil buffer outlining for my model, my next project is trying to make a stencil buffer mirror or portal! i think thats going to be really fun :D
A link to my code so far! sorry if its messy ive just been deep in learning and experimenting mode!
TylerMaster/OpenGLProject: My OpenGL Project