-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImage.glsl
37 lines (34 loc) · 1.35 KB
/
Image.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Ray Tracing - Primitives. Created by Reinder Nijhoff 2019
// The MIT License
// @reindernijhoff
//
// https://www.shadertoy.com/view/tl23Rm
//
// I wanted to create a reference shader similar to "Raymarching - Primitives"
// (https://www.shadertoy.com/view/Xds3zN), but with ray-primitive intersection
// routines instead of sdf routines.
//
// As usual, I ended up mostly just copy-pasting code from Íñigo Quílez:
//
// https://iquilezles.org/articles/intersectors
//
// Please let me know if there are other routines that I should add to this shader.
//
// You can find all intersection routines in the Common tab. The routines have a similar
// signature: a routine returns the distance to the first hit inside the
// [distBound.x, distBound.y] interval and will set the normal if an intersection is found.
// If no intersection is found, the routine will return MAX_DIST.
//
// I made a simple ray tracer (Buffer A) to visualize a scene with all primitives.
//
// Use your mouse to change the camera viewpoint.
//
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec4 data = texelFetch(iChannel0, ivec2(fragCoord), 0);
vec3 col = data.rgb / data.w;
// gamma correction
col = max( vec3(0), col - 0.004);
col = (col*(6.2*col + .5)) / (col*(6.2*col+1.7) + 0.06);
// Output to screen
fragColor = vec4(col,1.0);
}