Skip to content

Commit

Permalink
added task06
Browse files Browse the repository at this point in the history
  • Loading branch information
nobuyuki83 committed May 26, 2024
1 parent 671b1ab commit 0f87d1b
Show file tree
Hide file tree
Showing 11 changed files with 583 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_subdirectory(task02)
add_subdirectory(task03)
add_subdirectory(task04)
add_subdirectory(task05)
# add_subdirectory(task06)
add_subdirectory(task06)
# add_subdirectory(task07)
# add_subdirectory(task08)
# add_subdirectory(task09)
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Topics:
|(3)<br>Apr. 22| **Parametric representation**<br/>Bézier curve, polynominal | [task02](task02) | [[7] ](http://nobuyuki-umetani.com/acg2024s/parametric_curve.pdf) [[8]](http://nobuyuki-umetani.com/acg2024s/polynominal.pdf) |
|(5)<br>May 7| **Coordinate transformation**<br>Affine, homography transformation | [task03](task03) | [[9]](http://nobuyuki-umetani.com/acg2024s/transformation.pdf) [[10]](http://nobuyuki-umetani.com/acg2024s/transformation_homogeneous_2d.pdf) [[11]](http://nobuyuki-umetani.com/acg2024s/transformation_homogeneous_3d.pdf) |
|(4)<br>May 13| **Graphics pipeline**<br>depth buffer method, shading, shadow, anti aliasing | [task04](task04) | [[12]](http://nobuyuki-umetani.com/acg2024s/rasterization_3d.pdf) [[13]](http://nobuyuki-umetani.com/acg2024s/graphics_pipeline.pdf) |
|(6)<br>May 20| **Ray Casting 1**<br/>spatial data structure | [task05](task05) | [[14]](http://nobuyuki-umetani.com/acg2024s/shading.pdf) [[15]](http://nobuyuki-umetani.com/acg2024s/rasterization_subpixel.pdf) [[16]](http://nobuyuki-umetani.com/acg2024s/implicit_modeling.pdf) |
|(7)<br>May 27| **Ray Casting 2**<br>Rendering equation, Monte Carlo integration | task06 | |
|(6)<br>May 20| **Ray Casting 1**<br/>spatial data structure | [task05](task05) | [[14]](http://nobuyuki-umetani.com/acg2024s/shading.pdf) [[16]](http://nobuyuki-umetani.com/acg2024s/implicit_modeling.pdf) |
|(7)<br>May 27| **Ray Casting 2**<br>Rendering equation, Monte Carlo integration | [task06](task06) | [[15]](http://nobuyuki-umetani.com/acg2024s/rasterization_subpixel.pdf) [[17]](http://nobuyuki-umetani.com/acg2024s/ray_casting.pdf) [[18]](http://nobuyuki-umetani.com/acg2024s/monte_carlo_integration.pdf) [[19]](http://nobuyuki-umetani.com/acg2024s/ray_triangle_collision.pdf) |
|(8)<br>June 3| **Character animation**<br> Linear blend skinning | task07 | |
|(9)<br>June 10| Guest lecture by Dr. Rex West | | |
|(10)<br>June 17| **Optimization** <br> Inverse kinematic | task08 | |
Expand Down Expand Up @@ -83,8 +83,8 @@ Look at the following document.
| [task03](task03) | **Perspectively-correct texture mapping**<br>rasterization of triangle, barycentric coordinate | <img src="task03/preview.png" width=100px> |
| [task04](task04) | **Vertex shader practice** <br>Rendering pipeline, mirror reflection, OpenGL | <img src="task04/preview.png" width=100px> |
| [task05](task05) | **Fragment shader practice**<br>Ray marching method, CSG modeling, implicit modeling | <img src="task05/preview.png" width=100px> |
| task06 | **Monte Carlo integration**<br>Multiple importance sampling, path tracing, rendering equation | <img src="task06/preview.png" width=100px> |
| task07 | TBD | |
| [task06](task06) | **Monte Carlo integration1**<br>Ambient occlusion, importance sampling, BVH | <img src="task06/preview.png" width=100px> |
| task07 | **Monte Carlo integration2**<br/>Multiple importance sampling | <img src="task07/preview.png" width=100px> |
| task08 | **Skeletal Character Animation**<br>Linear blend skinning, articulated rigid body | <img src="task08/preview.png" width=100px> |
| task09 | TBD | |
| task10 | TBD | |
Expand All @@ -100,22 +100,45 @@ Look at the following document.
## Slides

- [[1] Introduction](http://nobuyuki-umetani.com/acg2024s/introduction.pdf)

- [[2] C++ programming](http://nobuyuki-umetani.com/acg2024s/cpp.pdf)

- [[3] Git+GitHub](http://nobuyuki-umetani.com/acg2024s/git.pdf)

- [[4] Digital Image](http://nobuyuki-umetani.com/acg2024s/digital_image.pdf)

- [[5] Rasterization in 2D](http://nobuyuki-umetani.com/acg2024s/rasterization_2d.pdf)

- [[6] Barycentric Coordinates](http://nobuyuki-umetani.com/acg2024s/barycentric_coordinates.pdf)

- [[7] Parametric Curve](http://nobuyuki-umetani.com/acg2024s/parametric_curve.pdf)

- [[8] Polynominal Root finding](http://nobuyuki-umetani.com/acg2024s/polynominal.pdf)

- [[9] Coordinate Transformation](http://nobuyuki-umetani.com/acg2024s/transformation.pdf)

- [[10] 2D Homogeneous Transformation](http://nobuyuki-umetani.com/acg2024s/transformation_homogeneous_2d.pdf)

- [[11] 3D Homogeneous Transformation](http://nobuyuki-umetani.com/acg2024s/transformation_homogeneous_3d.pdf)

- [[12] 3D Rasterization](http://nobuyuki-umetani.com/acg2024s/rasterization_3d.pdf)

- [[13] Graphics Pipeline](http://nobuyuki-umetani.com/acg2024s/graphics_pipeline.pdf)

- [[14] Shading](http://nobuyuki-umetani.com/acg2024s/shading.pdf)

- [[15] Subpixel Effect](http://nobuyuki-umetani.com/acg2024s/rasterization_subpixel.pdf)

- [[16] Implicit Modeling](http://nobuyuki-umetani.com/acg2024s/implicit_modeling.pdf)

- [[17]Ray Casting](http://nobuyuki-umetani.com/acg2024s/ray_casting.pdf)

- [[18]Monte Carlo Integration](http://nobuyuki-umetani.com/acg2024s/monte_carlo_integration.pdf)

- [[19]Ray Triangle Collision](http://nobuyuki-umetani.com/acg2024s/ray_triangle_collision.pdf)





## Reading Material
Expand Down
35 changes: 35 additions & 0 deletions task06/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# specify the version of cmake (intentionally using old version for those who cannot update CMake)
cmake_minimum_required(VERSION 3.10)

#############################
# set C++ detail
enable_language(CXX) # we are using C++
set(CMAKE_CXX_STANDARD 17) # we are using C++ 17
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) # we are using STL library

#############################
# set project name

project(task07)

#############################
# define macro
add_definitions(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")

#############################
# specifying libraries to use

########################
# include, build, and link

include_directories(
${PROJECT_SOURCE_DIR}/../external
${PROJECT_SOURCE_DIR}/../external/eigen
)

add_executable(${PROJECT_NAME}
main.cpp
)

target_link_libraries(${PROJECT_NAME}
)
77 changes: 77 additions & 0 deletions task06/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Task06: Ambient Occlusion and BVH (Monte Carlo Integration, Importance Sampling)

![preview](preview.png)

**Deadline: May 30th (Thu) at 15:00pm**

----

## Before Doing Assignment

If you have not done the [task01](../task01), [task02](../task02) do it first to set up the C++ development environment.

Follow [this document](../doc/submit.md) to submit the assignment, In a nutshell, before doing the assignment,
- make sure you synchronized the `main ` branch of your local repository to that of remote repository.
- make sure you created branch `task06` from `main` branch.
- make sure you are currently in the `task06` branch (use `git branch -a` command).

Now you are ready to go!

---

## Problem 1 (compilation practice)

1. Build the code using cmake
2. Run the code **with release mode**

The program will output `normal_map.png` that update the image below

![problem1](normal_map.png)

## Problem 2 (efficient search using BVH)

The code in Problem 1 is very slow. It is because the computation of intersection betweeen a ray and a triangle mesh is **brute force**.

Comment out the brute force intersection computation (from `line#146` to `line#158`) and implement code to evaluate BVH to accelerate the computation around `line #120`.

The program output the computation time. Fill the table below to compare the timing before/after the acceleraion. Please make sure that you build the code **with release mode**



| brute force | BVH |
| ----------- | ------ |
| ??? ms | ??? ms |




## Problem 3 (ambient occlusion)

Now you have the code for fast ray-mesh intersection. Using that code, let's compute the ambient occlusion.

- First, Comment out the `continue;` in the `main()` at `line #21` in the original code . This will enable the ambient occlusion computation. The problem will output `ao.png`.

- Then fix the bug in `line #223`in the original code to correctly compute the ambient occlusion. The result should looks like `preview.png` at the begining of this document.

- Finally, modify the name of the outut image as `ao_uniform.png`



## Problem 4 (importance sampling)

The computation of ambient occlusion is a bit noisy (i.e., the variance is high). Let's implement the importance sampling to reduce the variance. Write some code to compute the direction and PDF of **cosine-weighted sampling of hemisphere **around `line #53`. Modify the name of the output image `ao.png` as `ao_cosweight.png`.

| Uniform sample | Cosine weighted sample |
| --------------------------- | ----------------------------- |
| ![problem2](ao_uniform.png) | ![problem3](ao_cosweight.png) |



Observe that the variance (noise) is reduced using the importance sampling




## After Doing the Assignment

After modify the code, push the code and submit a pull request. Make sure your pull request only contains the files you edited. Good luck!
Binary file added task06/ao_cosweight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added task06/ao_uniform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0f87d1b

Please sign in to comment.