mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 09:15:50 +02:00
Change shadow debug buffer to reuse shadowMap tex
This commit is contained in:
parent
7a5562abce
commit
398f83be3f
4 changed files with 14 additions and 13 deletions
|
@ -63,10 +63,6 @@ Framebuffer* Framebuffer::createShadowmap(uint16 width) {
|
|||
depthTexture->setSampler(Sampler(samplerDesc));
|
||||
framebuffer->setDepthStencilBuffer(depthTexture, depthFormat);
|
||||
|
||||
// Use a render buffer to allow use of the DebugDeferredBuffer Job
|
||||
gpu::TexturePointer colorbuffer{gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, width)};
|
||||
framebuffer->setRenderBuffer(0, colorbuffer);
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,10 +72,15 @@ static const std::string DEFAULT_LIGHTING_SHADER {
|
|||
" }"
|
||||
};
|
||||
static const std::string DEFAULT_SHADOW_SHADER {
|
||||
"uniform sampler2D shadowMapColor;"
|
||||
// The actual shadowMap is a sampler2DShadow, so we cannot normally sample it
|
||||
"uniform sampler2DShadow shadowMap;"
|
||||
"vec4 getFragmentColor() {"
|
||||
" return vec4(texture(shadowMapColor, uv).xyz, 1.0);"
|
||||
" for (int i = 255; i >= 0; --i) {"
|
||||
" float depth = i / 255.0;"
|
||||
" if (texture(shadowMap, vec3(uv, depth)) > 0.5) {"
|
||||
" return vec4(vec3(depth), 1.0);"
|
||||
" }"
|
||||
" }"
|
||||
" return vec4(vec3(0.0), 1.0);"
|
||||
" }"
|
||||
};
|
||||
static const std::string DEFAULT_CUSTOM_SHADER {
|
||||
|
@ -169,7 +174,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Modes mode, std::st
|
|||
slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));
|
||||
slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
|
||||
slotBindings.insert(gpu::Shader::Binding("lightingMap", Lighting));
|
||||
slotBindings.insert(gpu::Shader::Binding("shadowMapColor", Shadow));
|
||||
slotBindings.insert(gpu::Shader::Binding("shadowMap", Shadow));
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
|
||||
|
@ -225,7 +230,7 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren
|
|||
batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
|
||||
batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
|
||||
batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture());
|
||||
batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getRenderBuffer(0));
|
||||
batch.setResourceTexture(Shadow, lightStage.lights[0]->shadow.framebuffer->getDepthStencilBuffer());
|
||||
|
||||
const glm::vec4 color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
const glm::vec2 bottomLeft(renderContext->_deferredDebugSize.x, renderContext->_deferredDebugSize.y);
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
layout(location = 0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
// stencil in solid color for debugging
|
||||
_fragColor = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
// pass-through to set z-buffer
|
||||
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
layout(location = 0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
// stencil in solid color for debugging
|
||||
_fragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
// pass-through to set z-buffer
|
||||
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue