Material on C# 3D Software Renderer

Started by
2 comments, last by Kaptein 9 years, 7 months ago

I want to create a 3D Software Renderer, with a few limitations - it can't use OpenGL or DirectX (shocker, huh?), and it has to be written in either C# or Java. I will be using C#.

I've searched the web quite a lot, and failed to find any material that would actually help. Many of the links posted are outdated, and most of the material that still, well, exists online, is purely theoretical and mostly limited to "how to draw this line".

Can you recommend a source online that explains this subject in a bit more detail, preferably something not too outdated?

Advertisement

"Many of the links posted are outdated, and most of the material that still, well, exists online, is purely theoretical and mostly limited to "how to draw this line". "

Well, that's generally how you implement anything. You read material that explains the general methods you use to create a software renderer. Then you implement it yourself using the programming language of your choice.

The algorithms, math and underlying fundamentals haven't changed since the 90s. You could read about software rendering from 1990 and from that using your modern programming language and modern single and multi-core parallellism as well as GPU implement the very same thing, just more in parallell. That particular aspect might not be very interesting for you though, so if you want to keep it simple - stick to the original methods and try to understand them well.

Anyways, I googled for 5 mins and found a C# tutorial series:

http://blogs.msdn.com/b/davrous/archive/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript.aspx

A more detailed series here:

http://fgiesen.wordpress.com/2013/02/17/optimizing-sw-occlusion-culling-index/

Also, keep in mind that if you are looking for strictly C# code, you are going to have a bad time. You really need to be able to learn from and understand articles that explain things from a more academic perspective, that explains things in terms of algorithms, pseudo-code, algebra (and unfortunately sometimes logic.)

To make a software renderer you might want to make sure you have covered at least the basics in linear algebra first.

"Many of the links posted are outdated, and most of the material that still, well, exists online, is purely theoretical and mostly limited to "how to draw this line". "

Well, that's generally how you implement anything. You read material that explains the general methods you use to create a software renderer. Then you implement it yourself using the programming language of your choice.

The algorithms, math and underlying fundamentals haven't changed since the 90s. You could read about software rendering from 1990 and from that using your modern programming language and modern single and multi-core parallellism as well as GPU implement the very same thing, just more in parallell. That particular aspect might not be very interesting for you though, so if you want to keep it simple - stick to the original methods and try to understand them well.

Anyways, I googled for 5 mins and found a C# tutorial series:

http://blogs.msdn.com/b/davrous/archive/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript.aspx

A more detailed series here:

http://fgiesen.wordpress.com/2013/02/17/optimizing-sw-occlusion-culling-index/

Also, keep in mind that if you are looking for strictly C# code, you are going to have a bad time. You really need to be able to learn from and understand articles that explain things from a more academic perspective, that explains things in terms of algorithms, pseudo-code, algebra (and unfortunately sometimes logic.)

To make a software renderer you might want to make sure you have covered at least the basics in linear algebra first.

I wanted something a little bit more advanced than just drawing a line, because I don't really know how to properly scale this line into an entire scene, and I'm looking for something on a larger scale.

The thing is, it's a school project, and the requirements are either Java or C#, and no OpenGL or DirectX. The first link uses WPF (which uses DirectX for rendering) and SharpDX.

I wanted something a little bit more advanced than just drawing a line, because I don't really know how to properly scale this line into an entire scene, and I'm looking for something on a larger scale.

The thing is, it's a school project, and the requirements are either Java or C#, and no OpenGL or DirectX. The first link uses WPF (which uses DirectX for rendering) and SharpDX.

Well, in your original post you said you wanted to "create a software renderer," which is the same thing in any language. The no OpenGL or DirectX requirement also doesn't change anything. The underlying fundamentals are still the same. All that changes is how you present the image on the screen.

Imagine that I was allowed to use OpenGL, what changes? Well, I could rasterize to a buffer in memory and present the finished image using OpenGL. In other words, I let OpenGL be my in-program image-viewer.

Just get started. It doesnt matter what you draw on. You could draw to a buffer that you write to a .bmp file and show in windows image viewer. If the goal is a software renderer, the rest doesn't matter. Just focus on the rasterizing part. You can worry about what you draw on later.

The links I posted will tell you everything you need to know to get started.

From the link I posted, is a good article about triangle rasterization:

http://fgiesen.wordpress.com/2013/02/08/triangle-rasterization-in-practice/

And for the "scaling" - that's where linear algebra, lots of theory and many hours comes in.

http://www.arcsynthesis.org/gltut/Basics/Intro%20Graphics%20and%20Rendering.html

and

http://www.arcsynthesis.org/gltut/Positioning/Tut05%20Boundaries%20and%20Clipping.html#d0e5543

This gives an overview of the process, which should help you get started. You need to start at the beginning just like everyone else.

And a gamedev forum post about this subject:

http://www.gamedev.net/topic/595604-resources-for-writing-a-software-renderer/

A more advanced series, on perspective texture mapping:

http://chrishecker.com/Miscellaneous_Technical_Articles

As you can see, it gets abit harder when you move on to texture mapping. Which is why my advice is to keep it simple.

Start with a 2D renderer. It will simplify things. Rasterize some lines.

Move on to a 3D wireframe rasterizer. Then rasterize solid triangles with a single color. Then flat shaded materials (eg. each triangle or side of a cube has different colors).

This topic is closed to new replies.

Advertisement