All Projects → fogleman → Fauxgl

fogleman / Fauxgl

Licence: mit
Software-only 3D renderer written in Go.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Fauxgl

Tinyraycaster
486 lines of C++: old-school FPS in a weekend
Stars: ✭ 1,383 (+110.18%)
Mutual labels:  opengl, graphics, 3d, rendering
Tinyrenderer
A brief computer graphics / rendering course
Stars: ✭ 11,776 (+1689.67%)
Mutual labels:  opengl, graphics, 3d, rendering
Vxr
General purpose engine written in C++ with emphasis on materials rendering (PBR, clear coat, anisotropy, iridescence)
Stars: ✭ 181 (-72.49%)
Mutual labels:  opengl, graphics, 3d, rendering
Renderhelp
⚡️ 可编程渲染管线实现,帮助初学者学习渲染
Stars: ✭ 494 (-24.92%)
Mutual labels:  opengl, graphics, 3d, rendering
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+1677.81%)
Mutual labels:  opengl, graphics, 3d
Physics3d
A 3D physics engine
Stars: ✭ 101 (-84.65%)
Mutual labels:  opengl, graphics, rendering
Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (-18.84%)
Mutual labels:  opengl, graphics, 3d
Gaiasky
Mirror of Gaia Sky repository hosted on Gitlab: https://gitlab.com/langurmonkey/gaiasky
Stars: ✭ 162 (-75.38%)
Mutual labels:  opengl, graphics, 3d
Worldwindjava
The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
Stars: ✭ 526 (-20.06%)
Mutual labels:  opengl, graphics, 3d
Im3d
Immediate mode rendering and 3d gizmos.
Stars: ✭ 561 (-14.74%)
Mutual labels:  graphics, 3d, rendering
Dagon
3D game engine for D
Stars: ✭ 165 (-74.92%)
Mutual labels:  opengl, 3d, rendering
Polymer
🎨 graphics + interaction engine
Stars: ✭ 243 (-63.07%)
Mutual labels:  opengl, graphics, rendering
Mini3d
3D Software Renderer in 700 Lines !!
Stars: ✭ 1,320 (+100.61%)
Mutual labels:  opengl, graphics, 3d
Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+1458.05%)
Mutual labels:  opengl, graphics, rendering
Tinyraytracer
A brief computer graphics / rendering course
Stars: ✭ 3,971 (+503.5%)
Mutual labels:  graphics, 3d, rendering
Shaderworkshop
Interactive GLSL fragment shaders editor made with Qt
Stars: ✭ 43 (-93.47%)
Mutual labels:  opengl, graphics, rendering
Unity Dithered Transparency Shader
Unity material and shader for applying clipped, dithered transparency
Stars: ✭ 174 (-73.56%)
Mutual labels:  graphics, 3d, rendering
Euc
A software rendering crate that lets you write shaders with Rust
Stars: ✭ 180 (-72.64%)
Mutual labels:  graphics, 3d, rendering
Glitter
Dead Simple OpenGL
Stars: ✭ 2,040 (+210.03%)
Mutual labels:  opengl, graphics, rendering
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+466.57%)
Mutual labels:  opengl, graphics, 3d

FauxGL

3D software rendering in pure Go. No OpenGL, no C extensions, no nothin'.


Dragon

About

It's like OpenGL, but it's not. It's FauxGL.

It doesn't use your graphics card, only your CPU. So it's slow and unsuitable for realtime rendering. But it's still pretty fast. It works the same way OpenGL works - rasterizing.

Features

  • STL, OBJ, PLY, 3DS file formats
  • triangle rasterization
  • vertex and fragment "shaders"
  • view volume clipping
  • face culling
  • alpha blending
  • textures
  • triangle & line meshes
  • depth biasing
  • wireframe rendering
  • built-in shapes (plane, sphere, cube, cylinder, cone)
  • anti-aliasing (via supersampling)
  • voxel rendering
  • parallel processing

Performance

FauxGL uses all of your CPU cores. But none of your GPU.

Rendering the Stanford Dragon shown above (871306 triangles) at 1920x1080px takes about 150 milliseconds on my machine. With 4x4=16x supersampling, it takes about 950 milliseconds. This is the time to render a frame and does not include loading the mesh from disk.

Go Get

go get -u github.com/fogleman/fauxgl

Go Run

cd go/src/github.com/fogleman/fauxgl
go run examples/hello.go

Go Doc

https://godoc.org/github.com/fogleman/fauxgl

Complete Example

package main

import (
	. "github.com/fogleman/fauxgl"
	"github.com/nfnt/resize"
)

const (
	scale  = 1    // optional supersampling
	width  = 1920 // output width in pixels
	height = 1080 // output height in pixels
	fovy   = 30   // vertical field of view in degrees
	near   = 1    // near clipping plane
	far    = 10   // far clipping plane
)

var (
	eye    = V(-3, 1, -0.75)               // camera position
	center = V(0, -0.07, 0)                // view center position
	up     = V(0, 1, 0)                    // up vector
	light  = V(-0.75, 1, 0.25).Normalize() // light direction
	color  = HexColor("#468966")           // object color
)

func main() {
	// load a mesh
	mesh, err := LoadOBJ("examples/dragon.obj")
	if err != nil {
		panic(err)
	}

	// fit mesh in a bi-unit cube centered at the origin
	mesh.BiUnitCube()

	// smooth the normals
	mesh.SmoothNormalsThreshold(Radians(30))

	// create a rendering context
	context := NewContext(width*scale, height*scale)
	context.ClearColorBufferWith(HexColor("#FFF8E3"))

	// create transformation matrix and light direction
	aspect := float64(width) / float64(height)
	matrix := LookAt(eye, center, up).Perspective(fovy, aspect, near, far)

	// use builtin phong shader
	shader := NewPhongShader(matrix, light, eye)
	shader.ObjectColor = color
	context.Shader = shader

	// render
	context.DrawMesh(mesh)

	// downsample image for antialiasing
	image := context.Image()
	image = resize.Resize(width, height, image, resize.Bilinear)

	// save image
	SavePNG("out.png", image)
}

Teapot

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].