From e94f584b7e21ab28aaadf275db0fcec779d15d5c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 2 Oct 2023 12:32:51 +0100 Subject: [PATCH] Added debug info --- src/vsg/state/ViewDependentState.cpp | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/vsg/state/ViewDependentState.cpp b/src/vsg/state/ViewDependentState.cpp index c8b0bb693..e64474b72 100644 --- a/src/vsg/state/ViewDependentState.cpp +++ b/src/vsg/state/ViewDependentState.cpp @@ -471,7 +471,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const return bounds; }; - // info("\n\nViewDependentState::traverse(", &rt, ", ", &view, ") numShadowMaps = ", numShadowMaps); + //info("nViewDependentState::traverse(", &rt, ", ", &view, ") numShadowMaps = ", numShadowMaps); // set up the light data auto light_itr = lightData->begin(); @@ -518,7 +518,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const // light direction in world coords auto light_direction = normalize(light->direction * (inverse_3x3(mv * inverse_viewMatrix))); -#if 0 +#if 1 info(" directional light : light direction in world = ", light_direction, ", light->shadowMaps = ", light->shadowMaps); info(" light->direction in model = ", light->direction); info(" view_direction in world = ", view_direction); @@ -555,10 +555,6 @@ void ViewDependentState::traverse(RecordTraversal& rt) const auto lookAt = camera->viewMatrix.cast(); auto ortho = camera->projectionMatrix.cast(); -#if 0 - info(" lookAt = ", lookAt); - info(" ortho = ", ortho); -#endif auto ws_bounds = computeFrustumBounds(clip_near_z, clip_far_z, clipToWorld); auto center = (ws_bounds.min + ws_bounds.max) * 0.5; @@ -591,12 +587,28 @@ void ViewDependentState::traverse(RecordTraversal& rt) const ortho->nearDistance = ls_bounds.min.z; ortho->farDistance = ls_bounds.max.z; } +#if 0 + ortho->left = -1; + ortho->right = 1; + ortho->nearDistance = -30.0; + ortho->farDistance = 10.0; +#endif +#if 1 + info("updateCamera( clip_near_z = ", clip_near_z, ", clip_far_z = ", clip_far_z); + info(" ws_bounds = ", ws_bounds); + info(" ls_bounds = ", ls_bounds); + info(" lookAt : eye [", lookAt->eye, "], center [", lookAt->center,"], up [", lookAt->up,"]"); + info(" ortho : left = ", ortho->left, ", left = ", ortho->right, ", bottom = ", ortho->left, ", top = ", ortho->top, ", near = ", ortho->nearDistance, ", far = ", ortho->farDistance); +#endif + dmat4 shadowMapProjView = camera->projectionMatrix->transform() * camera->viewMatrix->transform(); dmat4 shadowMapTM = scale(0.5, 0.5, 1.0) * translate(1.0, 1.0, shadowMapBias) * shadowMapProjView * inverse_viewMatrix; // convert tex gen matrix to float matrix and assign to light data + + mat4 m(shadowMapTM); (*light_itr++) = m[0]; @@ -610,13 +622,13 @@ void ViewDependentState::traverse(RecordTraversal& rt) const shadowMapIndex++; }; -#if 0 +#if 1 info(" light_x = ", light_x); info(" light_y = ", light_y); info(" light_z = ", light_z); #endif -#if 0 +#if 1 double range = f - n; info(" n = ", n, ", f = ", f, ", range = ", range); #endif @@ -668,7 +680,7 @@ void ViewDependentState::traverse(RecordTraversal& rt) const if (requiresPerRenderShadowMaps && preRenderCommandGraph) { - // info("ViewDependentState::traverse(RecordTraversal&) doing pre render command graph. shadowMapIndex = ", shadowMapIndex); + info("ViewDependentState::traverse(RecordTraversal&) doing pre render command graph. shadowMapIndex = ", shadowMapIndex); preRenderCommandGraph->accept(rt); } }