Skip to content

Commit dc8c343

Browse files
committed
Cleanups.
1 parent 2bb73bc commit dc8c343

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

examples_tests/60.ClusteredRendering/cull_common.glsl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ bool cullCone(in cone_t cone, in nbl_glsl_shapes_AABB_t aabb)
186186

187187
const vec3 waypoint = normalize(vertex - cone.tip);
188188

189+
// Todo(achal): nbl_glsl_slerp_impl_impl wants the length of cross of first two params to be exactly 1, hence there should be division
190+
// by sine of angle between the cone.direction and waypoint, however, it introduces a chance of divison by zero as well which messes up
191+
// things massively (as I have come to find out with a previous bug) --need to think about what to do when the sine approaches 0.
189192
const vec3 normal = nbl_glsl_slerp_impl_impl(cone.direction, normalize(waypoint), sqrt(1.f - cone.cosHalfAngle * cone.cosHalfAngle));
190193
if (dot(nbl_glsl_shapes_AABB_getFarthestPointInFront(aabb, normal) - cone.tip, normal) < 0.f)
191194
return true;
@@ -213,7 +216,6 @@ bool cullCone(in cone_t cone, in nbl_glsl_shapes_AABB_t aabb)
213216
// Todo(achal): Can make this cone_t something like light_volume_t..
214217
bool lightIntersectAABB(in cone_t cone, in nbl_glsl_shapes_AABB_t aabb)
215218
{
216-
#if 1
217219
const vec3 sphereMinPoint = cone.tip - cone.height;
218220
const vec3 sphereMaxPoint = cone.tip + cone.height;
219221

@@ -227,7 +229,6 @@ bool lightIntersectAABB(in cone_t cone, in nbl_glsl_shapes_AABB_t aabb)
227229

228230
if (cone.cosHalfAngle <= -(1.f - 1e-3f))
229231
return false;
230-
#endif
231232

232233
return !cullCone(cone, aabb);
233234
}

examples_tests/60.ClusteredRendering/main.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using namespace nbl;
1010

1111
// #define SYNC_DEBUG
12-
// #define DEBUG_VIZ
12+
#define DEBUG_VIZ
1313

1414
#define CLIPMAP
1515
// #define OCTREE
@@ -1857,7 +1857,7 @@ class ClusteredRenderingSampleApp : public ApplicationBase
18571857
if ((ev.keyCode == ui::EKC_F) && (ev.action == ui::SKeyboardEvent::ECA_RELEASED))
18581858
{
18591859
const core::vectorSIMDf aabbCenter = camera.getPosition();
1860-
const float extent = 500.f;
1860+
const float extent = 100.f;
18611861
nbl_glsl_shapes_AABB_t aabb;
18621862
aabb.minVx = { aabbCenter.x - (extent / 2.f), aabbCenter.y - (extent / 2.f), aabbCenter.z - (extent / 2.f) };
18631863
aabb.maxVx = { aabbCenter.x + (extent / 2.f), aabbCenter.y + (extent / 2.f), aabbCenter.z + (extent / 2.f) };
@@ -1872,7 +1872,7 @@ class ClusteredRenderingSampleApp : public ApplicationBase
18721872
if ((ev.keyCode == ui::EKC_G) && (ev.action == ui::SKeyboardEvent::ECA_RELEASED))
18731873
{
18741874
const core::vectorSIMDf aabbCenter = camera.getPosition();
1875-
const float extent = 500.f;
1875+
const float extent = 100.f;
18761876
nbl_glsl_shapes_AABB_t aabb;
18771877

18781878
aabb.minVx = { aabbCenter.x - (extent / 2.f), aabbCenter.y - (extent / 2.f), aabbCenter.z - (extent / 2.f) };
@@ -2889,20 +2889,15 @@ class ClusteredRenderingSampleApp : public ApplicationBase
28892889
const uint32_t y = (i >> 1) & 0x1u;
28902890
const uint32_t z = (i >> 2) & 0x1u;
28912891

2892-
printf("Vertex ID: [%d, %d, %d]\n", x, y, z);
28932892

28942893
const core::vectorSIMDf aabbVertex(
28952894
(1u - x) * aabb.minVx.x + x * aabb.maxVx.x,
28962895
(1u - y) * aabb.minVx.y + y * aabb.maxVx.y,
28972896
(1u - z) * aabb.minVx.z + z * aabb.maxVx.z);
28982897

2899-
printf("Vertex: [%f, %f, %f]\n", aabbVertex.x, aabbVertex.y, aabbVertex.z);
2900-
29012898
const core::vectorSIMDf waypoint = core::normalize(aabbVertex - cone.tip);
29022899

29032900
const core::vectorSIMDf normal = slerp_till_cosine(cone.direction, core::normalize(waypoint), core::sqrt(1.f - cone.cosHalfAngle * cone.cosHalfAngle));
2904-
printf("normal: [%f, %f, %f]\n", normal.x, normal.y, normal.z);
2905-
printf("dot(cone.direction, normal): %f\n\n", core::dot(cone.direction, normal).x);
29062901
if (core::dot(getFarthestPointInFront(aabb, normal) - cone.tip, normal).x < 0.f)
29072902
return true;
29082903
}

0 commit comments

Comments
 (0)