Giter Club home page Giter Club logo

raytracer's Introduction

Raytracer

Features

Currently implemented

  • Support for triangles, spheres & planes
  • Support for different types of materials: diffuse, reflective, refractive & glossy
  • Shadow casting
  • Custom camera orientation
  • Depth of field
  • Anti-aliasing

To be implemented

  • Support for emissive materials
  • Ambient occlusion
  • OBJ model support

Using the program

Representing the scene in the input text file

  • Material: Material "MaterialName" <MaterialType> (Color) <RefractiveIndex>
    • <MaterialType> represents the material type, and can be one of Diffuse, Reflective, Refractive or Glossy.
    • (Color) represents the color of the material as (r, g, b) where each value is a double between 0 and 1 corresponding to red, green and blue respectively.
    • <RefractiveIndex> is a double value between 0 and 1.
  • Triangle: Triangle "TriangleName" (v0) (v1) (v2) "MaterialName"
    • Vertices are represented by (v0), (v1) and (v2) each as coordinates (x, y, z). The front face is defined by clockwise winding order.
    • "MaterialName" indicates the material that should be used.
  • Sphere: Sphere "SphereName" (center) <radius> "MaterialName"
    • (center) represents the center of the sphere as coordinates (x, y, z)
    • <radius> is a double representing the radius of the sphere
    • "MaterialName" indicates the material that should be used.
  • Plane: Plane "PlaneName" (center) (normal) "MaterialName"
    • (center) represents the center of the sphere as coordinates (x, y, z)
    • (normal) represents the direction of the normal vector of the plane as coordinates (x, y, z)
    • "MaterialName" indicates the material that should be used.
  • Point light: PointLight "LightName" (position) (Color)
    • (position) represents the position of the point light as coordinates (x, y, z)
    • (Color) represents the color of the material as (r, g, b) where each value is a double between 0 and 1 corresponding to red, green and blue respectively.

Running the program from the command line

Ensure that .NET SDK version 6.0 or higher is installed, and then run the following command:

dotnet run -- -f tests/sample_scene_1.txt -o images/ouput.png

Command arguments

  • -f: Input text file path
  • -o: Output image file path
  • -w: Image width (default 400px)
  • -h: Input height (default 400px)
  • -x: Anti-aliasing multiplier (default 1)
  • -p: Camera position coordinates (default (0.0, 0.0, 0.0))
  • -a: Camera rotation axis vector (default (0.0, 0.0, 1.0))
  • -n: Camera rotation angle (default 0 degrees)
  • -r: Aperture radius of camera (default 0.0)
  • -t: Focal length of camera (default 1.0)

-f and -o are mandatory, the rest are optional.

References

raytracer's People

Contributors

c3phal0p0d avatar

Watchers

 avatar

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.