OBJ Viewer
- 11 Devlogs
- 44 Total hours
A C program that uses software rasterization to view .obj 3d files
A C program that uses software rasterization to view .obj 3d files
Changes:I fixed a parsing error with materials with the map_d attribute. I also added support for tiling UVs, so the well-known Sponza model works properly.
I spent a lot of time improving the CMake packaging. Now, I can just run one command and it will build and package the project (with correct linking) for MacOS and Linux. I don’t have access to a Windows machine at the moment, so I haven’t added support for that yet.
My last touch was reversing the Z-direction because OBJ files use a right-handed coordinate system. Now I think I’m ready to ship this project.
I finished adding near clipping. I spent a ton of time figuring out why the UV coordinates were messed up, but I ended up fixing that. Now, you can go extremely close up to the model without any unseen polygons.
I added basic near clipping for polygons with two vertices behind the plane (I will eventually add clipping for polygons with one vertex behind the plane). This actually took forever to figure out. I nearly gave up twice. The attached image puts the clipping plane at 0.5 so you can see what I am talking about, but in reality the clipping distance will be a really low number like 0.01.
I’ve just fixed some more bugs, including: leading spaces not working, UV coordinates being upside down, indicator text not showing, and the specular exponent being the wrong default value. The proper UV coordinates now make some of the free models I downloaded actually work. The rasterizer is now super cool.
I just fixed some bugs. Those bugs include three buffer overflows (💀), a goto initialization error, and file loading not working with Windows paths on other OS’s.
I added texture and material loading support. It uses SDL_image to load the textures and supports relative paths. It supports MTL files. I think I’m going to ship this project soon.
Texture mapping has been implemented into the renderer but not the parser. My next step is to add textures to the parser so that the user can load the textures automatically instead of manually writing the filepath. I have already set up the structs for MTL support, including a hashmap to allow for string-indexing.
This update might be a little boring, but I genuinely spent hours debugging a problem with the normals that occured on high-poly models. It added random empty spots in the model and it was genuinely so satisfying to fix it. All that was happening was that it was dividing by zero and returning NaN; I just added a check to avoid NaN.
I added smooth (phong) shading to my OBJ viewer, and prepared the code for texture mapping.