Skip to content

Commit e48edf0

Browse files
committed
add test resources
1 parent 05eb55e commit e48edf0

File tree

8 files changed

+581739
-0
lines changed

8 files changed

+581739
-0
lines changed

resources/CornellBox_License.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Cornell Box
2+
https://casual-effects.com/data/
3+
License: CC BY 3.0
4+
© 2009 Morgan McGuire

resources/Sponza_License.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Crytek Sponza
2+
https://casual-effects.com/data/
3+
License: CC BY 3.0
4+
© 2010 Frank Meinl, Crytek

resources/cornell_box.mtl

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Blender MTL File: 'None'
2+
# Material Count: 8
3+
4+
newmtl backWall
5+
Ns 7.843137
6+
Ka 0.000000 0.000000 0.000000
7+
Kd 0.580000 0.568000 0.544000
8+
Ks 0.000000 0.000000 0.000000
9+
Ni 1.000000
10+
d 1.000000
11+
illum 2
12+
13+
newmtl ceiling
14+
Ns 7.843137
15+
Ka 0.000000 0.000000 0.000000
16+
Kd 0.580000 0.568000 0.544000
17+
Ks 0.000000 0.000000 0.000000
18+
Ni 1.000000
19+
d 1.000000
20+
illum 2
21+
22+
newmtl floor
23+
Ns 7.843137
24+
Ka 0.000000 0.000000 0.000000
25+
Kd 0.580000 0.568000 0.544000
26+
Ks 0.000000 0.000000 0.000000
27+
Ni 1.000000
28+
d 1.000000
29+
illum 2
30+
31+
newmtl leftWall
32+
Ns 7.843137
33+
Ka 0.000000 0.000000 0.000000
34+
Kd 0.504000 0.052000 0.040000
35+
Ks 0.000000 0.000000 0.000000
36+
Ni 1.000000
37+
d 1.000000
38+
illum 2
39+
40+
newmtl light
41+
Ns 7.843137
42+
Ka 0.000000 0.000000 0.000000
43+
Kd 0.624000 0.624000 0.624000
44+
Ks 0.000000 0.000000 0.000000
45+
Ke 36 33 24
46+
Ni 1.000000
47+
d 1.000000
48+
illum 2
49+
50+
newmtl rightWall
51+
Ns 7.843137
52+
Ka 0.000000 0.000000 0.000000
53+
Kd 0.112000 0.360000 0.072800
54+
Ks 0.000000 0.000000 0.000000
55+
Ni 1.000000
56+
d 1.000000
57+
illum 2
58+
59+
newmtl shortBox
60+
Ns 7.843137
61+
Ka 0.000000 0.000000 0.000000
62+
Kd 0.580000 0.568000 0.544000
63+
Ks 0.000000 0.000000 0.000000
64+
Ni 1.000000
65+
d 1.000000
66+
illum 2
67+
68+
newmtl tallBox
69+
Ns 7.843137
70+
Ka 0.000000 0.000000 0.000000
71+
Kd 0.580000 0.568000 0.544000
72+
Ks 0.000000 0.000000 0.000000
73+
Ni 1.000000
74+
d 1.000000
75+
illum 2

