Yi Liu
Create a Shadertoy account. Either fork this shadertoy, or create a new shadertoy and copy the code from the Debugging Puzzle.
https://www.shadertoy.com/view/M3fcD2
- Issue: The variable uv2 was declared as vec instead of vec2.
- Fix: Change the type of uv2 to vec2.
- How It Was Found: The Shadertoy editor highlighted this as a syntax error upon running the shader.
- Issue: The uv variable was incorrectly used when calling the raycast function.
- Fix: Use uv2 instead of uv when calling raycast to ensure proper coordinates are passed.
- How It Was Found: The rendered output was distorted, leading to inspection of how coordinates were handled.
- Issue: The reflection was not computed correctly due to the misuse of the reflect function.
- Fix: Update the reflect function call to use the correct vector inputs:
dir = reflect(dir, nor);
- How It Was Found: The reflection on objects appeared incorrect, leading a deeper look into the reflection calculation.
- Issue: The rendered scene was stretched along the x-axis, showing ellipsoids instead of spheres.
- Fix: Adjust the scene's aspect ratio to prevent distortion.
uv2.x *= iResolution.x;
uv2.x /= iResolution.y;
- How It Was Found: Comparing the reference Shadertoy to the current output revealed the ratio issue.
- Issue: The march function was not iterating through enough steps, causing the scene to render incorrectly.
- Fix: Increase the number of iterations in the march function to allow sufficient steps for ray marching:
for (int i = 0; i < 300; ++i) { ... }
- How It Was Found: Visual artifacts and incomplete rendering prompted the inspection of the march funtion.