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
7272 " }"
7373 };
7474 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;"
7776 "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);"
7984 " }"
8085 };
8186 static const std::string DEFAULT_CUSTOM_SHADER {
@@ -169,7 +174,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st · 87 unmodified lines
169174 slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));
170175 slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
171176 slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting));
172− slotBindings.insert(gpu::Shader::Binding("shadowMapColor", Shadow));
177+ slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow));
173178 gpu::Shader::makeProgram(*program, slotBindings);
174179
175180 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
225230 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
226231 batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
227232 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());
229234
230235 const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
231236 const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y);