Skip to content

MickeyMeowMeowHouse/NASMCompileTimeRayTracing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NASM Compile-Time Ray-Tracing Demo

Ray-tracing rendering technique achieved by using NASM macros. Rendering is done during compile time. The compiler outputs a BMP file.

Demo

How to compile

Prerequisite

First, you need the NASM compiler. To install the NASM compiler under Linux you can use apt-get, yum, pacman, etc.

The source code was designed to be compiled by using makefile under bash in order to compile the file concurrently. If you don't have the environment, simply running nasm raytrace.asm -o raytrace.bmp to compile if you have nasm available.

The NASM compiler here isn't used for compiling machine codes. It's used to generate a BMP file struct directly, and it renders the scene during compiling.

Concurrent compiling and memory usage

During compiling/rendering, there will be a huge amount of RAM consumed by the compiler. You have to check out the first few lines of makefile to adjust the configurations.

Pay attention to the option SLICES and PIECES of makefile, it's used for the ability to run multiple NASM compiler together to produce the scene quickly, and the option PIECES and SLICES are used to split the picture into small blocks. The small blocks can be compiled concurrently. Using the -j option of makefile specifies the maximum count of the running processes of the compiler. But since the compilation consumes huge memory, more PIECES and SLICES with a lower -j number is suggested. Note that YRES must be integer times of SLICES and XRES must be integer times of PIECES to produce a correct BMP file.

For example, set the resolution to 640x480, and set PIECES to 64, set SLICES to 48, then run make -j12, the scene will be generated by compiling some small 10x10 parts concurrently by running 12 compiler processes together. After all of the parts were generated, the compiler creates the scene out of the parts. The usage of memory is expected to lower than 32GB.

Preview

When compiling is slowly proceeding, it's able to check the preview of the scene by running make preview. The script tries to composite the picture by concatenating the pieces and create a picture file out of them. You can then view preview.bmp to have a quick peek of the rendering picture.

The GLSL Implementation Demo From Shadertoy

Please check out from Shadertoy: here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published