A basic Ray Tracer that exploits numpy arrays and functions to work fast.

Overview

Python-Fast-Raytracer

A basic Ray Tracer that exploits numpy arrays and functions to work fast. The code is written keeping as much readability as possible.

animation

  • Refraction
  • Thin film interference
  • Textures
  • Monte Carlo Ray Tracing with importance sampling
  • Relativistic optical effects

Installation

Just clone or download this repo. You'll need to install two packages.

  1. Pillow is a fork of the PIL package. It provides the Image module for this application. to install it run the following.
pip install pillow
  1. Numpy is a scientific package that helps with mathematical functions.
pip install numpy

Examples

See the examples to see how to render the following images:

python example1.py

N|Solid

python example2.py

N|Solid

python example3.py

N|Solid

python example4.py

N|Solid

python example_cornell_box.py

N|Solid

Some animations: https://www.youtube.com/watch?v=vt9vAcZQT4A

A basic version of this raytracer can be found here: https://github.com/jamesbowman/raytrace

Comments
  • i want to use your engine as a base to mine

    i want to use your engine as a base to mine

    hi, i wanna make a ray tracing plugin to a game engine called godot iam not one of the gme engine's devs or smth just a user soo i wanna use your engine as a base to mine i will add alot more features and optimizations to it so it works perfectly with a game and the plugin will be completely free and open source after making everything in python i will translate them to gdnative to make the plugin i just want to take permission from you for using it and your name will be mentioned in the vreators page of the plug in, thnx in advance zenux

    opened by zenux-dev 5
  • Scene Scripting Language

    Scene Scripting Language

    So... many many many years ago I used to use POVRay and the thing I liked about it is the scenes were scripted in their own files.

    You could not only describe the scene but also use variables to start doing animations with batch files. I wrote an DOS based animation tool in Turbo Pascal that did all sorts of weird and wonderful things. Things like moving objects (the camera and lights are counted as an object) along bezier curves, catmull-rom spline curves etc.

    So anyway to get to the point it would really make this far more accessible if a text file could be used to describe a scene. So things like objects, textures, camera, lights etc could be defined in a far simpler file that is called by the Python code.

    I'd be happy to help with how it should look and do testing. Perhaps a simplified version of the POVRay scene files could be a guide.

    Another thing that can be done of course is (as you will see in the example below) separating out textures into their own files for modification. :)

    For example a basic scene would look like this:

    //EXAMPLE OF SPHERE
    
    //Files with predefined colors and textures
    #include "colors.inc"
    #include "glass.inc"
    #include "golds.inc"
    #include "metals.inc"
    #include "stones.inc"
    #include "woods.inc"
    
    //Place the camera
    camera {
      sky <0,0,1>           //Don't change this
      direction <-1,0,0>    //Don't change this  
      right <-4/3,0,0>      //Don't change this
      location <30,10,1.5> //Camera location
      look_at <0,0,0>     //Where camera is pointing
      angle 15      //Angle of the view--increase to see more, decrease to see less
    }
    
    //Ambient light to "brighten up" darker pictures
    global_settings { ambient_light White }
    
    //Place a light--you can have more than one!
    light_source {
      <10,-10,20>   //Change this if you want to put the light at a different point
      color White*2         //Multiplying by 2 doubles the brightness
    }
    
    //Set a background color
    background { color White }
    
    //Create a "floor"
    plane {
      <0,0,1>, 0            //This represents the plane 0x+0y+z=0
      texture { T_Silver_3A }       //The texture comes from the file "metals.inc"
    }
    
    //Sphere with specified center point and radius
    //The texture comes from the file "stones.inc"
    sphere { <0,0,1.5>, 1 texture {T_Stone1} }
    
    opened by sparthir 5
  • Original Picture

    Original Picture

    Hello, I'm very interesting with your project, so maybe you can help me how to see the picture before rendered, maybe you can explain it to add some code to see the image before rendered and then the image after rendered into ray tracing

    opened by rudiana587 2
  • How can I make an animation?

    How can I make an animation?

    Hello!I am interested in your project name raytracer on github. I wonder how to generate "animation.gif", I can not find the source code. Could you please help me out?Thank you! I would be appreciate if you could send your all source code to me.

    opened by Nanran 2
  • Loading custom objects?

    Loading custom objects?

    I have an object .stl file which I have build using a 3D CAD software. Can that be imported into the scene? Or is there any other library where such objects can be imported and rendered.

    Thanks.

    opened by sidgairo18 1
  • fixing point light sources for glossy surfaces

    fixing point light sources for glossy surfaces

    This PR fixes 2 issues -

    1. #16
    2. Currently, the glossy surface rendering would only work in presence of directional light in the code. I modified the code for it to work with both directional and point light sources.
    opened by chinmay0301ucsd 0
  • Potential bug in triangle mesh class

    Potential bug in triangle mesh class

    https://github.com/rafael-fuente/Python-Raytracer/blob/5c1c05b38e043feaf21435ace1f9e18766baf5bb/sightpy/geometry/triangle_mesh.py#L38 This line should be changed to

    [Triangle_Collider...] 
    

    as colliders is not imported

    opened by chinmay0301ucsd 0
