Skip to content

Latest commit

 

History

History

riow-111-defocus-blur

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

RIOW 1.11: Defocus Blur

View shader on Shadertoy - Published on 2018-09-04

thumbnail

These shaders are my implementation of the raytracer described in the (excellent) book "Raytracing in one weekend" [1] by Peter Shirley (@Peter_shirley). I have tried to follow the code from his book as much as possible, but I had to make some changes to get it running in a fragment shader:

  • There are no classes (and methods) in glsl so I use structs and functions instead. Inheritance is implemented by adding a type variable to the struct and adding ugly if/else statements to the (not so overloaded) functions.
  • The scene description is procedurally implemented in the world_hit function to save memory.
  • The color function is implemented using a loop because it is not possible to have a recursive function call in glsl.
  • Only one sample per pixel per frame is calculated. Samples of all frames are added in Buffer A and averaged in the Image tab.

You can find the raytracer / pathtracer in Buffer A.

= Ray tracing in one week =

= Ray tracing: the next week =

[1] http://in1weekend.blogspot.com/2016/01/ray-tracing-in-one-weekend.html

Shaders

Buffer A

Source: Buffer A.glsl

Inputs

  • iChannel0: Buffer A (linear, clamp, vflipped)

Image

Source: Image.glsl

Inputs

  • iChannel0: Buffer A (linear, clamp, vflipped)

Links

License

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.