Skip to content

Commit 39b0342

Browse files
committed
add task8
1 parent 11ceb5c commit 39b0342

File tree

507 files changed

+186873
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

507 files changed

+186873
-61
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"files.associations": {
33
"random": "cpp",
4-
"cmath": "cpp"
4+
"cmath": "cpp",
5+
"atomic": "cpp",
6+
"*.tcc": "cpp",
7+
"iomanip": "cpp",
8+
"istream": "cpp",
9+
"ostream": "cpp"
510
}
611
}

Notes13.md

Lines changed: 0 additions & 1 deletion

Notes16.md

Lines changed: 9 additions & 4 deletions

Notes17.md

Lines changed: 10 additions & 2 deletions

Notes18.md

Lines changed: 11 additions & 2 deletions

Notes21.md

Lines changed: 32 additions & 2 deletions

README.md

Lines changed: 10 additions & 1 deletion

task7/task7/task7.xcodeproj/xcuserdata/lilin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,32 @@
77
<BreakpointProxy
88
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
99
<BreakpointContent
10-
uuid = "F788D66F-EB15-4DE4-B740-1171D0AB7CDB"
10+
uuid = "07661B8A-B7FB-457D-B334-F649D42CEE89"
1111
shouldBeEnabled = "No"
1212
ignoreCount = "0"
1313
continueAfterRunningActions = "No"
1414
filePath = "task7/Renderer.cpp"
1515
startingColumnNumber = "9223372036854775807"
1616
endingColumnNumber = "9223372036854775807"
17-
startingLineNumber = "22"
18-
endingLineNumber = "22"
17+
startingLineNumber = "35"
18+
endingLineNumber = "35"
1919
landmarkName = "Renderer::Render(scene)"
2020
landmarkType = "7">
2121
</BreakpointContent>
2222
</BreakpointProxy>
2323
<BreakpointProxy
2424
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
2525
<BreakpointContent
26-
uuid = "9F733401-2730-41AB-93A9-EF0543841AD0"
27-
shouldBeEnabled = "Yes"
28-
ignoreCount = "0"
29-
continueAfterRunningActions = "No"
30-
filePath = "task7/Scene.cpp"
31-
startingColumnNumber = "9223372036854775807"
32-
endingColumnNumber = "9223372036854775807"
33-
startingLineNumber = "79"
34-
endingLineNumber = "79"
35-
landmarkName = "Scene::castRay(ray, depth)"
36-
landmarkType = "7">
37-
</BreakpointContent>
38-
</BreakpointProxy>
39-
<BreakpointProxy
40-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
41-
<BreakpointContent
42-
uuid = "5CF217F2-FDA8-4E2A-B0F5-F114137246C2"
43-
shouldBeEnabled = "Yes"
26+
uuid = "8B231DF7-9EE2-42E5-88EB-FE2EAA26FE18"
27+
shouldBeEnabled = "No"
4428
ignoreCount = "0"
4529
continueAfterRunningActions = "No"
46-
filePath = "task7/Scene.cpp"
30+
filePath = "task7/Renderer.cpp"
4731
startingColumnNumber = "9223372036854775807"
4832
endingColumnNumber = "9223372036854775807"
49-
startingLineNumber = "78"
50-
endingLineNumber = "78"
51-
landmarkName = "Scene::castRay(ray, depth)"
33+
startingLineNumber = "72"
34+
endingLineNumber = "72"
35+
landmarkName = "Renderer::Render(scene)"
5236
landmarkType = "7">
5337
</BreakpointContent>
5438
</BreakpointProxy>

