History

Fixed android compilation error and removed _glUniformi call

Olivier Prat committed 8 years ago

Commit 51fe60e1 parent 1a5c3825 files · +57 −21Browse files

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

Unified · Split

libraries/render-utils/src/DebugDeferredBuffer.cpp+11−11
@@ -60,7 +60,8 @@ enum TextureSlot { · 59 unmodified lines
6060 enum ParamSlot {
6161 CameraCorrection = 0,
6262 DeferredFrameTransform,
63− ShadowTransform
63+ ShadowTransform,
64+ DebugParametersBuffer
6465 };
6566
6667 static const std::string DEFAULT_ALBEDO_SHADER {
@@ -139,13 +140,11 @@ static const std::string DEFAULT_LIGHTING_SHADER { · 72 unmodified lines
139140 " }"
140141 };
141142
142−static const std::string DEFAULT_SHADOW_SHADER{
143− "uniform sampler2DArrayShadow shadowMaps;"
144− "uniform int shadowCascadeIndex;"
143+static const std::string DEFAULT_SHADOW_DEPTH_SHADER{
145144 "vec4 getFragmentColor() {"
146145 " for (int i = 255; i >= 0; --i) {"
147146 " float depth = i / 255.0;"
148− " if (texture(shadowMaps, vec4(uv, shadowCascadeIndex, depth)) > 0.5) {"
147+ " if (texture(shadowMaps, vec4(uv, parameters._shadowCascadeIndex, depth)) > 0.5) {"
149148 " return vec4(vec3(depth), 1.0);"
150149 " }"
151150 " }"
@@ -324,7 +323,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust · 172 unmodified lines
324323 case ShadowCascade1Mode:
325324 case ShadowCascade2Mode:
326325 case ShadowCascade3Mode:
327− return DEFAULT_SHADOW_SHADER;
326+ return DEFAULT_SHADOW_DEPTH_SHADER;
328327 case ShadowCascadeIndicesMode:
329328 return DEFAULT_SHADOW_CASCADE_SHADER;
330329 case LinearDepthMode:
@@ -397,6 +396,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str · 66 unmodified lines
397396 slotBindings.insert(gpu::Shader::Binding("cameraCorrectionBuffer", CameraCorrection));
398397 slotBindings.insert(gpu::Shader::Binding("deferredFrameTransformBuffer", DeferredFrameTransform));
399398 slotBindings.insert(gpu::Shader::Binding("shadowTransformBuffer", ShadowTransform));
399+ slotBindings.insert(gpu::Shader::Binding("parametersBuffer", DebugParametersBuffer));
400400
401401 slotBindings.insert(gpu::Shader::Binding("albedoMap", Albedo));
402402 slotBindings.insert(gpu::Shader::Binding("normalMap", Normal));
@@ -433,8 +433,11 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str · 30 unmodified lines
433433 }
434434
435435 void DebugDeferredBuffer::configure(const Config& config) {
436+ auto& parameters = _parameters.edit();
437+
436438 _mode = (Mode)config.mode;
437439 _size = config.size;
440+ parameters._shadowCascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)SHADOW_CASCADE_MAX_COUNT - 1);
438441 }
439442
440443 void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const Inputs& inputs) {
@@ -484,18 +487,15 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I · 43 unmodified lines
484487 batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture());
485488 }
486489
490+ batch.setUniformBuffer(DebugParametersBuffer, _parameters);
491+
487492 auto lightStage = renderContext->_scene->getStage<LightStage>();
488493 assert(lightStage);
489494 assert(lightStage->getNumLights() > 0);
490495 auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow();
491496 const auto& globalShadow = lightAndShadow.second;
492497 if (globalShadow) {
493− const auto cascadeIndex = glm::clamp(_mode - Mode::ShadowCascade0Mode, 0, (int)globalShadow->getCascadeCount() - 1);
494− const auto cascadeIndexLocation = pipeline->getProgram()->getUniforms().findLocation("shadowCascadeIndex");
495498 batch.setResourceTexture(Shadow, globalShadow->map);
496− if (cascadeIndexLocation >= 0) {
497− batch._glUniform1i(cascadeIndexLocation, cascadeIndex);
498− }
499499 batch.setUniformBuffer(ShadowTransform, globalShadow->getBuffer());
500500 batch.setUniformBuffer(DeferredFrameTransform, frameTransform->getFrameTransformBuffer());
501501 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t