0

Musings on Raytracing vs Rasterisation

Intend: While working on a simple raytracer project , I got to think about the pros and cons of current rendering techniques, namely rasterisation and raytracing so wanted to write down a few points as a reminder for future me.

Although most of my current knowledge on 3D graphics is based on rasterisation algorithms, I did learn about raytracing before for sure yet never come to implement it from scratch. I have to say, it’s a pure joy as I have a background on math (graduated from mathematical engineering) and aytracing is all about tracing the natural steps of light-matter interaction.

So what’s raytracing anyways? Simply put, it’s the process of rendering objects in 3D by shooting rays from a virtual camera towards the scene and coming up with a color value for the current pixel, given the material properties of the object that this very pixel is a part of. What kind of material properties for example? you may ask. It can be the type of material such as glass, water, sand or reflectivitiy and transparency coefficients. Due to its nature, features that are hard or costy to implement with current real-time rendering techniques such as soft shadows, global illumination etc. are inherently easier with it. The main benefit of raytracing comes from the fact that it holds the overall scene data within every cell, which is also the reason why it’s waaaay too slower compared to rasterisation.

So if raytracing is so nice but a bit slower, can’t we just use it with faster computers soon for mind-blowingly beautiful real-time rendering? The thing is, eventhough there exist dozen spatial acceleration structures and optimizations for better data coherency, it’s still nowhere near the rasterisation on speed. The reason being is what makes raytraced scenes look so natural and beautiful, scene structure. Rasterisation simply works with primitives such as triangles at its deepest and requires just a little bit information on current pixel to shade it. We can currently render millions of vertices on 60 FPS on an average PC GPU whereas raytracing can take as many time as days or even weeks with multi-pc and threading setup!

I think smart rendering people of the past made quite a choice going (read: forcedly going) with rasterisation instead of raytracing eventhough it is sometimes absurd how cheap approximations are made to compensate performance to implement a much-natural feature in raytracing. Given that there is nowadays some steps taken towards special raytracing-based hardware, my hopes are high for that in a mid-term we can see a simple game with amazing content on PCs.

Cheers!

0

Compiling Simple x64 Assembly Files on Windows

While reading through that fast Introduction to x64 Assembly here, I wanted to simply compile the example without bothering with Visual Studio project settings stuff so I wrote that below no-brainer Windows batch to compile x64 Assembly!

@echo off
cd [PATH_TO_OUTPUT_DEST]
set LIB=%LIB%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64; #v7.1A can be 7.0A/8.0A/8.1A WRT Windows version
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\ml64" [PATH_TO_ASM_FILE]\hello.asm /link /subsystem:windows /defaultlib:kernel32.lib /defaultlib:user32.lib /entry:[NAME_OF_ENTRY_POINT]
pause # Keep console open to see the output

Go and try it:
extrn ExitProcess: PROC
extrn MessageBoxA: PROC
.data
caption db '64-bit hello!', 0
message db 'Hello World!', 0
.code
Start PROC
sub rsp,28h
mov rcx, 0
lea rdx, message
lea r8, caption
mov r9d, 0
call MessageBoxA
mov ecx, eax
call ExitProcess
Start ENDP
End

If you save the code above with [NAME_OF_ENTRY_POINT] as Start into hello.asm assigning in batch [PATH_TO_OUTPUT_DEST] and [PATH_TO_ASM_FILE] to where it’s saved, calling the batch above should produce hello.exe. Simply run the program and see the magic!

Enjoy!

0

Hello, World!

Hi, there!

There goes my first attempt at creating a simple personal blog to show my current projects, works and thoughts about any possible thing I’ll think of along the way.

Stay tuned!