Giter Site home page Giter Site logo

brenomfviana / rain Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 0.0 10.94 MB

RAIN is a 3D image renderer running on the CPU made from scratch. This renderer uses Ray Tracing technique and implements KD-Tree and multithreading to optmization.

License: MIT License

Makefile 0.38% C++ 99.53% C 0.09%
rain raytracing renderer render coursework image-rendering 3d 3d-graphics blinn-phong ray-tracing

rain's Introduction

RAIN

Description

Rain is an image renderer that uses ray casting and ray tracing techniques.

About

This image renderer is a project of Computer Graphics course of the Federal University of Rio Grande do Norte (UFRN).

The name rain is an acronym for RAy tracINg.

Features and TO DOs

  • Ray Tracer

    • Anti-aliasing
    • Threads
    • Shaders
      • Background
      • Normal to RGB
      • Depth Map
      • Blinn-Phong
      • Toon (Cel)
      • Lambertian
  • Scene

    • Scene reader
    • Scene components
      • Light
        • Directional Light
        • Point Light
        • Spotlight
      • Shapes
        • Sphere
        • Triangle
        • Box
        • Mesh
        • Materials
          • Blinn-Phong
          • Diffuse
          • Metal
          • Toon
          • Dielectrics
          • Texture
            • Simple Texture
            • Perlin Noise Texture
    • Camera
      • Perspective
      • Orthogonal
  • Printer

    • ASCII
    • Binary
    • Supported image file formats
      • PPM
  • Miscellaneous

    • Progress Bar
    • Show render time

Dependencies

  • C++11
  • GLM 0.9.9

How to compile

Use the make command to compile the renderer.

How to use

Choose a scene and run the renderer passing the file path of the scene as an argument to render an image. See here all the images rendered by rain

# ./render scenefile.txt
./render hello-rain.txt

Scene file format

Sky

Image

alt text

NOTE: The image was converted to png format to be shown here, the renderer does not generate images in that format.

Scene Description File

# Output settings
NAME: sky.ppm
TYPE: PPM
CODIFICATION: binary # or ascii
WIDTH: 1200
HEIGHT: 600
# Ray Tracer Settings
SAMPLES: 1 # Number of samples for anti-aliasing
RAYS:    0 # Number of rays of the recursion
# Camera
CAMERA:
    PERSPECTIVE
    LOOK_FROM: 0 0 0
    LOOK_AT: 0 0 -1
    VUP: 0 1 0
    VFOV: 90
    ASPECT_RATIO: 2
    APERTURE: 0
    FOCAL_DISTANCE: 1
# Scene description
SHADER:
    BACKGROUND
BACKGROUND:
    TOP: 0.5 0.7 1 # Top color
    BOTTOM: 1 1 1  # Bottom color

Blinn-Phong Shader

Image

alt text

NOTE: The image was converted to png format to be shown here, the renderer does not generate images in that format.

Scene Description File

# Output settings
NAME: point_light_1_perspective.ppm
TYPE: PPM
CODIFICATION: binary # or ascii
WIDTH: 1200
HEIGHT: 600
# Ray Tracer Settings
SAMPLES: 100 # Number of samples for anti-aliasing
RAYS:    0   # Number of rays of the recursion
# Camera
CAMERA:
    PERSPECTIVE
    LOOK_FROM: 3 3 2
    LOOK_AT: 0 0 -1
    VUP: 0 1 0
    VFOV: 90
    ASPECT_RATIO: 2
    APERTURE: 0
    FOCAL_DISTANCE: 1
# Scene description
SHADER:
    BLINNPHONG
    AMBIENT_LIGHT: 0.3 0.3 0.3
BACKGROUND:
    TOP: 0.5 0.7 1 # Top color
    BOTTOM: 1 1 1  # Bottom color
