Software Renderer in Unity

posted in jhocking
Published January 22, 2024 Imported
Advertisement

As a somewhat random learning exercise, I picked up the book Computer Graphics from Scratch to see if it was any good. The title by itself is rather vague, but the subtitle “A Programmer’s Introduction to 3D Rendering” makes it clear this is up my alley. This tweet is from a few days after I started:

The book has you implementing a software renderer. Although I already knew all the individual steps involved, I had never actually written a software renderer before, so it was an interesting project for me. Plus I decided to do it within Unity, and so there’s a bit of renderer inception going on, with the output from my software renderer being displayed by Unity’s hardware renderer!

My overall review of the book is that I’m enjoying it a lot! I do wonder if someone with less experience would have trouble following it, because I’ve had to improvise around the pseudocode (eg. the PutPixel equivalent in Unity uses different coordinates) but for me the level of difficulty is perfect.

What I did was generate a Texture2D, and then apply that texture to a RawImage that’s on an overlay UI canvas. Although the examples for the book are written in JavaScript, the book itself presents everything as pseudocode, and assumes you are already familiar with the fundamentals of your programming language. Thus, I could create an array in C# and then pass that to the texture’s SetPixels() method.

The book goes over raytracing as a first method of rendering, and then goes over rasterization. I only did the raytrace renderer so far; I’m not sure when I’ll get around to rasterization, but I did add keyboard controls on top of what the book instructed because hey why not!

Read more

1 likes 1 comments

Comments

steve3

I spent a lot of time on your site. and saw your post. I really liked it. Let me also share with you the information that paying for essays compromises academic integrity, promotes dishonesty, and inhibits students' learning and critical thinking https://academized.com/pay-for-essay devalues the educational process and undermines the purpose of academic assessment. Upholding ethical writing practices, fostering originality, and prioritizing personal growth is essential for a genuine and enriching educational experience.

July 26, 2024 10:10 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement