All Projects → bewuethr → bash-raytracer

bewuethr / bash-raytracer

Licence: MIT license
A raytracer in (mostly) Bash

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to bash-raytracer

raytracer
Raytracer in C.
Stars: ✭ 24 (-36.84%)
Mutual labels:  raytracer
mmterm
View proteins and trajectories in the terminal
Stars: ✭ 87 (+128.95%)
Mutual labels:  terminal-graphics
TextGraphic
TextGraphic is a framework for creating Textual Graphics. It provides layers, styling, rich color, text justification, layouts, tables, view-ports, transparency, etc.
Stars: ✭ 83 (+118.42%)
Mutual labels:  terminal-graphics
monte-carlo-ray-tracer
Physically based renderer with Path Tracing and Photon Mapping.
Stars: ✭ 246 (+547.37%)
Mutual labels:  raytracer
pixelizer
An efficient image pixelizer written in go
Stars: ✭ 103 (+171.05%)
Mutual labels:  terminal-graphics
mcrt
Monte Carlo Raytracer from Scratch in C++11/14
Stars: ✭ 22 (-42.11%)
Mutual labels:  raytracer
Photon-v2
A program that takes photographs of a virtual world.
Stars: ✭ 75 (+97.37%)
Mutual labels:  raytracer
ctrt
Compile-Time Ray Tracer in Rust ported from C++
Stars: ✭ 82 (+115.79%)
Mutual labels:  raytracer
wasm-raytracer
a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL
Stars: ✭ 158 (+315.79%)
Mutual labels:  raytracer
PassLock
PassLock is a medium-security password manager that encrypts passwords using Advanced Encryption Standards (AES)
Stars: ✭ 44 (+15.79%)
Mutual labels:  terminal-graphics
rust-tracer
Simple Ray tracer written in Rust
Stars: ✭ 14 (-63.16%)
Mutual labels:  raytracer
C-Raytracer
A CPU raytracer from scratch in C
Stars: ✭ 49 (+28.95%)
Mutual labels:  raytracer
Monte-Carlo-Path-Tracer
A realistic Monte Carlo Path Tracer project for CS230 (Virtual Reality and Interactive 3D Graphics Display), ACM Class, SJTU
Stars: ✭ 19 (-50%)
Mutual labels:  raytracer
TermGL
2D & 3D graphics engine in the terminal [C/C++]
Stars: ✭ 219 (+476.32%)
Mutual labels:  terminal-graphics
table2ascii
Python library for converting lists to fancy ASCII tables for displaying in the terminal and on Discord
Stars: ✭ 31 (-18.42%)
Mutual labels:  terminal-graphics
SwiftTracer
A raytracer written in Swift for learning and lulz
Stars: ✭ 14 (-63.16%)
Mutual labels:  raytracer
Habitican-Curse
A Terminal application for HabitRPG using the python curses library
Stars: ✭ 30 (-21.05%)
Mutual labels:  terminal-graphics
Iyan3d
Iyan 3D Professional Edition - 3D animation app for iOS
Stars: ✭ 27 (-28.95%)
Mutual labels:  raytracer
brain-monitor
A terminal app written in Node.js to monitor brain signals in real-time
Stars: ✭ 119 (+213.16%)
Mutual labels:  terminal-graphics
upp-components
A collection of packages for U++ framework.
Stars: ✭ 36 (-5.26%)
Mutual labels:  terminal-graphics

Bash Raytracer

Lint code base Add issues to project

A raytracer written in Bash (except for floating point calculations, where I use bc). It requires a terminal emulator capable of displaying 256 colours (using the -8 option) or true colour.

Change log

2016/11/02

The latest changes allow for quite some variety in what can be achieved – for example a checkered plane with a single light source (suffering horribly from aliasing):

Point light source plane horizontal

The same scene seen from the top, better hiding the fact that the pixels are huge:

Point light source plane vertical

A sphere in front of a slanted plane, lit by three point light sources:

Sphere plane and 3 point lights

Or this triangle with spheres on its vertices, sitting on a plane, dimly lit by three point light sources:

Triangle and 3 spheres

2016/11/01

  • Add option to use multiple lights instead of single light source
  • Add new light source type: point lights
  • Factor out scene description into separate file for improved tinkering
  • Contribution of ambient lights reduced to just 5%

Test scene with one directional light and one point light source (notice differing levels of shadow intensity):

rendering10

