-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPostFX.hpp
More file actions
65 lines (53 loc) · 2.26 KB
/
PostFX.hpp
File metadata and controls
65 lines (53 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef POSTFX_HPP
#define POSTFX_HPP
#include <cstdint>
#include "Config.hpp"
namespace Renderer {
/// @brief Collection of in-place post-processing effects on an RGB565 framebuffer.
///
/// Each effect compiles to a no-op when its corresponding POSTFX_* config
/// flag is zero. Working buffers are allocated once at construction and
/// reused every frame.
class PostFX {
public:
/// @brief Construct a PostFX instance sized for a specific framebuffer.
/// @param screenWidth Framebuffer width in pixels.
/// @param screenHeight Framebuffer height in pixels.
PostFX(int screenWidth, int screenHeight);
~PostFX();
/// @brief Apply a 5-tap luminance-driven anti-aliasing pass in place.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyFXAA(uint16_t* framebuffer);
/// @brief Apply a separable box-blur bloom pass in place.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyBloom(uint16_t* framebuffer);
/// @brief Apply a CRT scanline darkening effect in place.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyCRT(uint16_t* framebuffer);
/// @brief Blend the current frame with the previous frame to produce motion blur.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyMotionBlur(uint16_t* framebuffer);
/// @brief Apply a chromatic aberration channel-shift effect in place.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyChromatic(uint16_t* framebuffer);
/// @brief Quantize the framebuffer to PIXELATE_SIZE x PIXELATE_SIZE blocks in place.
/// @param framebuffer RGB565 framebuffer of size screenWidth*screenHeight.
void applyPixelate(uint16_t* framebuffer);
private:
int screenWidth;
int screenHeight;
#if POSTFX_BLOOM
uint16_t* bloomBuffer;
uint16_t* bloomTemp;
#endif
#if POSTFX_MOTION_BLUR
uint16_t* previousFrame;
#endif
#if POSTFX_ANTIALIASING
// Cached unpacked channels + luminance for the previous (top) row.
// Layout: 4 * screenWidth int16s, indexed [x*4 + {0=r,1=g,2=b,3=lum}].
int16_t* fxaaTopRow;
#endif
};
} // namespace Renderer
#endif // POSTFX_HPP