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中显示帧缓冲器中的图像
You might also like...
This project is an implementation of a simple K-means algorithm
This project is an implementation of a simple K-means algorithm

Simple-Kmeans-Clustering-Algorithm Abstract K-means is a centroid-based algorithm, or a distance-based algorithm, where we calculate the distances to

A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD.
A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD.

8QueensGenetic A Python project for optimizing the 8 Queens Puzzle using the Genetic Algorithm implemented in PyGAD. The project uses the Kivy cross-p

This project consists of a collaborative filtering algorithm to predict movie reviews ratings from a dataset of Netflix ratings.
This project consists of a collaborative filtering algorithm to predict movie reviews ratings from a dataset of Netflix ratings.

Collaborative Filtering - Netflix movie reviews Description This project consists of a collaborative filtering algorithm to predict movie reviews rati

Algorithms and data structures for educational, demonstrational and experimental purposes.

Algorithms and Data Structures (ands) Introduction This project was created for personal use mostly while studying for an exam (starting in the month

A* (with 2 heuristic functions), BFS , DFS and DFS iterativeA* (with 2 heuristic functions), BFS , DFS and DFS iterative

Descpritpion This project solves the Taquin game (jeu de taquin) problem using different algorithms : A* (with 2 heuristic functions), BFS , DFS and D

Provide player's names and mmr and generate mathematically balanced teams
Provide player's names and mmr and generate mathematically balanced teams

Lollo's matchmaking algorithm Provide player's names and mmr and generate mathematically balanced teams How to use Fill the input.json file with your

Minimal examples of data structures and algorithms in Python
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Repository for data structure and algorithms in Python for coding interviews
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set

Python Sorted Containers Sorted Containers is an Apache2 licensed sorted collections library, written in pure-Python, and fast as C-extensions. Python

Owner
null
An implementation of ordered dithering algorithm in python as multimedia course project

One way of minimizing the size of an image is to simply reduce the number of bits you use to represent each pixel.

null 7 Dec 2, 2022
Planning Algorithms in AI and Robotics. MSc course at Skoltech Data Science program

Planning Algorithms in AI and Robotics course T2 2021-22 The Planning Algorithms in AI and Robotics course at Skoltech, MS in Data Science, during T2,

Mobile Robotics Lab. at Skoltech 6 Sep 21, 2022
Path finding algorithm visualizer with python

path-finding-algorithm-visualizer ~ click on the grid to place the starting block and then click elsewhere to add the end block ~ click again to place

izumi 1 Oct 31, 2021
Rover. Finding the shortest pass by Dijkstra’s shortest path algorithm

rover Rover. Finding the shortest path by Dijkstra’s shortest path algorithm Задача Вы — инженер, проектирующий роверы-беспилотники. Вам надо спроекти

null 1 Nov 11, 2021
Robotic Path Planner for a 2D Sphere World

Robotic Path Planner for a 2D Sphere World This repository contains code implementing a robotic path planner in a 2D sphere world with obstacles. The

Matthew Miceli 1 Nov 19, 2021
PICO is an algorithm for exploiting Reinforcement Learning (RL) on Multi-agent Path Finding tasks.

PICO is an algorithm for exploiting Reinforcement Learning (RL) on Multi-agent Path Finding tasks. It is developed by the Multi-Agent Artificial Intel

null 21 Dec 20, 2022
Sorting-Algorithms - All information about sorting algorithm you need and you can visualize the code tracer

Sorting-Algorithms - All information about sorting algorithm you need and you can visualize the code tracer

Ahmed Hossam 15 Oct 16, 2022
How on earth can I ever think of a solution like that in an interview?!

fuck-coding-interviews This repository is created by an awkward programmer who always struggles with coding problems on LeetCode, even with some Easy

Vinta Chen 613 Jan 8, 2023
With this algorithm you can see all best positions for a Team.

Best Positions Imagine that you have a favorite team, and you want to know until wich position your team can reach With this algorithm you can see all

darlyn 4 Jan 28, 2022
This repository is an individual project made at BME with the topic of self-driving car simulator and control algorithm.

BME individual project - NEAT based self-driving car This repository is an individual project made at BME with the topic of self-driving car simulator

NGO ANH TUAN 1 Dec 13, 2021