@@ -66,10 +66,11 @@ pub fn setup_raytraced_shadows_scene(
66
66
mut commands : Commands ) -> Result < ( ) , hotline_rs:: Error > {
67
67
68
68
let cube_mesh = hotline_rs:: primitives:: create_cube_mesh ( & mut device. 0 ) ;
69
- let tourus_mesh = hotline_rs:: primitives:: create_tourus_mesh ( & mut device. 0 , 32 ) ;
69
+
70
+ let dodeca_mesh = hotline_rs:: primitives:: create_dodecahedron_mesh ( & mut device. 0 ) ;
70
71
let teapot_mesh = hotline_rs:: primitives:: create_teapot_mesh ( & mut device. 0 , 32 ) ;
71
- let tube_mesh = hotline_rs:: primitives:: create_tube_prism_mesh ( & mut device. 0 , 32 , 0 , 32 , true , true , 1.0 , 0.66 , 1.0 ) ;
72
- let triangle_mesh = hotline_rs:: primitives:: create_tube_prism_mesh ( & mut device. 0 , 3 , 0 , 3 , false , true , 0.33 , 0.66 , 1.0 ) ;
72
+ let tube_mesh = hotline_rs:: primitives:: create_tube_prism_mesh ( & mut device. 0 , 5 , 0 , 4 , false , true , 0.33 , 0.33 , 1.0 ) ;
73
+ let triangle_mesh = hotline_rs:: primitives:: create_pyramid_mesh ( & mut device. 0 , 4 , false , true ) ;
73
74
74
75
let bounds = 100.0 ;
75
76
@@ -80,7 +81,7 @@ pub fn setup_raytraced_shadows_scene(
80
81
commands. spawn ( (
81
82
Position ( light_pos) ,
82
83
Velocity ( Vec3f :: unit_z ( ) ) ,
83
- Colour ( vec4f ( 0.125 , 0.5 , 0.25 , 1.0 ) ) ,
84
+ Colour ( vec4f ( 0.5 , 0.125 , 0.25 , 1.0 ) ) ,
84
85
LightComponent {
85
86
light_type : LightType :: Point ,
86
87
radius : light_radius,
@@ -100,22 +101,22 @@ pub fn setup_raytraced_shadows_scene(
100
101
} ) ;
101
102
102
103
let shape_bounds = bounds * 0.6 ;
104
+ let shape_size = bounds * 0.1 ;
103
105
104
- // tourus
105
- let tourus_size = bounds * 0.1 ;
106
- let tourus_blas = commands. spawn ( (
106
+ // dodeca
107
+ let dodeca_blas = commands. spawn ( (
107
108
Position ( vec3f ( shape_bounds * -0.75 , shape_bounds * 0.7 , -shape_bounds * 0.1 ) ) ,
108
- Scale ( splat3f ( tourus_size ) ) ,
109
+ Scale ( splat3f ( shape_size * 2.0 ) ) ,
109
110
Rotation ( Quatf :: identity ( ) ) ,
110
- MeshComponent ( tourus_mesh . clone ( ) ) ,
111
+ MeshComponent ( dodeca_mesh . clone ( ) ) ,
111
112
WorldMatrix ( Mat34f :: identity ( ) ) ,
112
- blas_from_mesh ( & mut device, & tourus_mesh ) ?
113
+ blas_from_mesh ( & mut device, & dodeca_mesh ) ?
113
114
) ) . id ( ) ;
114
115
115
116
// helix
116
117
commands. spawn ( (
117
118
Position ( vec3f ( shape_bounds * -0.3 , shape_bounds * -0.6 , shape_bounds * 0.8 ) ) ,
118
- Scale ( splat3f ( tourus_size * 2.0 ) ) ,
119
+ Scale ( splat3f ( shape_size * 2.0 ) ) ,
119
120
Rotation ( Quatf :: identity ( ) ) ,
120
121
MeshComponent ( teapot_mesh. clone ( ) ) ,
121
122
WorldMatrix ( Mat34f :: identity ( ) ) ,
@@ -125,7 +126,7 @@ pub fn setup_raytraced_shadows_scene(
125
126
// tube
126
127
commands. spawn ( (
127
128
Position ( vec3f ( shape_bounds * 1.0 , shape_bounds * 0.1 , shape_bounds * -1.0 ) ) ,
128
- Scale ( splat3f ( tourus_size ) ) ,
129
+ Scale ( splat3f ( shape_size ) ) ,
129
130
Rotation ( Quatf :: identity ( ) ) ,
130
131
MeshComponent ( tube_mesh. clone ( ) ) ,
131
132
WorldMatrix ( Mat34f :: identity ( ) ) ,
@@ -135,7 +136,7 @@ pub fn setup_raytraced_shadows_scene(
135
136
// tri prsim
136
137
commands. spawn ( (
137
138
Position ( vec3f ( shape_bounds * 0.123 , shape_bounds * -0.6 , shape_bounds * -0.8 ) ) ,
138
- Scale ( splat3f ( tourus_size * 2.0 ) ) ,
139
+ Scale ( splat3f ( shape_size * 2.0 ) ) ,
139
140
Rotation ( Quatf :: identity ( ) ) ,
140
141
MeshComponent ( triangle_mesh. clone ( ) ) ,
141
142
WorldMatrix ( Mat34f :: identity ( ) ) ,
@@ -146,9 +147,11 @@ pub fn setup_raytraced_shadows_scene(
146
147
let thickness = bounds * 0.1 ;
147
148
let face_size = bounds * 2.0 ;
148
149
150
+ let wall_offset = ( bounds * 2.0 ) - thickness;
151
+
149
152
// -y
150
153
commands. spawn ( (
151
- Position ( vec3f ( 0.0 , -bounds , 0.0 ) ) ,
154
+ Position ( vec3f ( 0.0 , -wall_offset , 0.0 ) ) ,
152
155
Scale ( vec3f ( face_size, thickness, face_size) ) ,
153
156
Rotation ( Quatf :: identity ( ) ) ,
154
157
MeshComponent ( cube_mesh. clone ( ) ) ,
@@ -159,7 +162,7 @@ pub fn setup_raytraced_shadows_scene(
159
162
160
163
// + y
161
164
commands. spawn ( (
162
- Position ( vec3f ( 0.0 , bounds , 0.0 ) ) ,
165
+ Position ( vec3f ( 0.0 , wall_offset , 0.0 ) ) ,
163
166
Scale ( vec3f ( face_size, thickness, face_size) ) ,
164
167
Rotation ( Quatf :: identity ( ) ) ,
165
168
MeshComponent ( cube_mesh. clone ( ) ) ,
@@ -170,7 +173,7 @@ pub fn setup_raytraced_shadows_scene(
170
173
171
174
// -z
172
175
commands. spawn ( (
173
- Position ( vec3f ( 0.0 , 0.0 , -bounds ) ) ,
176
+ Position ( vec3f ( 0.0 , 0.0 , -wall_offset ) ) ,
174
177
Scale ( vec3f ( face_size, face_size, thickness) ) ,
175
178
Rotation ( Quatf :: identity ( ) ) ,
176
179
MeshComponent ( cube_mesh. clone ( ) ) ,
@@ -181,7 +184,7 @@ pub fn setup_raytraced_shadows_scene(
181
184
182
185
// -x
183
186
commands. spawn ( (
184
- Position ( vec3f ( -bounds , 0.0 , 0.0 ) ) ,
187
+ Position ( vec3f ( -wall_offset , 0.0 , 0.0 ) ) ,
185
188
Scale ( vec3f ( thickness, face_size, face_size) ) ,
186
189
Rotation ( Quatf :: identity ( ) ) ,
187
190
MeshComponent ( cube_mesh. clone ( ) ) ,
@@ -215,9 +218,10 @@ pub fn setup_tlas(
215
218
let translate = Mat34f :: from_translation ( position. 0 ) ;
216
219
let rotate = Mat34f :: from ( rotation. 0 ) ;
217
220
let scale = Mat34f :: from_scale ( scale. 0 ) ;
221
+ let flip = Mat34f :: from_scale ( vec3f ( 1.0 , 1.0 , 1.0 ) ) ;
218
222
instances. push (
219
223
gfx:: RaytracingInstanceInfo :: < gfx_platform:: Device > {
220
- transform : ( translate * rotate * scale) . m ,
224
+ transform : ( flip * translate * rotate * scale) . m ,
221
225
instance_id : index as u32 ,
222
226
instance_mask : 0xff ,
223
227
hit_group_index : 0 ,
@@ -236,7 +240,6 @@ pub fn setup_tlas(
236
240
) ?;
237
241
let tlas_srv = tlas. get_srv_index ( ) . expect ( "expect tlas to have an srv" ) ;
238
242
pmfx. push_constant_user_data [ 0 ] = tlas_srv as u32 ;
239
- println ! ( "tlas_srv = {tlas_srv}" ) ;
240
243
t. tlas = Some ( tlas) ;
241
244
}
242
245
}
@@ -276,9 +279,10 @@ pub fn update_tlas(
276
279
let translate = Mat34f :: from_translation ( position. 0 ) ;
277
280
let rotate = Mat34f :: from ( rotation. 0 ) ;
278
281
let scale = Mat34f :: from_scale ( scale. 0 ) ;
282
+ let flip = Mat34f :: from_scale ( vec3f ( 1.0 , 1.0 , 1.0 ) ) ;
279
283
instances. push (
280
284
gfx:: RaytracingInstanceInfo :: < gfx_platform:: Device > {
281
- transform : ( translate * rotate * scale) . m ,
285
+ transform : ( flip * translate * rotate * scale) . m ,
282
286
instance_id : index as u32 ,
283
287
instance_mask : 0xff ,
284
288
hit_group_index : 0 ,
@@ -298,11 +302,7 @@ pub fn update_tlas(
298
302
Ok ( ( ) )
299
303
}
300
304
301
- // TODO_RT
302
- // mesh vertex count
303
- // crash when switching demo
304
-
305
- // TODO clean
305
+ // TODO cleanup
306
306
// fix: Ignoring InitialState D3D12_RESOURCE_STATE_COPY_DEST. Buffers are effectively created in state D3D12_RESOURCE_STATE_COMMON.
307
307
308
308
#[ export_compute_fn]
0 commit comments