Free Go Library for 3D Rendering & Transformation
Leading Open Source Go 3D Graphics Library for Working with 3D Meshes, Custom Shading and Materials, 3D Transformations, Multithreaded Rendering, Anti-aliasing and So on.
What is FauxGL Library?
FauxGL is an innovative open source Go 3D library by Michael Fogleman, offering pure Go, software-based 3D rendering with no external dependencies. This lightweight yet powerful toolkit is ideal for developers seeking a free Go 3D API for portable graphics solutions. It supports essential features like vertex transformations, importing and manipulating 3D meshes, custom shading, material handling, perspective and camera control, triangle rasterization, color interpolation, texture mapping, wireframe rendering, depth buffering, and hidden surface removal. Software Developers can easily create STL 3D drawings, add sections to 3D files, and handle 3D diagrams rendering with precision, making it a versatile choice for projects requiring high control over the rendering pipeline.
Unlike GPU-dependent solutions like OpenGL or DirectX, FauxGL processes entirely on the CPU, making it perfect for environments without hardware acceleration or where direct rendering control is needed. While not designed for high-frame-rate gaming, it excels in offline rendering, algorithm testing, educational use, and visualization generation. FauxGL can work with 3D OBJ and FBX, load formats like STL, PLY, and 3DS, and even convert 3D files to PDF when integrated into broader workflows. It also offers built-in functions for creating planes, spheres, cubes, cylinders, and cones, allowing quick rendering of 3D file entities and applying transformations to 3D diagrams. FauxGL stands as a clean, expressive demonstration of Go’s capabilities in CPU-based 3D graphics rendering.
Getting Started with FauxGL
The recommend way to install FauxGL is using GitHub. Please use the following command for a smooth installation.
Install FauxGL API via Get command
go get github.com/fogleman/fauxgl
You can download the compiled shared library from Github repository.
Pure CPU-Based Rendering via Go API
The open source FauxGL library supports Pure CPU-Based Rendering and does not use the GPU at all. Every triangle, every pixel, and every transformation is computed purely on the CPU. This makes it a perfect choice for headless rendering environments (like servers) or simple graphics processing tasks without GPU dependency. The following code script shows how to setting up a scene inside Go applications.
How to Set Up a Scene for Pure CPU-Based Rendering via Go Library?
import "github.com/fogleman/fauxgl"
const (
width = 1024
height = 768
)
func main() {
context := fauxgl.NewContext(width, height)
context.ClearColorBufferWithColor(fauxgl.Black)
context.ClearDepthBuffer()
// Now you can start drawing models or primitives!
}
3D Model Loading and Transformation
The open source FauxGL library has provided complete support for loading and working 3D models inside Go applications. Once loaded, you can easily apply transformations like scaling, rotation, resizing, and translation. Here is a simple example that demonstrates how software developers can load Wavefront OBJ formats, one of the most common 3D model file formats and apply transformation to it using Go library.
How to Load a 3D Model and Applying Transformations via Go Library?
mesh, err := fauxgl.LoadOBJ("model.obj")
if err != nil {
panic(err)
}
// Apply transformations
matrix := fauxgl.Identity().
Scale(fauxgl.Vector{1, 1, 1}).
Rotate(fauxgl.V(0, 1, 0), fauxgl.Radians(45)).
Translate(fauxgl.Vector{0, 0, -5})
mesh.Transform(matrix)
Vector Operations via Go Library
The MathGL library provides extensive support for vector and matrix mathematics, including operations for 2D, 3D, and 4D vectors and matrices. These are essential for handling positions, directions, velocities, and other spatial data. It provides support for Add, Sub, Dot, Cross, Normalize, etc. and multiple precision types (mgl32 for float32, mgl64 for float64). Here is a simple example that demonstrates how software developers can perform different vector operations inside their Go applications.
How to Perform Vector Operations via Go Library?
package main
import (
"fmt"
"github.com/go-gl/mathgl/mgl32"
)
func main() {
// Create two 3D vectors
v1 := mgl32.Vec3{1, 2, 3}
v2 := mgl32.Vec3{4, 5, 6}
// Vector addition
sum := v1.Add(v2)
fmt.Println("Vector sum:", sum) // [5 7 9]
// Dot product
dot := v1.Dot(v2)
fmt.Println("Dot product:", dot) // 32
// Cross product
cross := v1.Cross(v2)
fmt.Println("Cross product:", cross) // [-3 6 -3]
}
Custom Shading and Materials via Go
You can define how objects are shaded using customizable shaders inside Go applications. The open source FauxGL library provides a flexible system for writing your own shading logic — allowing you to control color, lighting, and even custom effects at the pixel level. The following shows how software developers can perform simple flat shading inside Go applications.
How to Perform Simple Flat Shading inside Go Apps?
shader := func(vertex fauxgl.Vertex) fauxgl.Color {
normal := vertex.Normal.Normalize()
light := fauxgl.Vector{1, 1, 1}.Normalize()
intensity := normal.Dot(light)
baseColor := fauxgl.HexColor(0x3498db) // Light blue color
return baseColor.MulScalar(intensity)
}
context.Shader = shader
context.DrawMesh(mesh)