Thursday, August 15, 2019

How is software rendering done?


I would like to explore realtime software based rasterization. I know everything is going towards the GPU these days but there are a few games where it still makes sense to use a software renderer.


For example: Voxeltron



Voxatron is an arena shooter that takes place in a world made of voxels (little cubes, kind of). Everything in the game is displayed in a virtual 128x128x64 voxel display, including the menus and player inventory. If you look closely, you can sometimes see the inventory (score/life/ammo) casting a shadow on some of the objects on the ground.


I've been working on voxel rendering and modeling tools for a long time now, with the ultimate goal of making a large explorey adventure game. About half a year ago it fused with work I was doing on arena shooters for Conflux, and this is the result.



It's quite a simple game at heart -- mostly just Robotron set in a 3d destructible world with goofy creatures. I'm unsure how major the implications of destructibility will be for gameplay, but it sure is fun to blast away pieces of wall. I've also added an experimental wall-building pickup you can use to construct barriers to hide from scary monsters.


The game takes place in a small set of arenas. Some of them feature rooms with set action pieces, somewhere between Knightlore and Smash TV. This is some of the original adventure based design sneaking back in, and an excuse to create thematic environments.


Features:



  • Custom software rendering with soft shadows.

  • Built-in sound and music synthesizer (also used to make the trailer music).

  • Playback & post game recording.




Answer




I am going to assume you already know some basic linear algebra, the kind involved in: 3d projections, camera setup, transforming vertices into world position, etc... If you don't, there are plenty of great places to learn from. Here are two that I like:


Game Engine Architecture



  • Brief coverage of basic linear algebra but does cover everything you need to know. The book is worth having for many other reasons too.


Real-time Rendering



  • A little bit more detailed coverage but again sticks to only what you might need to know. Again, I recommend this one for the topics covered in the rest of the chapters.





Once you know about how to represent and handle 3d objects you are ready to look at how to draw them to the screen. Typically this is done with a scan line triangle rasterization technique. It is actually a pretty simple concept. You draw one row of one triangle at a time while interpolating color and uv texture coordinates. This process is continued for all triangles on the screen. You could even implement a depth buffer to handle out of order rendering.


enter image description here enter image description here enter image description here


This is covered in more detail in these articles:


Tutorial - Introduction to Software-based Rendering: Triangle Rasterization


Software Rendering School: Part I




And just for fun, check out the following article:


Quake 2 Source Code Review 3/4 (Software Renderer)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...