-
Notifications
You must be signed in to change notification settings - Fork 1
/
Algorithm.txt
57 lines (47 loc) · 1.54 KB
/
Algorithm.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Path Tracer Algorithm
*/
initBuffers(accum[], frameBuffer[]);
while(true)
{
generateCameraRay(rays[], cameraStruct, rayCount);
hitCount = 0;
for(int i = 0; i<5; i++)
{
if(rayCount>0)
{
/*
"Ray-scene intersection is where all resources are used in gpu, hence should be most optimized.
This is done through compaction of rays."
*/
tracekernel(rays[], intersection[], primitives[], bvh, hitCount, rayCount);
//if there is an environmental map
shadeBackground(intersection[], rays[], occlusions[]);
if(hitCount>0)
{
/*
"in case you hit light directly, since light doesn't reflect"
*/
lightHit(intersection[], material[], accum[]);
/*
"sample brdf"
"in case there are multiple brdfs and we need one
*/
sampleBRDF(intersection[], material[]);
/*
"sample direct light and perform a simple occlusion test of sampled light"
*/
directLightSample(intersection[], directLightRays[]);
/*
"this methods are trivial hence can fit in one kernel"
sample_next_ray()
calculate_brdf_factor()
calculate_brdf_pdf()
compact_ray()
*/
randomWalk(intersection[], rays[], material[], accum[]);
}
}
}
updateFrame(accum[], frameBuffer[], frameCount);
}