task7/task7/task7/Renderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void Renderer::Render(const Scene& scene)
2828
if(!multithread)
2929
{
3030
// change the spp value to change sample ammount
31-
int spp = 3; // samples per pixel
31+
int spp = 30; // samples per pixel
3232
std::cout << "SPP: " << spp << "\n";
3333
//#pragma omp parallel for
3434
//config for the simple multithreading code
@@ -65,7 +65,7 @@ void Renderer::Render(const Scene& scene)
6565
{
6666
float total = (float)scene.width * (float)scene.height;
6767
// change the spp value to change sample ammount
68-
int spp = 8;
68+
int spp = 180;
6969
std::cout << "SPP: " << spp << "\n";
7070
#pragma omp parallel for
7171
//config for the simple multithreading code

task7/task7/task7/Scene.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,35 @@ Vector3f Scene::castRay(const Ray &ray, int depth) const
6565
Vector3f hitcolor = Vector3f(0);
6666

6767
//deal with light source
68-
if(intersection.emit.norm()>0)
69-
hitcolor = Vector3f(1);
70-
else if(intersection.happened)
68+
if (intersection.emit.norm() > 0)
69+
hitcolor = Vector3f(1);
70+
else if (intersection.happened)
7171
{
72-
Vector3f wo = normalize(-ray.direction); // 光的出射方向
73-
Vector3f p = intersection.coords; // 射线和物体的坐标
74-
Vector3f N = normalize(intersection.normal);
72+
Vector3f wo = normalize(-ray.direction);
73+
Vector3f p = intersection.coords;
74+
Vector3f N = normalize(intersection.normal);
7575

7676
float pdf_light = 0.0f;
77-
Intersection inter;
78-
sampleLight(inter,pdf_light); // 任意物体表面上任意一个点
77+
Intersection inter;
78+
sampleLight(inter, pdf_light);
7979
Vector3f x = inter.coords;
80-
Vector3f ws = normalize(x-p); //
80+
Vector3f ws = normalize(x - p);
8181
Vector3f NN = normalize(inter.normal);
8282

8383
Vector3f L_dir = Vector3f(0);
84-
// direct light
85-
// 这里的公式参考 Notes16 P43
86-
if((intersect(Ray(p,ws)).coords - x).norm() < 0.01)
84+
//direct light
85+
if ((intersect(Ray(p, ws)).coords - x).norm() < 0.01)
8786
{
88-
// inter.emit 是发光物体才有意义 不然inter.emit 是0
89-
// eval(wo,ws,N) 返回的是一个漫反射系数
90-
L_dir = inter.emit * intersection.m->eval(wo,ws,N)*dotProduct(ws,N) * dotProduct(-ws,NN) / (((x-p).norm()* (x-p).norm()) * pdf_light);
87+
L_dir = inter.emit * intersection.m->eval(wo, ws, N) * dotProduct(ws, N) * dotProduct(-ws, NN) / (((x - p).norm() * (x - p).norm()) * pdf_light);
9188
}
9289

9390
Vector3f L_indir = Vector3f(0);
9491
float P_RR = get_random_float();
95-
// indirect light
96-
if(P_RR < Scene::RussianRoulette)
92+
//indirect light
93+
if (P_RR < Scene::RussianRoulette)
9794
{
98-
Vector3f wi = intersection.m->sample(wo,N);
99-
L_indir = castRay(Ray(p,wi),depth) *intersection.m->eval(wi,wo,N) * dotProduct(wi,N) / (intersection.m->pdf(wi,wo,N)*Scene::RussianRoulette);
95+
Vector3f wi = intersection.m->sample(wo, N);
96+
L_indir = castRay(Ray(p, wi), depth) * intersection.m->eval(wi, wo, N) * dotProduct(wi, N) / (intersection.m->pdf(wi, wo, N) * Scene::RussianRoulette);
10097
}
10198
hitcolor = L_indir + L_dir;
10299
}

task7/task7/task7/Scene.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Scene
1717
{
1818
public:
1919
// setting up options
20-
int width = 1280;
21-
int height = 960;
20+
int width = 720;
21+
int height = 540;
2222
double fov = 40;
2323
Vector3f backgroundColor = Vector3f(0.235294, 0.67451, 0.843137);
2424
int maxDepth = 1;

task8/assignment8.zip

-2 MB
Binary file not shown.

task8/assignment8/assignment8/CGL/src/CGL.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/CMakeLists.txt

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/base64.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/base64.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/color.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/color.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/complex.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/complex.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/console.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/matrix3x3.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/matrix3x3.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/matrix4x4.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/matrix4x4.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/osdfont.c

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/osdtext.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/osdtext.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/quaternion.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/quaternion.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/renderer.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/tinyxml2.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/tinyxml2.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector2D.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector2D.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector3D.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector3D.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector4D.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/vector4D.h

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/viewer.cpp

100644100755
File mode changed.

task8/assignment8/assignment8/CGL/src/viewer.h

100644100755
File mode changed.

0 commit comments

Comments
 (0)