History

Polish the debugging of the light volumes

samcake committed 10 years ago

Commit 6aa39ec1 parent a378a6e3 files · +46 −17Browse files

Showing the changes to libraries/render-utils/src/LightClusters.cpp (1 of 3 files). Show all

Unified · Split

libraries/render-utils/src/LightClusters.cpp+26−16
@@ -429,7 +429,6 @@ void LightClusters::updateClusters() { · 428 unmodified lines
429 }429 }
430 }430 }
431 431
432 // _clusterGrid[i] = (uint32_t)((numLights << 16) | offset);
433 _clusterGrid[i] = (uint32_t)((0xFF000000 & (numLightsSpot << 24)) | (0x00FF0000 & (numLightsPoint << 16)) | (0x0000FFFF & offset));432 _clusterGrid[i] = (uint32_t)((0xFF000000 & (numLightsSpot << 24)) | (0x00FF0000 & (numLightsPoint << 16)) | (0x0000FFFF & offset));
434 433
435 434
@@ -595,16 +594,23 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() { · 159 unmodified lines
595 594
596 595
597void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs) {596void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs) {
597 if (!(doDrawClusterFromDepth || doDrawContent || doDrawGrid)) {
598 return;
599 }
600
598 auto deferredTransform = inputs.get0();601 auto deferredTransform = inputs.get0();
599 auto deferredFramebuffer = inputs.get1();602 auto deferredFramebuffer = inputs.get1();
600 auto lightingModel = inputs.get2();603 auto lightingModel = inputs.get2();
601 auto linearDepthTarget = inputs.get3();604 auto linearDepthTarget = inputs.get3();
602 auto lightClusters = inputs.get4();605 auto lightClusters = inputs.get4();
603 606
604 auto args = renderContext->args;607 auto args = renderContext->args;
605 608
606 gpu::Batch batch;609 gpu::Batch batch;
607 610
611 batch.enableStereo(false);
612
613
608 // Assign the camera transform614 // Assign the camera transform
609 batch.setViewportTransform(args->_viewport);615 batch.setViewportTransform(args->_viewport);
610 glm::mat4 projMat;616 glm::mat4 projMat;
@@ -661,26 +667,30 @@ void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, co · 50 unmodified lines
661 batch.setResourceTexture(DEFERRED_BUFFER_LINEAR_DEPTH_UNIT, nullptr);667 batch.setResourceTexture(DEFERRED_BUFFER_LINEAR_DEPTH_UNIT, nullptr);
662 batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr);668 batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr);
663 }669 }
664 670
671
672
673 gpu::Batch drawGridAndCleanBatch;
674
665 if (doDrawGrid) {675 if (doDrawGrid) {
666 // bind the one gpu::Pipeline we need676 // bind the one gpu::Pipeline we need
667 batch.setPipeline(getDrawClusterGridPipeline());677 drawGridAndCleanBatch.setPipeline(getDrawClusterGridPipeline());
668 678
669 auto dims = lightClusters->_frustumGridBuffer->dims;679 auto dims = lightClusters->_frustumGridBuffer->dims;
670 glm::ivec3 summedDims(dims.x*dims.y * dims.z, dims.x*dims.y, dims.x);680 glm::ivec3 summedDims(dims.x*dims.y * dims.z, dims.x*dims.y, dims.x);
671 batch.drawInstanced(summedDims.x, gpu::LINES, 24, 0);681 drawGridAndCleanBatch.drawInstanced(summedDims.x, gpu::LINES, 24, 0);
672 }682 }
673 683
674 batch.setUniformBuffer(LIGHT_GPU_SLOT, nullptr);684 drawGridAndCleanBatch.setUniformBuffer(LIGHT_GPU_SLOT, nullptr);
675 batch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr);685 drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr);
676 batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr);686 drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr);
677 batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr);687 drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr);
678 688
679 batch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);689 drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);
680 batch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);690 drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);
681 batch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr);691 drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr);
682 batch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr);692 drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr);
683 693
684 args->_context->appendFrameBatch(batch);694 args->_context->appendFrameBatch(batch);
685 695 args->_context->appendFrameBatch(drawGridAndCleanBatch);
686}696}