resources/cornell_box.obj

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Blender v2.69 (sub 0) OBJ File: ''
2+
# www.blender.org
3+
mtllib cornellbox.mtl
4+
5+
o light
6+
v -0.240000 1.980000 0.160000
7+
v -0.240000 1.980000 -0.220000
8+
v 0.230000 1.980000 -0.220000
9+
v 0.230000 1.980000 0.160000
10+
vn 0.000000 -1.000000 0.000000
11+
usemtl light
12+
s off
13+
f 1//1 2//1 3//1 4//1
14+
15+
o shortBox
16+
v -1.010000 -0.000000 0.990000
17+
v -0.990000 0.000000 -1.040000
18+
v -1.020000 1.990000 -1.040000
19+
v -1.020000 1.990000 0.990000
20+
v 0.530000 0.600000 0.750000
21+
v 0.700000 0.600000 0.170000
22+
v 0.130000 0.600000 0.000000
23+
v -0.050000 0.600000 0.570000
24+
v -0.050000 -0.000000 0.570000
25+
v -0.050000 0.600000 0.570000
26+
v 0.130000 0.600000 0.000000
27+
v 0.130000 0.000000 0.000000
28+
v 0.530000 -0.000000 0.750000
29+
v 0.530000 0.600000 0.750000
30+
v -0.050000 0.600000 0.570000
31+
v -0.050000 -0.000000 0.570000
32+
v 0.700000 -0.000000 0.170000
33+
v 0.700000 0.600000 0.170000
34+
v 0.530000 0.600000 0.750000
35+
v 0.530000 -0.000000 0.750000
36+
v 0.130000 0.000000 0.000000
37+
v 0.130000 0.600000 0.000000
38+
v 0.700000 0.600000 0.170000
39+
v 0.700000 -0.000000 0.170000
40+
vn -0.000000 1.000000 0.000000
41+
vn -0.953583 0.000000 -0.301131
42+
vn -0.296399 -0.000000 0.955064
43+
vn 0.285805 0.000000 -0.958288
44+
vn 0.959629 -0.000000 0.281270
45+
vn 0.999937 0.010050 0.004926
46+
47+
usemtl shortBox
48+
s off
49+
f 9//2 10//2 11//2 12//2
50+
f 13//3 14//3 15//3 16//3
51+
f 17//4 18//4 19//4 20//4
52+
f 25//5 26//5 27//5 28//5
53+
f 21//6 22//6 23//6 24//6
54+
55+
o leftWall
56+
usemtl leftWall
57+
f 5//7 6//7 7//7 8//7
58+
59+
o backWall
60+
v -0.990000 0.000000 -1.040000
61+
v 1.000000 0.000000 -1.040000
62+
v 1.000000 1.990000 -1.040000
63+
v -1.020000 1.990000 -1.040000
64+
vn 0.000000 -0.000000 1.000000
65+
usemtl backWall
66+
s off
67+
f 29//8 30//8 31//8 32//8
68+
69+
o rightWall
70+
v 1.000000 0.000000 -1.040000
71+
v 1.000000 -0.000000 0.990000
72+
v 1.000000 1.990000 0.990000
73+
v 1.000000 1.990000 -1.040000
74+
vn -1.000000 0.000000 0.000000
75+
usemtl rightWall
76+
s off
77+
f 33//9 34//9 35//9 36//9
78+
79+
o ceiling
80+
v -1.020000 1.990000 0.990000
81+
v -1.020000 1.990000 -1.040000
82+
v 1.000000 1.990000 -1.040000
83+
v 1.000000 1.990000 0.990000
84+
vn 0.000000 -1.000000 -0.000000
85+
usemtl ceiling
86+
s off
87+
f 37//10 38//10 39//10 40//10
88+
89+
o tallBox
90+
v -0.530000 1.200000 0.090000
91+
v 0.040000 1.200000 -0.090000
92+
v -0.140000 1.200000 -0.670000
93+
v -0.710000 1.200000 -0.490000
94+
v -0.530000 -0.000000 0.090000
95+
v -0.530000 1.200000 0.090000
96+
v -0.710000 1.200000 -0.490000
97+
v -0.710000 0.000000 -0.490000
98+
v -0.710000 0.000000 -0.490000
99+
v -0.710000 1.200000 -0.490000
100+
v -0.140000 1.200000 -0.670000
101+
v -0.140000 0.000000 -0.670000
102+
v -0.140000 0.000000 -0.670000
103+
v -0.140000 1.200000 -0.670000
104+
v 0.040000 1.200000 -0.090000
105+
v 0.040000 0.000000 -0.090000
106+
v 0.040000 0.000000 -0.090000
107+
v 0.040000 1.200000 -0.090000
108+
v -0.530000 1.200000 0.090000
109+
v -0.530000 -0.000000 0.090000
110+
vn 0.000000 1.000000 0.000000
111+
vn -0.955064 0.000000 0.296399
112+
vn -0.301131 0.000000 -0.953583
113+
vn 0.955064 0.000000 -0.296399
114+
vn 0.301131 -0.000000 0.953583
115+
usemtl tallBox
116+
s off
117+
f 41//11 42//11 43//11 44//11
118+
f 45//12 46//12 47//12 48//12
119+
f 49//13 50//13 51//13 52//13
120+
f 53//14 54//14 55//14 56//14
121+
f 57//15 58//15 59//15 60//15
122+
123+
124+
o floor
125+
v -1.010000 -0.000000 0.990000
126+
v 1.000000 -0.000000 0.990000
127+
v 1.000000 0.000000 -1.040000
128+
v -0.990000 0.000000 -1.040000
129+
vn 0.000000 1.000000 0.000000
130+
usemtl floor
131+
s off
132+
f 61//16 62//16 63//16 64//16

