Showing the changes to libraries/render-utils/src/LightClusters.cpp (1 of 3 files). Show all
Unified · Split
| @@ -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 | 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 | |
| 597 | 596 | void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Inputs& inputs) { |
| 597 | + if (!(doDrawClusterFromDepth || doDrawContent || doDrawGrid)) { | |
| 598 | + return; | |
| 599 | + } | |
| 600 | + | |
| 598 | 601 | auto deferredTransform = inputs.get0(); |
| 599 | 602 | auto deferredFramebuffer = inputs.get1(); |
| 600 | 603 | auto lightingModel = inputs.get2(); |
| 601 | 604 | auto linearDepthTarget = inputs.get3(); |
| 602 | 605 | auto lightClusters = inputs.get4(); |
| 603 | − | |
| 606 | + | |
| 604 | 607 | auto args = renderContext->args; |
| 605 | − | |
| 608 | + | |
| 606 | 609 | gpu::Batch batch; |
| 607 | 610 | |
| 611 | + batch.enableStereo(false); | |
| 612 | + | |
| 613 | + | |
| 608 | 614 | // Assign the camera transform |
| 609 | 615 | batch.setViewportTransform(args->_viewport); |
| 610 | 616 | glm::mat4 projMat; |
| @@ -661,26 +667,30 @@ void DebugLightClusters::run(const render::SceneContextPointer& sceneContext, co · 50 unmodified lines | ||
| 661 | 667 | batch.setResourceTexture(DEFERRED_BUFFER_LINEAR_DEPTH_UNIT, nullptr); |
| 662 | 668 | batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr); |
| 663 | 669 | } |
| 664 | − | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + gpu::Batch drawGridAndCleanBatch; | |
| 674 | + | |
| 665 | 675 | if (doDrawGrid) { |
| 666 | 676 | // bind the one gpu::Pipeline we need |
| 667 | − batch.setPipeline(getDrawClusterGridPipeline()); | |
| 668 | − | |
| 677 | + drawGridAndCleanBatch.setPipeline(getDrawClusterGridPipeline()); | |
| 678 | + | |
| 669 | 679 | auto dims = lightClusters->_frustumGridBuffer->dims; |
| 670 | 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); | |
| 675 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr); | |
| 676 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr); | |
| 677 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr); | |
| 684 | + drawGridAndCleanBatch.setUniformBuffer(LIGHT_GPU_SLOT, nullptr); | |
| 685 | + drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, nullptr); | |
| 686 | + drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, nullptr); | |
| 687 | + drawGridAndCleanBatch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, nullptr); | |
| 678 | 688 | |
| 679 | − batch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr); | |
| 680 | − batch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr); | |
| 681 | − batch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr); | |
| 682 | − batch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr); | |
| 689 | + drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr); | |
| 690 | + drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr); | |
| 691 | + drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_EMISSIVE_UNIT, nullptr); | |
| 692 | + drawGridAndCleanBatch.setResourceTexture(DEFERRED_BUFFER_DEPTH_UNIT, nullptr); | |
| 683 | 693 | |
| 684 | 694 | args->_context->appendFrameBatch(batch); |
| 685 | − | |
| 695 | + args->_context->appendFrameBatch(drawGridAndCleanBatch); | |
| 686 | 696 | } |