Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab2 Yi Liu #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 51 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
# lab02-debugging

Yi Liu

# Setup

Create a [Shadertoy account](https://www.shadertoy.com/). Either fork this shadertoy, or create a new shadertoy and copy the code from the [Debugging Puzzle](https://www.shadertoy.com/view/flGfRc).

Let's practice debugging! We have a broken shader. It should produce output that looks like this:
[Unbelievably beautiful shader](https://user-images.githubusercontent.com/1758825/200729570-8e10a37a-345d-4aff-8eff-6baf54a32a40.webm)

It don't do that. Correct THREE of the FIVE bugs that are messing up the output. You are STRONGLY ENCOURAGED to work with a partner and pair program to force you to talk about your debugging thought process out loud.
# Shader Link
https://www.shadertoy.com/view/M3fcD2


<p align="center">
<img src="https://github.com/yiliu1237/lab02-debugging/blob/main/shader_result.gif?raw=true"/>
</p>



## Bug1: Syntax Error
- 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.

## Bug2: Incorrect Input to raycast Function
- 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.

## Bug3: Reflection Calculation Error
- 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.

## Bug4: Scene Aspect Ratio Distortion
- 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.


## Bug5: Insufficient Iterations in march Function
- 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:

Extra credit if you can find all FIVE bugs.
```
for (int i = 0; i < 300; ++i) { ... }
```

# Submission
- Create a pull request to this repository
- In the README, include the names of both your team members
- In the README, create a link to your shader toy solution with the bugs corrected
- In the README, describe each bug you found and include a sentence about HOW you found it.
- Make sure all three of your shadertoys are set to UNLISTED or PUBLIC (so we can see them!)
- How It Was Found: Visual artifacts and incomplete rendering prompted the inspection of the march funtion.
Binary file added shader_result.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.