COMPONENTS:
    POINT_LIGHT:
        ORIGIN: 0 0 0
        INTENSITY: 1 1 1
    SPHERE:
        ORIGIN: 0 -100.5 0
        RADIUS: 100
        BLINN_PHONG_MATERIAL:
            KA: 0.1 0.1 0.1
            KD: 0.3 0.3 0.3
            KS: 1 1 1
            P: 64
    SPHERE:
        ORIGIN: 1 0 0
        RADIUS: 0.5
        BLINN_PHONG_MATERIAL:
            KA: 0.1 0.1 0.1
            KD: 0.3 0 0
            KS: 0.9 0.9 0.9
            P: 64
    SPHERE:
        ORIGIN: -1 0 0
        RADIUS: 0.5
        BLINN_PHONG_MATERIAL:
            KA: 0.1 0.1 0.1
            KD: 0 0.3 0.8
            KS: 0.9 0.9 0.9
            P: 64
    SPHERE:
        ORIGIN: 0 0 1
        RADIUS: 0.5
        BLINN_PHONG_MATERIAL:
            KA: 0.1 0.1 0.1
            KD: 0.5 0.5 0
            KS: 0.9 0.9 0.9
            P: 64
    SPHERE:
        ORIGIN: 0 1 0
        RADIUS: 0.5
        BLINN_PHONG_MATERIAL:
            KA: 0.1 0.1 0.1
            KD: 0 0.2 0
            KS: 0.9 0.9 0.9
            P: 64

Lambertian Shader

Image

alt text

NOTE: The image was converted to png format to be shown here, the renderer does not generate images in that format.

Scene Description File

# Output settings
NAME: bunnies.ppm
TYPE: PPM
CODIFICATION: binary # or ascii
WIDTH: 1200
HEIGHT: 600
# Ray Tracer Settings
SAMPLES: 100 # Number of samples for anti-aliasing
RAYS:    100 # Number of rays of the recursion
# Camera
CAMERA:
    PERSPECTIVE
    LOOK_FROM: 0 0 4
    LOOK_AT: 0 0 -1
    VUP: 0 1 0
    VFOV: 20
    ASPECT_RATIO: 2
    APERTURE: 0
    FOCAL_DISTANCE: 1
# Scene description
SHADER:
    LAMBERTIAN
BACKGROUND:
    TOP: 0.09803921568 0.09803921568 0.43921568627   # Top color
    BOTTOM: 0 0 0 # Bottom color
COMPONENTS:
    PLANE:
        P1: -100 -0.5 100
        P2: 100 -0.5 100
        P3: 100 -0.5 -100
        P4: -100 -0.5 -100
        LAMBERTIAN:
            CHECKER_TEXTURE:
                ODD: 0.3 0.3 0.3
                EVEN: 0 0 0
    PLANE:
        P1: -0.5 0.6 -1
        P2: 0.5 0.6 -1
        P3: 0.5 0.6 -2
        P4: -0.5 0.6 -2
        DIFFUSE_LIGHT:
            EMIT: 10 10 10
    SPHERE:
        ORIGIN: -1 0 -1
        RADIUS: 0.5
        LAMBERTIAN:
            PERLIN_TEXTURE:
                VALUE: 1
    SPHERE:
        ORIGIN: 1 0 -1
        RADIUS: 0.5## License

        This project is licensed under MIT license - see the [MIT](LICENSE) file for details.

        DIELECTRIC:
            RI: 1.2
    SPHERE:
        ORIGIN: 1 0 -1
        RADIUS: -0.48
        DIELECTRIC:
            RI: 1.2
    MESH:
        FILE: samples/mesh/bunny.obj
        METAL:
            ALBEDO: 0.8 0.6 0.2
            FUZZ: 1
        SCALE:
            VALUE: 4 4 4
        TRANSLATE:
            VALUE: 0.2 -0.5 0
        ROTATE:
            VALUE: 0 25 0
    MESH:
        FILE: samples/mesh/bunny.obj
        METAL:
            ALBEDO: 1 0 0
            FUZZ: 0
        SCALE:
            VALUE: 4 4 4
        TRANSLATE:
            VALUE: -0.5 -0.5 0
        ROTATE:
            VALUE: 0 60 0

License

This project is licensed under the MIT License - see the LICENSE file for details.

rain's People

Contributors

brenomfviana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.