Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 804 vs 822 for /trunk/Source Code/Rendering/PostFX/CustomOperators/BloomPreRenderOperator.cpp

Diff revisions: vs.
  @@ -7,19 +7,22 @@
7 7 #include "Core/Resources/Headers/ResourceCache.h"
8 8 #include "Geometry/Shapes/Headers/Predefined/Quad3D.h"
9 9
10 + #include "Rendering/PostFX/Headers/PreRenderBatch.h"
11 + #include "Platform/Video/Buffers/RenderTarget/Headers/RenderTarget.h"
12 +
10 13 namespace Divide {
11 14
12 - BloomPreRenderOperator::BloomPreRenderOperator(GFXDevice& context, ResourceCache& cache, RenderTarget* hdrTarget, RenderTarget* ldrTarget)
13 - : PreRenderOperator(context, cache, FilterType::FILTER_BLOOM, hdrTarget, ldrTarget)
15 + BloomPreRenderOperator::BloomPreRenderOperator(GFXDevice& context, PreRenderBatch& parent, ResourceCache& cache)
16 + : PreRenderOperator(context, parent, cache, FilterType::FILTER_BLOOM)
14 17 {
15 18 for (U8 i = 0; i < 2; ++i) {
16 19 _bloomBlurBuffer[i] = _context.allocateRT(Util::StringFormat("Bloom_Blur_%d", i));
17 - _bloomBlurBuffer[i]._rt->addAttachment(_hdrTarget->getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
20 + _bloomBlurBuffer[i]._rt->addAttachment(parent.inputRT().getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
18 21 _bloomBlurBuffer[i]._rt->setClearColour(RTAttachment::Type::COUNT, 0, DefaultColours::BLACK());
19 22 }
20 23
21 24 _bloomOutput = _context.allocateRT("Bloom");
22 - _bloomOutput._rt->addAttachment(_hdrTarget->getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
25 + _bloomOutput._rt->addAttachment(parent.inputRT().getDescriptor(RTAttachment::Type::Colour, 0), RTAttachment::Type::Colour, 0, false);
23 26 _bloomOutput._rt->setClearColour(RTAttachment::Type::COUNT, 0, DefaultColours::BLACK());
24 27
25 28 ResourceDescriptor bloomCalc("bloom.BloomCalc");
  @@ -69,8 +72,11 @@
69 72 triangleCmd.drawCount(1);
70 73 triangleCmd.stateHash(_context.getDefaultStateBlock(true));
71 74
75 + RenderTarget* screen = &_parent.inputRT();
76 +
72 77 // Step 1: generate bloom
73 - _hdrTarget->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0); //screen
78 + screen->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0); //screen
79 +
74 80 // render all of the "bright spots"
75 81 _bloomOutput._rt->begin(RenderTarget::defaultPolicy());
76 82 triangleCmd.shaderProgram(_bloomCalc);
  @@ -96,13 +102,13 @@
96 102 _bloomBlurBuffer[1]._rt->end();
97 103
98 104 // Step 3: apply bloom
99 - _bloomBlurBuffer[0]._rt->blitFrom(_hdrTarget);
105 + _bloomBlurBuffer[0]._rt->blitFrom(screen);
100 106 _bloomBlurBuffer[0]._rt->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT0), RTAttachment::Type::Colour, 0); //Screen
101 107 _bloomBlurBuffer[1]._rt->bind(to_const_ubyte(ShaderProgram::TextureUsage::UNIT1), RTAttachment::Type::Colour, 0); //Bloom
102 - _hdrTarget->begin(_screenOnlyDraw);
108 + screen->begin(_screenOnlyDraw);
103 109 triangleCmd.shaderProgram(_bloomApply);
104 110 _context.draw(triangleCmd);
105 - _hdrTarget->end();
111 + screen->end();
106 112 }
107 113
108 114 void BloomPreRenderOperator::debugPreview(U8 slot) const {