History

introducing the Velocity buffer pass generation

samcake committed 9 years ago

Commit 2f0eee51 parent fe0b59713 files · +393 −7Browse files

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

Unified · Split

libraries/render-utils/src/DebugDeferredBuffer.cpp+17−1
@@ -52,7 +52,8 @@ enum Slot { · 51 unmodified lines
5252 DiffusedCurvature,
5353 Scattering,
5454 AmbientOcclusion,
55− AmbientOcclusionBlurred
55+ AmbientOcclusionBlurred,
56+ Velocity,
5657 };
5758
5859
@@ -226,6 +227,12 @@ static const std::string DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER{ · 167 unmodified lines
226227 " }"
227228 };
228229
230+static const std::string DEFAULT_VELOCITY_SHADER{
231+ "vec4 getFragmentColor() {"
232+ " return vec4(vec2(texture(velocityMap, uv).xy), 0.0, 1.0);"
233+ " }"
234+};
235+
229236 static const std::string DEFAULT_CUSTOM_SHADER {
230237 "vec4 getFragmentColor() {"
231238 " return vec4(1.0, 0.0, 0.0, 1.0);"
@@ -308,6 +315,8 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string cust · 76 unmodified lines
308315 return DEFAULT_AMBIENT_OCCLUSION_SHADER;
309316 case AmbientOcclusionBlurredMode:
310317 return DEFAULT_AMBIENT_OCCLUSION_BLURRED_SHADER;
318+ case VelocityMode:
319+ return DEFAULT_VELOCITY_SHADER;
311320 case CustomMode:
312321 return getFileContent(customFile, DEFAULT_CUSTOM_SHADER);
313322 default:
@@ -366,6 +375,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str · 52 unmodified lines
366375 slotBindings.insert(gpu::Shader::Binding("diffusedCurvatureMap", DiffusedCurvature));
367376 slotBindings.insert(gpu::Shader::Binding("scatteringMap", Scattering));
368377 slotBindings.insert(gpu::Shader::Binding("occlusionBlurredMap", AmbientOcclusionBlurred));
378+ slotBindings.insert(gpu::Shader::Binding("velocityMap", Velocity));
369379 gpu::Shader::makeProgram(*program, slotBindings);
370380
371381 auto pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
@@ -403,6 +413,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I · 31 unmodified lines
403413 auto& linearDepthTarget = inputs.get1();
404414 auto& surfaceGeometryFramebuffer = inputs.get2();
405415 auto& ambientOcclusionFramebuffer = inputs.get3();
416+ auto& velocityFramebuffer = inputs.get4();
406417
407418 gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
408419 batch.enableStereo(false);
@@ -431,6 +442,9 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I · 22 unmodified lines
431442 batch.setResourceTexture(Depth, deferredFramebuffer->getPrimaryDepthTexture());
432443 batch.setResourceTexture(Lighting, deferredFramebuffer->getLightingTexture());
433444 }
445+ if (velocityFramebuffer) {
446+ batch.setResourceTexture(Velocity, velocityFramebuffer->getVelocityTexture());
447+ }
434448
435449 auto lightStage = renderContext->_scene->getStage<LightStage>();
436450 assert(lightStage);
@@ -476,5 +490,7 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I · 39 unmodified lines
476490 batch.setResourceTexture(AmbientOcclusion, nullptr);
477491 batch.setResourceTexture(AmbientOcclusionBlurred, nullptr);
478492
493+ batch.setResourceTexture(Velocity, nullptr);
494+
479495 });
480496 }