History

More work on live g-buffer debug

Atlante45 committed 10 years ago

Commit b45b1cc1 parent 5bfcd4e9 files · +103 −17Browse files

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

Unified · Split

libraries/render-utils/src/DebugDeferredBuffer.cpp+30−8
@@ -24,20 +24,38 @@ · 23 unmodified lines
24 24
25using namespace render;25using namespace render;
26 26
27const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline() {27static const std::string PLACEHOLDER { "DEBUG_PLACEHOLDER" };
28 if (!_pipeline) {28static const std::array<std::string, DebugDeferredBuffer::NUM_SLOTS> SLOT_NAMES {{
29 "diffuseMap",
30 "normalMap",
31 "specularMap",
32 "depthMap",
33 "lightingMap"
34}};
35
36std::string getCode(int slot) {
37 return std::string("return texture(").append(SLOT_NAMES[slot]).append(", uv);");
38}
39
40const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(int slot) {
41 if (!_pipelines[slot]) {
42 std::string fragmentShader = debug_deferred_buffer_frag;
43 fragmentShader.replace(fragmentShader.find(PLACEHOLDER), PLACEHOLDER.size(), getCode(slot));
44
29 auto vs = gpu::ShaderPointer(gpu::Shader::createVertex({ debug_deferred_buffer_vert }));45 auto vs = gpu::ShaderPointer(gpu::Shader::createVertex({ debug_deferred_buffer_vert }));
30 auto ps = gpu::ShaderPointer(gpu::Shader::createPixel({ debug_deferred_buffer_frag }));46 auto ps = gpu::ShaderPointer(gpu::Shader::createPixel(fragmentShader));
31 auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));47 auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
32 48
33
34 gpu::Shader::BindingSet slotBindings;49 gpu::Shader::BindingSet slotBindings;
50 for (int slot = 0; slot < NUM_SLOTS; ++slot) {
51 slotBindings.insert(gpu::Shader::Binding(SLOT_NAMES[slot], slot));
52 }
35 gpu::Shader::makeProgram(*program, slotBindings);53 gpu::Shader::makeProgram(*program, slotBindings);
36 54
37 // Good to go add the brand new pipeline55 // Good to go add the brand new pipeline
38 _pipeline = gpu::Pipeline::create(program, std::make_shared<gpu::State>());56 _pipelines[slot] = gpu::Pipeline::create(program, std::make_shared<gpu::State>());
39 }57 }
40 return _pipeline;58 return _pipelines[slot];
41}59}
42 60
43 61
@@ -58,9 +76,13 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 14 unmodified lines
58 batch.setViewTransform(viewMat);76 batch.setViewTransform(viewMat);
59 batch.setModelTransform(Transform());77 batch.setModelTransform(Transform());
60 78
61 batch.setPipeline(getPipeline());79 batch.setPipeline(getPipeline((DebugDeferredBufferSlot)(renderContext->_drawDebugDeferredBuffer - 1)));
62 80
63 batch.setResourceTexture(0, framebufferCache->getDeferredColorTexture());81 batch.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture());
82 batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
83 batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
84 batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
85 batch.setResourceTexture(Lighting, framebufferCache->getLightingTexture());
64 86
65 glm::vec4 color(0.0f, 0.0f, 1.0f, 1.0f);87 glm::vec4 color(0.0f, 0.0f, 1.0f, 1.0f);
66 glm::vec2 bottomLeft(0.0f, -1.0f);88 glm::vec2 bottomLeft(0.0f, -1.0f);

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