Skip to content

A program that emulates the 3d rendering process from scratch in the CPU with C++

License

Notifications You must be signed in to change notification settings

RodrigoPAml/SoftwareRasterizer

Repository files navigation

SoftwareRasterizer

A program that emulates the 3d rendering process writed from scratch in the CPU with C++ for fun

It uses assimp to import some 3d objects files with materials

245673981-bf4f6ff5-3029-439f-a41e-f891bf68d838

GIFS

Check some results

gif2

gif3

gif1

What is implemented ?

  • Perspective projection (world, camera and screen space ...)
  • Naive triangle clipping
  • Camera implementation with translation (with front, right and up vectors) and rotation (based on pitch and yaw)
  • Basic triangle scan line using triangle bounding box
  • Triangle interpolation for vertex attributes with z correction
  • Per pixel light, uv mapping with textures, wireframe, depth testing and more
  • Everything is writed in an array of pixels (Pixel buffer) and sended to GPU to draw as a simple texture
  • GPU is not used at all (only to show the result)
  • Face culling based on camera front vector (recent)

image

Using the rasterizer

You can build by downloading the project and compiling it or by downloading the results that also come with models for test

Opening a model

  • On the topbar click on File -> Open then select the model 3d to open

image

Using

To move use the wasd or the arrows

To look around drag the mouse with right click

The menu has the following options

  • Change the render resolution
  • Change draw mode/shader (wireframe, light, normals, positions, uvs, patterns, depth)
  • Change camera movement and rotation speed
  • Fov, Aspect Ratio
  • FPS view
  • Pattern scalar option (for pattern draw mode)
  • ZFar and ZNear planes
  • Back-culling
  • Perfect clipping
  • Light direction and ambient light strength

image

To do

  • A better triangle drawing algorithm, to get more peformance
  • Triangle clipping is done perfectly only on Z axis, maybe if done in all axis will increase performance

Funny Results

  • Here is some print of the results with the best angle

Images

image

image

4

image

Sponza

image

image

image

Fortress

image

image

image

About

A program that emulates the 3d rendering process from scratch in the CPU with C++

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published