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
2424
2525 using namespace render;
2626
27−const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline() {
28− if (!_pipeline) {
27+static const std::string PLACEHOLDER { "DEBUG_PLACEHOLDER" };
28+static const std::array<std::string, DebugDeferredBuffer::NUM_SLOTS> SLOT_NAMES {{
29+ "diffuseMap",
30+ "normalMap",
31+ "specularMap",
32+ "depthMap",
33+ "lightingMap"
34+}};
35+
36+std::string getCode(int slot) {
37+ return std::string("return texture(").append(SLOT_NAMES[slot]).append(", uv);");
38+}
39+
40+const 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+
2945 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));
3147 auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps));
3248
33−
3449 gpu::Shader::BindingSet slotBindings;
50+ for (int slot = 0; slot < NUM_SLOTS; ++slot) {
51+ slotBindings.insert(gpu::Shader::Binding(SLOT_NAMES[slot], slot));
52+ }
3553 gpu::Shader::makeProgram(*program, slotBindings);
3654
3755 // 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>());
3957 }
40− return _pipeline;
58+ return _pipelines[slot];
4159 }
4260
4361
@@ -58,9 +76,13 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren · 14 unmodified lines
5876 batch.setViewTransform(viewMat);
5977 batch.setModelTransform(Transform());
6078
61− batch.setPipeline(getPipeline());
79+ batch.setPipeline(getPipeline((DebugDeferredBufferSlot)(renderContext->_drawDebugDeferredBuffer - 1)));
6280
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());
6486
6587 glm::vec4 color(0.0f, 0.0f, 1.0f, 1.0f);
6688 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