Ray-tracing

Introduction

This project Demo Link consists of basic ray-tracing functions and many extra features.

Following features have been implemented:

  • Render polygons
  • Render spheres
  • Use simple Phong Shading (in color)
  • Compute shadows
  • Compute reflections
  • Use point lights
  • Write its output to a standard image format(.ppm).
  • Depth of field
  • Anti-aliasing
  • Transparency with refraction
  • Use AABB tree to accelerate the computations
  • Use iterative flows to trace the bounce rays, instead of recursion.
  • Toon shading

Inputs

The inputs include two parts: command lane arguments and an input file(writen in .nnf format)

Command Lane Arguments

All the command line arguments are optional. The default values for each object on the screen is its ambient color. Other pixels will be filled with background color. Detailed specifications are written in the input file.

-c

  • This command tells the programm to shade the objects(i.e. running phone shading or toon shading)

-d %g

  • This command provides an integer value limiting the number of bounces in reflection and refraction.

-phone

  • Switch to phone shading(default)

-toon

  • Switch to toon shading(the last command on switching shading methods will be applied)

-samples %g

  • Set the number of samples(%g * %g) to be collected to determine each pixel(if greater than one, then automatically run anti-aliasing)

-aabb

  • Set to use aabb-tree data structure

-iter

  • Set to shift from recursion to iteration bounce ray tracing.

Input files

Specifications

In addition, I added three extra parameters–rr rg rb following the fill color and shading parameters to provide the reflective attenuation, which makes the rendering of image easier.

Gallery

The tracing results generated from my program. All the input datasets were from the Internet.

Environment: Windows10, i7-8750H 2.20GHz CPU, VS Code

teapot.nff

Sample1

Command Line Arguments: raytracer trace -c (-aabb) teapot.nnf teapot.ppm

Total time: 1415.78s(normal structure & flow)

Total time: 748s(use AABB tree)

balls.nff

Sample2

Command Line Arguments: raytracer trace -c (-aabb) balls.nnf balls.ppm

Total time: 3267.89s(normal structure & flow)

Total time: 2287.5s(use AABB tree)

More pictures are coming soon!

Site by Shengyu Jin using hexo blog framework. Late Updated: May 6, 2020

载入天数...载入时分秒...