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中显示帧缓冲器中的图像
Implementation of an ordered dithering algorithm used in computer graphics

Ordered Dithering Project In this project, we use an ordered dithering method to turn an RGB image, first to a gray scale image and then, turn the gra

1 Oct 26, 2021
Python implementation of Aho-Corasick algorithm for string searching

Python implementation of Aho-Corasick algorithm for string searching

Daniel O'Sullivan 1 Dec 31, 2021
Algorithm for Cutting Stock Problem using Google OR-Tools. Link to the tool:

Cutting Stock Problem Cutting Stock Problem (CSP) deals with planning the cutting of items (rods / sheets) from given stock items (which are usually o

Emad Ehsan 87 Dec 31, 2022
Algorithmic virtual trading using the neostox platform

Documentation Neostox doesnt have an API Support, so this is a little selenium code to automate strategies How to use Clone this repository and then m

Abhishek Mittal 3 Jul 20, 2022
My own Unicode compression algorithm

Zee Code ZCode is a custom compression algorithm I originally developed for a competition held for the Spring 2019 Datastructures and Algorithms cours

Vahid Zehtab 2 Oct 20, 2021
So far implements A* will add more later

Pathfinding_Visualization Finds the shortest path between two nodes. The light blue path is the shortest path. The black nodes are barriers. Created i

Lukas DeLoach 1 Jan 18, 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
marching rectangles algorithm in python with clean code.

Marching Rectangles marching rectangles algorithm in python with clean code. Tools Python 3 EasyDraw Creators Mohammad Dori Run the Code Installation

Mohammad Dori 3 Jul 15, 2022
This python algorithm creates a simple house floor plan based on a user-provided CSV file.

This python algorithm creates a simple house floor plan based on a user-provided CSV file. The algorithm generates possible router placements and evaluates where a signal will be reached in every roo

Joshua Miller 1 Nov 12, 2021
Programming Foundations Algorithms With Python

Programming-Foundations-Algorithms Algorithms purpose to solve a specific proplem with a sequential sets of steps for instance : if you need to add di

omar nafea 1 Nov 01, 2021
8 Puzzle with A* , Greedy & BFS Search in Python

8_Puzzle 8 Puzzle with A* , Greedy & BFS Search in Python Python Install Python from here. Pip Install pip from here. How to run? 🚀 Install 8_Puzzle

I3L4CK H4CK3l2 1 Jan 30, 2022
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
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
A simple python application to visualize sorting algorithms.

Visualize sorting algorithms A simple python application to visualize sorting algorithms. Sort Algorithms Name Function Name O( ) Bubble Sort bubble_s

Duc Tran 3 Apr 01, 2022
Rover. Finding the shortest pass by Dijkstra’s shortest path algorithm

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

1 Nov 11, 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
Genius Square puzzle solver in Python

Genius Square puzzle solver in Python

James 3 Dec 15, 2022
:computer: Data Structures and Algorithms in Python

Algorithms in Python Implementations of a few algorithms and datastructures for fun and profit! Completed Karatsuba Multiplication Basic Sorting Rabin

Prakhar Srivastav 2.9k Jan 01, 2023
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

4 Aug 04, 2022
A priority of preferences for teacher assignment problem

Genetic-Algorithm-for-Assignment-Problem A priority of preferences for teacher assignment problem Keywords k-partition; clustering; education 4.0 Abst

hades 2 Oct 31, 2022