2016/10/25

  • Command line options and usage text: simpler setup for size / full screen, field of view and colours settings, using getopts and this syntax:

    raytracer [-hf8] [-v FOV] [-s FACTOR]
  • Default to 24-bit colours and fall back to 8-bit colours when the new -8 option is used

  • Reduce intensity of ambient lighting to 10%

Colours in the shadows are now discernible and gradients look a bit smoother:

rendering9

2016/10/24

  • Shadows: every hit point checks if there is an object covering the directional light; if there is, the point is shaded with just ambient colour (20% of light intensity). If there is nothing covering the light, diffuse colouring is added. I've also tweaked the light direction a little.
  • New resolution: I've switched my system (no more MSYS2 Bash under Windows, proper Ubuntu now!) and have adjusted the default resolution to match the size of the original Whitted picture.

Because there aren't many colours available, the shadows tend to be very dark and "dark yellow" on the checkered floor becomes "pitch black":

rendering8

I plan on switching to true colour soon, which should get rid of this problem.

2016/10/03

  • Lambertian shading: similar to incident angle shading, but the light source is no longer the camera; the direction of light can be defined freely in space. The light source is distant, i.e., all light rays are parallel.
  • No shadows (yet)

Unlit parts of objects are pitch black, which doesn't look super natural:

rendering7

  • Add ambient lighting to scene at 20% of intensity of light source; it's a bit much, but the RGB to terminal colour mapping results in all black otherwise (or my mapping is screwed up)

Rendered image:

rendering8

2016/09/16

  • Add incident angle shader: treat camera as light source, shade surfaces darker the smaller the incident angle of the camera ray

rendering6

2016/09/10

  • Make rgbcolours into a sourceable library of test functions
  • Add test function facing_ratio to rgbcolours to test interpolation between an RGB triple and (0,0,0) for later use with a simple facing ratio shading technique

Testing facing_ratio with all the colours of the last rendering, drawing 21 shades each:

facing_ratio_test

2016/09/07

  • Checker board texture for triangles (square size should be slightly reduced, and colours are currently inverted from original)
  • Use RGB to terminal colour mapping everywhere
  • Slight adjustment to right end of rectangle in scene

Rendered image:

rendering5

And overlaid on top of the original scene:

rendering5whitted

2016/09/01

  • Groundwork for shading: figure out mapping from RGB triplets to terminal colours, mostly following this Stack Overflow answer
  • Auxiliary script to show and label all terminal colours: tools/showcolours
  • Auxiliary script to loop over RGB space, convert to terminal colours and display them: tools/rgbcolours

Output of these two scripts: showcolours (left) and rgbcolours (right, slightly re-sized)

showcolours rgbtest

2016/08/30

  • Add ray-triangle intersection function (simple "inside-outside" technique)
  • Replace infinite plane with two triangles and change a few colours to accommodate yellow/red plane (will be checkered later)
  • Clean up bc parts after understanding how to pass arrays to functions by reference (which is mentioned in the manual, but not shown)

Rendered image:

rendering4

And overlaid on top of the original scene:

rendering4whitted

2016/07/11

  • Add ray-plane intersection function
  • Add plane to scene

Rendered image:

rendering3

And overlaid on top of the original scene:

rendering3whitted

2016/07/02

  • Now capable of handling multiple objects
    • Loops over all variables with a name that starts with obj_
    • Calculates actual intersection point, tests for closest one
    • Still only spheres, though
  • Scene with two spheres
    • "Glass" is currently red
    • New camera-to-world matrix for simpler scene geometry values

The rendered image now looks like this:

rendering2

Overlaid on top of the original Whitted scene:

rendering2whitted

2016/06/22

  • First version capable of generating an image
  • Simple raycasting: test for intersection, colouring pixel in sphere colour if ray intersects sphere and background colour if not (no shading)
  • Camera ray generation with hard-coded camera position and scene (a single sphere)
  • Intersection test is just true/false and doesn't return closest intersection, so clipping doesn't work yet
  • Image size is whatever the terminal size is when starting the raytracer
  • No reflection, refraction, phong or other illumination models, shadows, shapes other than spheres, depth of field effect, motion blur, bump or environment mapping, subsurface scattering, ... you name it.

The rendered image looks like this:

rendering1

If you think you can see an uncanny resemblance to the famous Whitted raytracer scene (minus the second sphere, the plane and all effects), you're completely right. That's what it'll become when it's grown up.

whitted

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].