Showing the changes to libraries/render-utils/src/DebugDeferredBuffer.cpp (1 of 4 files). Show all
Unified · Split
| @@ -72,10 +72,15 @@ static const std::string DEFAULT_LIGHTING_SHADER { · 71 unmodified lines | ||
| 72 | 72 | " }" |
| 73 | 73 | }; |
| 74 | 74 | static const std::string DEFAULT_SHADOW_SHADER { |
| 75 | − "uniform sampler2D shadowMapColor;" | |
| 76 | − // The actual shadowMap is a sampler2DShadow, so we cannot normally sample it | |
| 75 | + "uniform sampler2DShadow shadowMap;" | |
| 77 | 76 | "vec4 getFragmentColor() {" |
| 78 | − " return vec4(texture(shadowMapColor, uv).xyz, 1.0);" | |
| 77 | + " for (int i = 255; i >= 0; --i) {" | |
| 78 | + " float depth = i / 255.0;" | |
| 79 | + " if (texture(shadowMap, vec3(uv, depth)) > 0.5) {" | |
| 80 | + " return vec4(vec3(depth), 1.0);" | |
| 81 | + " }" | |
| 82 | + " }" | |
| 83 | + " return vec4(vec3(0.0), 1.0);" | |
| 79 | 84 | " }" |
| 80 | 85 | }; |
| 81 | 86 | static const std::string DEFAULT_CUSTOM_SHADER { |
| @@ -169,7 +174,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 87 unmodified lines | ||
| 169 | 174 | slotBindings.insert(gpu::Shader::Binding("specularMap", Specular)); |
| 170 | 175 | slotBindings.insert(gpu::Shader::Binding("depthMap", Depth)); |
| 171 | 176 | slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting)); |
| 172 | − slotBindings.insert(gpu::Shader::Binding("shadowMapColor", Shadow)); | |
| 177 | + slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow)); | |
| 173 | 178 | gpu::Shader::makeProgram(*program, slotBindings); |
| 174 | 179 | |
| 175 | 180 | auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>()); |
| @@ -225,7 +230,7 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 49 unmodified lines | ||
| 225 | 230 | batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture()); |
| 226 | 231 | batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture()); |
| 227 | 232 | batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture()); |
| 228 | − batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getRenderBuffer(0)); | |
| 233 | + batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getDepthStencilBuffer()); | |
| 229 | 234 | |
| 230 | 235 | const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f); |
| 231 | 236 | const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y); |