resources/shaders/intersect.hlsl

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//*********************************************************
2+
//
3+
// Copyright (c) Microsoft. All rights reserved.
4+
// This code is licensed under the MIT License (MIT).
5+
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6+
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7+
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8+
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9+
//
10+
//*********************************************************
11+
12+
// clang-format off
13+
#define INVALID_ID ~0u
14+
15+
struct Ray
16+
{
17+
float3 origin;
18+
float min_t;
19+
float3 direction;
20+
float max_t;
21+
};
22+
23+
typedef BuiltInTriangleIntersectionAttributes MyAttributes;
24+
25+
struct HitData
26+
{
27+
#ifdef ASM_QUERY_OUTPUT_FULL_HIT
28+
float2 uv;
29+
uint prim_id;
30+
#endif
31+
uint inst_id;
32+
};
33+
34+
RaytracingAccelerationStructure g_scene : register(t0, space0);
35+
RWStructuredBuffer<Ray> g_rays : register(u0);
36+
RWStructuredBuffer<HitData> g_hits : register(u1);
37+
38+
[shader("raygeneration")]
39+
void FetchAndSpawn()
40+
{
41+
uint ray_index = DispatchRaysIndex().x;
42+
43+
RayDesc ray;
44+
ray.Origin = g_rays[ray_index].origin;
45+
ray.Direction = g_rays[ray_index].direction;
46+
ray.TMin = g_rays[ray_index].min_t;
47+
ray.TMax = g_rays[ray_index].max_t;
48+
49+
HitData hit;
50+
TraceRay(g_scene, 0, ~0, 0, 1, 0, ray, hit);
51+
52+
g_hits[ray_index] = hit;
53+
}
54+
55+
#ifndef ASM_QUERY_FIRST_HIT
56+
[shader("closesthit")]
57+
void Hit(inout HitData hit, in MyAttributes attr)
58+
{
59+
#ifdef ASM_QUERY_OUTPUT_FULL_HIT
60+
hit.uv = attr.barycentrics.xy;
61+
hit.inst_id = InstanceIndex();
62+
hit.prim_id = PrimitiveIndex();
63+
#else
64+
hit.inst_id = InstanceIndex();
65+
#endif
66+
}
67+
#else
68+
[shader("anyhit")]
69+
void Hit(inout HitData hit, in MyAttributes attr)
70+
{
71+
#ifdef ASM_QUERY_OUTPUT_FULL_HIT
72+
hit.uv = attr.barycentrics.xy;
73+
hit.inst_id = InstanceIndex();
74+
hit.prim_id = PrimitiveIndex();
75+
#else
76+
hit.inst_id = InstanceIndex();
77+
#endif
78+
}
79+
#endif
80+
81+
[shader("miss")]
82+
void Miss(inout HitData hit)
83+
{
84+
hit.inst_id = INVALID_ID;
85+
}
86+
87+
// clang-format on
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef INTERSECT_STRUCTURES_HLSL
2+
#define INTERSECT_STRUCTURES_HLSL
3+
4+
struct Ray
5+
{
6+
float3 origin;
7+
float min_t;
8+
float3 direction;
9+
float max_t;
10+
};
11+
12+
struct FullHitData
13+
{
14+
float2 uv;
15+
uint inst_id;
16+
uint prim_id;
17+
};
18+
19+
struct AnyHitData
20+
{
21+
uint inst_id;
22+
};
23+
24+
#endif

0 commit comments

Comments
 (0)