Built as a small experiment to understand how 3D rendering works without relying on OpenGL.
A simple 3D software renderer written in Java using Swing.
This project renders .obj models without OpenGL or external graphics libraries. Everything is implemented manually: transformations, triangle rasterization, z-buffering, and basic shading.
- OBJ file loading
- Triangle rasterization
- Z-buffer (depth buffer)
- Per-face lighting (based on surface normal)
- Interactive rotation (mouse sliders)
- Load custom models at runtime
- Mesh subdivision ("inflate")
The renderer follows a basic 3D pipeline:
- Load vertices and faces from an OBJ file
- Apply rotation using 3x3 matrices
- Project 3D coordinates to screen space (orthographic)
- Rasterize triangles using barycentric coordinates
- Use a z-buffer to handle depth
- Compute simple shading using triangle normals
No GPU acceleration is used. All rendering is done on the CPU.
- Horizontal slider → rotate around Y axis
- Vertical slider → rotate around X axis
- "Open OBJ" → load a model from disk
- "Inflate" → subdivide the mesh
Open the project in IntelliJ IDEA and run:
DemoViewer.java
Requires Java 8 or newer.
src/
DemoViewer.java // UI + application setup
RenderPanel.java // rendering logic
ObjLoader.java // OBJ parsing
Matrix3.java // matrix math
Vertex.java // 3D point
Triangle.java // triangle data
models/
*.obj // example models
- Rendering is orthographic (no perspective projection)
- Large meshes may reduce performance (CPU rasterizer)
- OBJ support is minimal (only vertices and faces)
- Perspective projection
- Backface culling
- Wireframe mode
- Texture mapping
MIT
