diff --git a/README.md b/README.md index aa0f112..9b73d67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,45 @@ +# shadertoy link +https://www.shadertoy.com/view/msS3zt + +# bugs +- bug 1: compile error. uv2 was type vec and not vec2 +- bug 2: incorrect inputs to raycast() in mainImage(). uv was inputted and not uv2. +- bug 3: improper resolution. the spheres were smooshed. after creating uv2 (mapping from [0,1] to [-1,-1]), + we need to multiply uv2.x by iresX/iresY. this is because when we start with the uv (uv = fragCordXY/resXY), we could have any mix of x and y lengths. if x >> y then the y domain will look very smooshed, and so on. so we need to preserve the aspect ratio. in total we have + + * fragCoord : [[0, resX], [0, resY]] + * * uv = fragCordXY/resXY + * uv: [[0:1], [0:1]] + * * uv2 = 2. * uv - vec2(1.) + * * uv2 = 2. * ((fcX/resX), (fcY/resY)) - (1., 1.) + * * *(this was what we added to fix the bug!)* --> uv2.x *= resX/resY + * * uv2 = 2. * ((fcX/resY), (fcY/resY)) - (1., 1.) + + ^ now that both components of uv2 have the same denominator, the aspect ratio is preserved + + +- bug 4: the reflections were off. +

+

**before**

+

**after**

+

+ +

+ image + image +

+ + ** Initially i had thought that the error was in computeMaterial, but this just computes the geometry and color of the hit object based on a point and a direction. The reflection error was in the sdf3D() fucntion. after we get the interseciton point along our direction **dir** (which is from the eye to the pixel), we want to call the raymarch function with a reflected direction. on line 75, the bug was *dir = reflect(eye, nor)*; when in fact, we want to reflect dir along the normal. so, **dir = reflect(dir, nor)**. In march(), the raymarching function, the inputs are march(origin = isect + dir * 0.01, dir = dir, t = t, hitObj = hitObj). this allows us to find the color of the reflected object, since we raymarch along the reflected direction. once we get that hidObj id, we can use computeMaterial to get this reflected color (specReflCol in code). The final color is a mix of the original object color, the original times the specRefColor, using "fresnel". + + bug 5: idk, didn't have time + + + + +# - + + + # lab06-debugging # Setup