History

Change shadow debug buffer to reuse shadowMap tex

Zach Pomerantz committed 10 years ago

Commit 398f83b1 parent 7a5562a4 files · +14 −13Browse files

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

Unified · Split

libraries/render-utils/src/DebugDeferredBuffer.cpp+10−5
@@ -72,10 +72,15 @@ static const std::string DEFAULT_LIGHTING_SHADER { · 71 unmodified lines
72 " }"72 " }"
73};73};
74static const std::string DEFAULT_SHADOW_SHADER {74static const std::string DEFAULT_SHADOW_SHADER {
75 "uniform sampler2D shadowMapColor;"75 "uniform sampler2DShadow shadowMap;"
76 // The actual shadowMap is a sampler2DShadow, so we cannot normally sample it
77 "vec4 getFragmentColor() {"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};
81static const std::string DEFAULT_CUSTOM_SHADER {86static const std::string DEFAULT_CUSTOM_SHADER {
@@ -169,7 +174,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 87 unmodified lines
169 slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));174 slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));
170 slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));175 slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
171 slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting));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 gpu::Shader::makeProgram(*program, slotBindings);178 gpu::Shader::makeProgram(*program, slotBindings);
174 179
175 auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());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 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());230 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
226 batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());231 batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
227 batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture());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 const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);235 const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
231 const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y);236 const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y);