Owner
Rafael de la Fuente
Rafael de la Fuente
An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.

Ray provides a simple, universal API for building distributed applications. Ray is packaged with the following libraries for accelerating machine lear

null 23.3k Dec 31, 2022
Distributed Tensorflow, Keras and PyTorch on Apache Spark/Flink & Ray

A unified Data Analytics and AI platform for distributed TensorFlow, Keras and PyTorch on Apache Spark/Flink & Ray What is Analytics Zoo? Analytics Zo

null 2.5k Dec 28, 2022
DistML is a Ray extension library to support large-scale distributed ML training on heterogeneous multi-node multi-GPU clusters

DistML is a Ray extension library to support large-scale distributed ML training on heterogeneous multi-node multi-GPU clusters

null 27 Aug 19, 2022
Iris species predictor app is used to classify iris species created using python's scikit-learn, fastapi, numpy and joblib packages.

Iris Species Predictor Iris species predictor app is used to classify iris species using their sepal length, sepal width, petal length and petal width

Siva Prakash 5 Apr 5, 2022
Penguins species predictor app is used to classify penguins species created using python's scikit-learn, fastapi, numpy and joblib packages.

Penguins Classification App Penguins species predictor app is used to classify penguins species using their island, sex, bill length (mm), bill depth

Siva Prakash 3 Apr 5, 2022
Educational python for Neural Networks, written in pure Python/NumPy.

Educational python for Neural Networks, written in pure Python/NumPy.

null 127 Oct 27, 2022
NumPy-based implementation of a multilayer perceptron (MLP)

My own NumPy-based implementation of a multilayer perceptron (MLP). Several of its components can be tuned and played with, such as layer depth and size, hidden and output layer activation functions, weight decay and dropout.

null 1 Feb 10, 2022
MLReef is an open source ML-Ops platform that helps you collaborate, reproduce and share your Machine Learning work with thousands of other users.

The collaboration platform for Machine Learning MLReef is an open source ML-Ops platform that helps you collaborate, reproduce and share your Machine

MLReef 1.4k Dec 27, 2022
A repository of PyBullet utility functions for robotic motion planning, manipulation planning, and task and motion planning

pybullet-planning (previously ss-pybullet) A repository of PyBullet utility functions for robotic motion planning, manipulation planning, and task and

Caelan Garrett 260 Dec 27, 2022
Implementations of Machine Learning models, Regularizers, Optimizers and different Cost functions.

Linear Models Implementations of LinearRegression, LassoRegression and RidgeRegression with appropriate Regularizers and Optimizers. Linear Regression

Keivan Ipchi Hagh 1 Nov 22, 2021
Cohort Intelligence used to solve various mathematical functions

Cohort-Intelligence-for-Mathematical-Functions About Cohort Intelligence : Cohort Intelligence ( CI ) is an optimization technique. It attempts to mod

Aayush Khandekar 2 Oct 25, 2021
Basic Docker Compose for Machine Learning Purposes

Docker-compose for Machine Learning How to use: cd docker-ml-jupyterlab

Chris Chen 1 Oct 29, 2021
A fast, scalable, high performance Gradient Boosting on Decision Trees library, used for ranking, classification, regression and other machine learning tasks for Python, R, Java, C++. Supports computation on CPU and GPU.

Website | Documentation | Tutorials | Installation | Release Notes CatBoost is a machine learning method based on gradient boosting over decision tree

CatBoost 6.9k Jan 5, 2023
Simple, fast, and parallelized symbolic regression in Python/Julia via regularized evolution and simulated annealing

Parallelized symbolic regression built on Julia, and interfaced by Python. Uses regularized evolution, simulated annealing, and gradient-free optimization.

Miles Cranmer 924 Jan 3, 2023
ThunderSVM: A Fast SVM Library on GPUs and CPUs

What's new We have recently released ThunderGBM, a fast GBDT and Random Forest library on GPUs. add scikit-learn interface, see here Overview The miss

Xtra Computing Group 1.4k Dec 22, 2022
A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Light Gradient Boosting Machine LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed a

Microsoft 14.5k Jan 7, 2023
ThunderGBM: Fast GBDTs and Random Forests on GPUs

Documentations | Installation | Parameters | Python (scikit-learn) interface What's new? ThunderGBM won 2019 Best Paper Award from IEEE Transactions o

Xtra Computing Group 648 Dec 16, 2022
Greykite: A flexible, intuitive and fast forecasting library

The Greykite library provides flexible, intuitive and fast forecasts through its flagship algorithm, Silverkite.

LinkedIn 1.7k Jan 4, 2023
Meerkat provides fast and flexible data structures for working with complex machine learning datasets.

Meerkat makes it easier for ML practitioners to interact with high-dimensional, multi-modal data. It provides simple abstractions for data inspection, model evaluation and model training supported by efficient and robust IO under the hood.

Robustness Gym 115 Dec 12, 2022