Coder Social home page Coder Social logo

simple-raytracer's Introduction

simple-raytracer

A simple translation of the famous business card raytracer

You can also render custom messages by generating the bit vectors from ascii art using the included python script.

Take note of the number of columns and rows it tells you your message has, you'll need to change:

  • The NUM_LINES constant to the "number of lines" value
  • The NUM_COLUMNS constant to the "number of columns" value
  • The contents of the sphere_positions array with the contents of the "Bit vector" array from the script.

Note that the bigger your message the longer the rendering is going to take, and it already takes a while as is :)

rendered img

Usage

  1. Put your ascii art into the python script and run it with python3 bit_vector_creator.py
  2. Get your sphere_positions, NUM_COLUMNS, and NUM_LINES from the python script output and place them into the relevant zig variables
    • You can create your own art here
  3. Run with zig build-exe raytracer.zig && ./raytracer > img.ppm
    • You can also use the -O ReleaseFast or -O ReleaseSafe flags to speed up the execution
  4. Then, with imagemagick installed, run convert img.ppm img.png to convert the image to a png format

Sources

simple-raytracer's People

Watchers

 avatar

simple-raytracer's Issues

Uncentered graphics

When rendering, the resulting image has all elements pushed to the extreme right of the image:
bad

I think this is due to the number of bits in zigs usize type and the bit vectorizer not accounting for that. I attempted something that would center the bit vectors in a length of 64 but that didn't really work:
bad_attempt_1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.