Skip to content

Commit

Permalink
Mark all TLAS instances opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
sergcpp committed Apr 6, 2024
1 parent d34b901 commit 1ce0d01
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion internal/SceneDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void Ray::Dx::Scene::Rebuild_HWRT_TLAS_nolock() {
new_instance.InstanceID = meshes_[instance.mesh_index].vert_index / 3;
new_instance.InstanceMask = (instance.ray_visibility & 0xff);
new_instance.InstanceContributionToHitGroupIndex = 0;
new_instance.Flags = 0;
new_instance.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE;
new_instance.AccelerationStructure = dx_blas.gpu_virtual_address();

// const mesh_t &mesh = meshes_[instance.mesh_index];
Expand Down
5 changes: 1 addition & 4 deletions internal/SceneVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,9 @@ void Ray::Vk::Scene::Rebuild_HWRT_TLAS_nolock() {
auto &new_instance = tlas_instances.back();
to_khr_xform(instance.xform, new_instance.transform.matrix);
new_instance.instanceCustomIndex = m.vert_index / 3;
// blas.geo_index;
new_instance.mask = (instance.ray_visibility & 0xff);
new_instance.instanceShaderBindingTableRecordOffset = 0;
new_instance.flags = 0;
// VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR; //
// VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR;
new_instance.flags = VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR;
new_instance.accelerationStructureReference = static_cast<uint64_t>(vk_blas.vk_device_address());

// const mesh_t &mesh = meshes_[instance.mesh_index];
Expand Down
2 changes: 1 addition & 1 deletion internal/shaders/intersect_scene.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void main() {
inter.t // tMax
);
while (rayQueryProceedEXT(rq)) {
rayQueryConfirmIntersectionEXT(rq);
// NOTE: All instances are opaque, no need to confirm intersection
}

if (rayQueryGetIntersectionTypeEXT(rq, true) != gl_RayQueryCommittedIntersectionNoneEXT) {
Expand Down
7 changes: 2 additions & 5 deletions internal/shaders/intersect_scene_shadow.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,8 @@ vec3 IntersectSceneShadow(shadow_ray_t r) {
rd, // direction
dist // tMax
);

while(rayQueryProceedEXT(rq)) {
if (rayQueryGetIntersectionTypeEXT(rq, false) == gl_RayQueryCandidateIntersectionTriangleEXT) {
rayQueryConfirmIntersectionEXT(rq);
}
while (rayQueryProceedEXT(rq)) {
// NOTE: All instances are opaque, no need to confirm intersection
}

if (rayQueryGetIntersectionTypeEXT(rq, true) != gl_RayQueryCommittedIntersectionNoneEXT) {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 1ce0d01

Please sign in to comment.