Skip to content

Commit

Permalink
Refactor|Renderer|UI: Post-processing shader applied during view comp…
Browse files Browse the repository at this point in the history
…osition

Instead of having fx::PostProcessing as a lens effect, ViewCompositor
now applies the post-processing shader when it blits the game view to
the window as one of the layers of the view.

This has the benefit that the post-processor doesn't need a separate
framebuffer of its own because it can use the existing game view
texture and draw directly in the window framebuffer.

fx::Resize was also removed because the game view resolution can be
trivially changed by resizing the game view texture.
  • Loading branch information
skyjake committed Sep 30, 2016
1 parent 9d942e8 commit 1e11df7
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 425 deletions.
55 changes: 0 additions & 55 deletions doomsday/apps/client/include/render/fx/resize.h

This file was deleted.

Expand Up @@ -20,19 +20,19 @@
#define DENG_CLIENT_FX_POSTPROCESSING_H

#include "render/consoleeffect.h"
#include <de/Matrix>
#include <de/Time>

namespace fx {
#include <de/GLTexture>

/**
* Post-processing of rendered camera lens frames. Maintains an offscreen
* render target and provides a way to draw it back to the regular target
* with shader effects applied.
*/
class PostProcessing : public ConsoleEffect
class PostProcessing
{
public:
PostProcessing(int console);
PostProcessing();

/**
* Determines whether the effect is active. If it isn't, it can be skipped
Expand Down Expand Up @@ -64,14 +64,17 @@ class PostProcessing : public ConsoleEffect
void glInit();
void glDeinit();

void beginFrame();
void draw();
void endFrame();
void update();

//void beginFrame();
void draw(de::Matrix4f const &mvpMatrix, de::GLTexture const &frame);
//void endFrame();

public:
static void consoleRegister();

private:
DENG2_PRIVATE(d)
};

} // namespace fx

#endif // DENG_CLIENT_FX_POSTPROCESSING_H
4 changes: 4 additions & 0 deletions doomsday/apps/client/include/ui/viewcompositor.h
Expand Up @@ -21,6 +21,8 @@

#include <de/GLTextureFramebuffer>

class PostProcessing;

/**
* Compositor for the game view.
*
Expand Down Expand Up @@ -78,6 +80,8 @@ class ViewCompositor
*/
void drawCompositedLayers();

PostProcessing &postProcessing();

private:
DENG2_PRIVATE(d)
};
Expand Down
48 changes: 3 additions & 45 deletions doomsday/apps/client/src/render/cameralensfx.cpp
Expand Up @@ -44,8 +44,6 @@
#include "render/fx/bloom.h"
#include "render/fx/colorfilter.h"
#include "render/fx/lensflares.h"
#include "render/fx/postprocessing.h"
#include "render/fx/resize.h"
#include "render/fx/vignette.h"
#include "world/p_players.h"

Expand All @@ -63,59 +61,19 @@ using namespace de;
static int fxFramePlayerNum; ///< Player view currently being drawn.

#define IDX_LENS_FLARES 3
#define IDX_POST_PROCESSING 5

D_CMD(PostFx)
{
DENG2_UNUSED(src);

int console = String(argv[1]).toInt();
String const shader = argv[2];
TimeDelta const span = (argc == 4? String(argv[3]).toFloat() : 0);

if(console < 0 || console >= DDMAXPLAYERS)
{
LOG_SCR_WARNING("Invalid console %i") << console;
return false;
}

fx::PostProcessing *post =
static_cast<fx::PostProcessing *>(DD_Player(console)->fxStack().effects[IDX_POST_PROCESSING]);

// Special case to clear out the current shader.
if(shader == "none")
{
post->fadeOut(span);
return true;
}
else if(shader == "opacity") // Change opacity.
{
post->setOpacity(span);
return true;
}

post->fadeInShader(shader, span);
return true;
}

void LensFx_Register()
{
C_CMD("postfx", "is", PostFx);
C_CMD("postfx", "isf", PostFx);
}
//#define IDX_POST_PROCESSING 5

void LensFx_Init()
{
for(int i = 0; i < DDMAXPLAYERS; ++i)
{
ConsoleEffectStack &stack = DD_Player(i)->fxStack();
stack.effects
<< new fx::Resize(i)
<< new fx::Bloom(i)
<< new fx::Vignette(i)
<< new fx::LensFlares(i) // IDX_LENS_FLARES
<< new fx::ColorFilter(i)
<< new fx::PostProcessing(i); // IDX_POST_PROCESSING
<< new fx::ColorFilter(i);
//<< new fx::PostProcessing(i); // IDX_POST_PROCESSING
}
}

Expand Down

0 comments on commit 1e11df7

Please sign in to comment.