Skip to content

Commit

Permalink
Update OBJ loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Nov 13, 2017
1 parent 40339c2 commit cd4fcbe
Show file tree
Hide file tree
Showing 26 changed files with 516 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ main
*.jpg
*.prof

*.mayaSwatches
*.mb

!results/*.jpg
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ go build ./src/main.go

## Result

#### Gopher

<img src="./results/gopher.jpg" alt="gopher.jpg" width="500"/>

#### Cornell box

<img src="./results/cbox.jpg" alt="cbox.jpg" width="500"/>

The scene courtesy of Mitsuba renderer (W. Jakob 2010).

## Copyright

MIT License 2017 (c) Tatsuya Yatagawa (tatsy)
49 changes: 49 additions & 0 deletions data/cbox/cbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"name": "image",
"parameters": [
{"name": "width", "value": "512"},
{"name": "height", "value": "512"}
]
},
{
"name": "integrator",
"parameters": [
{"name": "type", "value": "path"},
{"name": "max-bounces", "value": "16"},
{"name": "num-samples", "value": "64"}
]
},
{
"name": "sensor",
"parameters": [
{"name": "type", "value": "perspective"},
{"name": "center", "value": "(278, 273, -800)"},
{"name": "target", "value": "(278, 273, -799)"},
{"name": "up", "value": "(0, 1, 0)"},
{"name": "fov", "value": "39.3077"},
{"name": "focus-distance", "value": "1000.0"},
{"name": "near-clip", "value": "10"},
{"name": "far-clip", "value": "2800"}
]
},
{
"name": "sampler",
"parameters": [
{"name": "type", "value": "independent"}
]
},
{
"name": "shape",
"parameters": [
{"name": "obj", "value": "cbox_objects.obj"}
]
},
{
"name": "light",
"parameters": [
{"name": "radiance", "value": "(16.0, 16.0, 16.0)"},
{"name": "obj", "value": "cbox_luminaire.obj"}
]
}
]
14 changes: 14 additions & 0 deletions data/cbox/cbox_luminaire.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file uses centimeters as units for non-parametric coordinates.

v 343.000000 544.828839 227.000000
v 343.000000 544.828839 332.000000
v 213.000000 544.828839 332.000000
v 213.000000 544.828839 227.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
f 1//1 2//2 3//3
f 1//4 3//5 4//6
27 changes: 27 additions & 0 deletions data/cbox/cbox_objects.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
newmtl grayWallSG
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
newmtl greenWallSG
illum 4
Kd 0.00 1.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
newmtl redWallSG
illum 4
Kd 0.50 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Ks 0.50 0.50 0.50
210 changes: 210 additions & 0 deletions data/cbox/cbox_objects.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib cbox_objects.mtl
v 549.599976 0.000000 559.200012
v 0.000000 0.000000 559.200012
v 0.000000 548.799988 559.200012
v 556.000000 548.799988 559.200012
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
usemtl grayWallSG
f 2//1 3//2 1//3
f 1//3 3//2 4//4
v 556.000000 548.799988 0.000000
v 556.000000 548.799988 559.200012
v 0.000000 548.799988 559.200012
v 0.000000 548.799988 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
f 5//5 6//6 8//7
f 8//7 6//6 7//8
v 552.799988 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 0.000000 559.200012
v 549.599976 0.000000 559.200012
v 130.000000 0.000000 65.000000
v 82.000000 0.000000 225.000000
v 240.000000 0.000000 272.000000
v 290.000000 0.000000 114.000000
v 423.000000 0.000000 247.000000
v 265.000000 0.000000 296.000000
v 314.000000 0.000000 456.000000
v 472.000000 0.000000 406.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
f 9//9 10//10 12//11
f 12//11 10//10 11//12
v 0.000000 0.000000 559.200012
v 0.000000 0.000000 0.000000
v 0.000000 548.799988 0.000000
v 0.000000 548.799988 559.200012
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
usemtl greenWallSG
f 21//13 22//14 24//15
f 24//15 22//14 23//16
v 423.000000 330.000000 247.000000
v 265.000000 330.000000 296.000000
v 314.000000 330.000000 456.000000
v 472.000000 330.000000 406.000000
v 423.000000 0.000000 247.000000
v 423.000000 330.000000 247.000000
v 472.000000 330.000000 406.000000
v 472.000000 0.000000 406.000000
v 472.000000 0.000000 406.000000
v 472.000000 330.000000 406.000000
v 314.000000 330.000000 456.000000
v 314.000000 0.000000 456.000000
v 314.000000 0.000000 456.000000
v 314.000000 330.000000 456.000000
v 265.000000 330.000000 296.000000
v 265.000000 0.000000 296.000000
v 265.000000 0.000000 296.000000
v 265.000000 330.000000 296.000000
v 423.000000 330.000000 247.000000
v 423.000000 0.000000 247.000000
v 472.000000 0.000000 406.000000
v 314.000000 0.000000 456.000000
v 265.000000 0.000000 296.000000
v 423.000000 0.000000 247.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.955649 0.000000 -0.294508
vn 0.955649 0.000000 -0.294508
vn 0.955649 0.000000 -0.294508
vn 0.955649 0.000000 -0.294508
vn 0.955649 0.000000 -0.294508
vn 0.955649 0.000000 -0.294508
vn 0.301709 0.000000 0.953400
vn 0.301709 0.000000 0.953400
vn 0.301709 0.000000 0.953400
vn 0.301709 0.000000 0.953400
vn 0.301709 0.000000 0.953400
vn 0.301709 0.000000 0.953400
vn -0.956166 0.000000 0.292826
vn -0.956166 0.000000 0.292826
vn -0.956166 0.000000 0.292826
vn -0.956166 0.000000 0.292826
vn -0.956166 0.000000 0.292826
vn -0.956166 0.000000 0.292826
vn -0.296209 0.000000 -0.955123
vn -0.296209 0.000000 -0.955123
vn -0.296209 0.000000 -0.955123
vn -0.296209 0.000000 -0.955123
vn -0.296209 0.000000 -0.955123
vn -0.296209 0.000000 -0.955123
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
usemtl grayWallSG
f 25//17 26//18 27//19
f 25//20 27//21 28//22
f 29//23 30//24 31//25
f 29//26 31//27 32//28
f 33//29 34//30 35//31
f 33//32 35//33 36//34
f 37//35 38//36 39//37
f 37//38 39//39 40//40
f 41//41 42//42 43//43
f 41//44 43//45 44//46
f 45//47 46//48 47//49
f 45//50 47//51 48//52
v 552.799988 0.000000 0.000000
v 549.599976 0.000000 559.200012
v 556.000000 548.799988 559.200012
v 556.000000 548.799988 0.000000
vn -0.999967 0.005831 -0.005722
vn -0.999958 0.008781 -0.002827
vn -0.999958 0.008711 -0.002895
vn -0.999932 0.011661 0.000000
usemtl redWallSG
f 49//53 50//54 52//55
f 52//55 50//54 51//56
v 130.000000 165.000000 65.000000
v 82.000000 165.000000 225.000000
v 240.000000 165.000000 272.000000
v 290.000000 165.000000 114.000000
v 290.000000 0.000000 114.000000
v 290.000000 165.000000 114.000000
v 240.000000 165.000000 272.000000
v 240.000000 0.000000 272.000000
v 130.000000 0.000000 65.000000
v 130.000000 165.000000 65.000000
v 290.000000 165.000000 114.000000
v 290.000000 0.000000 114.000000
v 82.000000 0.000000 225.000000
v 82.000000 165.000000 225.000000
v 130.000000 165.000000 65.000000
v 130.000000 0.000000 65.000000
v 240.000000 0.000000 272.000000
v 240.000000 165.000000 272.000000
v 82.000000 165.000000 225.000000
v 82.000000 0.000000 225.000000
v 290.000000 0.000000 114.000000
v 240.000000 0.000000 272.000000
v 82.000000 0.000000 225.000000
v 130.000000 0.000000 65.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.953400 0.000000 0.301709
vn 0.953400 0.000000 0.301709
vn 0.953400 0.000000 0.301709
vn 0.953400 0.000000 0.301709
vn 0.953400 0.000000 0.301709
vn 0.953400 0.000000 0.301709
vn 0.292826 0.000000 -0.956166
vn 0.292826 0.000000 -0.956166
vn 0.292826 0.000000 -0.956166
vn 0.292826 0.000000 -0.956166
vn 0.292826 0.000000 -0.956166
vn 0.292826 0.000000 -0.956166
vn -0.957826 0.000000 -0.287348
vn -0.957826 0.000000 -0.287348
vn -0.957826 0.000000 -0.287348
vn -0.957826 0.000000 -0.287348
vn -0.957826 0.000000 -0.287348
vn -0.957826 0.000000 -0.287348
vn -0.285121 0.000000 0.958492
vn -0.285121 0.000000 0.958492
vn -0.285121 0.000000 0.958492
vn -0.285121 0.000000 0.958492
vn -0.285121 0.000000 0.958492
vn -0.285121 0.000000 0.958492
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
usemtl grayWallSG
f 53//57 54//58 55//59
f 53//60 55//61 56//62
f 57//63 58//64 59//65
f 57//66 59//67 60//68
f 61//69 62//70 63//71
f 61//72 63//73 64//74
f 65//75 66//76 67//77
f 65//78 67//79 68//80
f 69//81 70//82 71//83
f 69//84 71//85 72//86
f 73//87 74//88 75//89
f 73//90 75//91 76//92
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions data/scene.json → data/gopher/scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
"name": "image",
"parameters": [
{"name": "width", "value": "640"},
{"name": "height", "value": "360"}
{"name": "width", "value": "1280"},
{"name": "height", "value": "720"}
]
},
{
"name": "integrator",
"parameters": [
{"name": "type", "value": "path"},
{"name": "max-bounces", "value": "16"},
{"name": "num-samples", "value": "32"}
{"name": "num-samples", "value": "128"}
]
},
{
Expand All @@ -22,6 +22,7 @@
{"name": "target", "value": "(0.0, 2.0, 0.0)"},
{"name": "up", "value": "(0.0, 1.0, 0.0)"},
{"name": "fov", "value": "45.0"},
{"name": "focus-distance", "value": "1.0"},
{"name": "near-clip", "value": "0.1"},
{"name": "far-clip", "value": "1000.0"}
]
Expand All @@ -42,6 +43,7 @@
{
"name": "light",
"parameters": [
{"name": "radiance", "value": "(4.0, 4.0, 4.0)"},
{"name": "obj", "value": "sphere.obj"}
]
}
Expand Down
File renamed without changes.
Binary file added results/cbox.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/accelerator/bvh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestPartition(t *testing.T) {
}

func TestBvhIntersection(t *testing.T) {
triMesh := NewTriMeshFromFile("../../data/gopher.obj")
triMesh := NewTriMeshFromFile("../../data/gopher/gopher.obj")
bvh := NewBvh(triMesh.Primitives)

numTrials := 1000
Expand Down
Loading

0 comments on commit cd4fcbe

Please sign in to comment.