Path tracing obj - (taichi course final project) a path tracing renderer that can import and render obj files

Overview

太极图形课S1-大作业

作业来源

路径追踪是目前计算机图形学中进行三维渲染的主流算法,因其生成的图像真实感强,广泛应用于静态图、电影等离线渲染上。随着目前GPU算力的不断增强,电子游戏等实时渲染领域也逐渐采用光栅化和路径追踪的方法来增强画面效果。

本次大作业通过太极编程语言完成了一个简单的路径追踪渲染器,该渲染器支持OBJ文件的导入和渲染。但因时间原因,没有实现OBJ的纹理映射和各类空间求交加速算法。

在实现本大作业中,参考了太极图形课的路径追踪示例程序 (链接)

运行方式

运行环境:

[Taichi] version 0.8.8, llvm 10.0.0, commit 7bae9c77, win, python 3.9.7

运行:

python path_tracing_obj.py

  • 使用 默认OBJ文件: 需保证model文件夹和path_tracing_obj.py文件位于同一路径下

  • 使用 自定义 OBJ文件: 可以修改path_tracing_obj.py文件中scene_init开头的函数以加载自定义模型,需注意可能需要对模型进行三维几何变换以让模型以合适的大小、位置、角度显示在屏幕上

效果展示

下面为在康纳盒中显示不同OBJ模型的效果图 res0

res1

res2

res3

res4

res5

整体结构

-LICENSE
-|data
-|model
-README.MD
-path_tracing_obj.py
-requirements.txt

实现细节:

path_tracing_obj.py是项目源代码,其中包含Ray类、Triangle类、Model类、ModelSphere类、Scene类、路径追踪中用到的反射折射方向计算函数和路径追踪函数、渲染函数、场景加载函数和main函数。

整体流程

  1. 执行场景加载函数,用OBJ文件实例化Model类,对Model对象执行三维几何变换,将Model对象添加到Scene类中
  2. 执行渲染函数,对屏幕上每个像素计算射线方向并调用路径追踪函数获取其颜色,将其写入帧缓冲器
  3. 在路径追踪函数依照路径追踪算法不断迭代,直到到达最大深度或与光源相交
  4. 在GUI中显示帧缓冲器中的图像
SortingAlgorithmVisualization - A place for me to learn about sorting algorithms

SortingAlgorithmVisualization A place for me to learn about sorting algorithms.

1 Jan 15, 2022
Cormen-Lib - An academic tool for data structures and algorithms courses

The Cormen-lib module is an insular data structures and algorithms library based on the Thomas H. Cormen's Introduction to Algorithms Third Edition. This library was made specifically for administeri

Cormen Lib 12 Aug 18, 2022
This is an implementation of the QuickHull algorithm in Python. I

QuickHull This is an implementation of the QuickHull algorithm in Python. It randomly generates a set of points and finds the convex hull of this set

Anant Joshi 4 Dec 04, 2022
Gnat - GNAT is NOT Algorithmic Trading

GNAT GNAT is NOT Algorithmic Trading! GNAT is a financial tool with two goals in

Sher Shah 2 Jan 09, 2022
TikTok X-Gorgon & X-Khronos Generation Algorithm

TikTok X-Gorgon & X-Khronos Generation Algorithm X-Gorgon and X-Khronos headers are required to call tiktok api. I will provide you API as rental or s

TikTokMate 31 Dec 01, 2022
Pathfinding algorithm based on A*

Pathfinding V1 What is pathfindingV1 ? This program is my very first path finding program, using python and turtle for graphic rendering. How is it wo

Yan'D 6 May 26, 2022
This repository is not maintained

This repository is no longer maintained, but is being kept around for educational purposes. If you want a more complete algorithms repo check out: htt

Nic Young 2.8k Dec 30, 2022
Benchmark for Robustness Tests of Control Alrogithms

A gym-like classical control benchmark for evaluating the robustnesses of control and reinforcement learning algorithms.

Kim Taekyung 4 Jan 18, 2022
Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

172 Dec 21, 2022
A simple library for implementing common design patterns.

PyPattyrn from pypattyrn.creational.singleton import Singleton class DummyClass(object, metaclass=Singleton): # DummyClass is now a Singleton!

1.7k Jan 01, 2023
Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Code for generating alloy / disordered structures through the special quasirandom structure (SQS) algorithm

Bruno Focassio 1 Nov 10, 2021
GoldenSAML Attack Libraries and Framework

WhiskeySAML and Friends TicketsPlease TicketsPlease: Python library to assist with the generation of Kerberos tickets, remote retrieval of ADFS config

Secureworks 43 Jan 03, 2023
Multiple Imputation with Random Forests in Python

miceforest: Fast, Memory Efficient Imputation with lightgbm Fast, memory efficient Multiple Imputation by Chained Equations (MICE) with lightgbm. The

Samuel Wilson 202 Dec 31, 2022
Sorting Algorithm Visualiser using pygame

SortingVisualiser Sorting Algorithm Visualiser using pygame Features Visualisation of some traditional sorting algorithms like quicksort and bubblesor

4 Sep 05, 2021
Python sample codes for robotics algorithms.

PythonRobotics Python codes for robotics algorithm. Table of Contents What is this? Requirements Documentation How to use Localization Extended Kalman

Atsushi Sakai 17.2k Jan 01, 2023
A simple python implementation of A* and bfs algorithm solving Eight-Puzzle

A simple python implementation of A* and bfs algorithm solving Eight-Puzzle

2 May 22, 2022
Wordle-solver - A program that solves a Wordle using a simple algorithm

Wordle Solver A program that solves a Wordle using a simple algorithm. To see it

Luc Bouchard 3 Feb 13, 2022
Implemented page rank program

Page Rank Implemented page rank program based on fact that a website is more important if it is linked to by other important websites using recursive

Vaibhaw 6 Aug 24, 2022
Implementation of core NuPIC algorithms in C++

NuPIC Core This repository contains the C++ source code for the Numenta Platform for Intelligent Computing (NuPIC)

Numenta 270 Nov 19, 2022
A lightweight, object-oriented finite state machine implementation in Python with many extensions

transitions A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+. Installa

4.7k Jan 01, 2023