Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
PostProcess.h
Go to the documentation of this file.
1/**
2 * @file PostProcess.h
3 * @ingroup mnd_graphics
4 * @brief Three.js-style pixel-art post-pass.
5 *
6 * Reads the scene RenderTarget's three attachments (colour, view-normals,
7 * depth), computes depth-edge and normal-edge indicators a la
8 * threejs.org/examples/webgl_postprocessing_pixel.html, and writes the
9 * result into its own colour FBO for the final BlitNearest upscale.
10 *
11 * For the current full-resolution RenderTarget path, pixelation is done in
12 * this pass by snapping colour/depth/normal samples to RenderSettings::pixelSize
13 * screen-pixel cells before applying the optional edge term.
14 */
15
16#pragma once
17
18#include "GL/glew.h"
19
20namespace mnd
21{
22
23class RenderTarget;
24struct CameraData;
25
27{
28public:
29 bool Init();
30 void Destroy();
31
32 /// Lazily resize the internal output FBO to match the scene target.
33 void Resize(int w, int h);
34
35 /// Run the outline pass, sampling `scene` and writing to OutputTex().
36 void RunOutline(const RenderTarget &scene, const CameraData &cam);
37
38 GLuint OutputTex() const { return m_color; }
39 bool IsValid() const { return m_program != 0 && m_vao != 0; }
40
41 // Editor-tunable. Both 0 = passthrough (no edges).
42 float depthEdgeStrength = 0.4F;
43 float normalEdgeStrength = 0.3F;
44
45private:
46 bool CreateFBO(int w, int h);
47 void DestroyFBO();
48
49 GLuint m_program = 0;
50 GLuint m_vao = 0;
51
52 GLuint m_fbo = 0;
53 GLuint m_color = 0;
54 int m_w = 0;
55 int m_h = 0;
56
57 int m_locColor = -1;
58 int m_locNormal = -1;
59 int m_locDepth = -1;
60 int m_locTexel = -1;
61 int m_locDepthStr = -1;
62 int m_locNormalStr = -1;
63 int m_locPixelSize = -1;
64};
65
66} // namespace mnd
unsigned int GLuint
Definition GLForward.h:11
bool IsValid() const
Definition PostProcess.h:39
float normalEdgeStrength
Definition PostProcess.h:43
float depthEdgeStrength
Definition PostProcess.h:42
void Resize(int w, int h)
Lazily resize the internal output FBO to match the scene target.
void RunOutline(const RenderTarget &scene, const CameraData &cam)
Run the outline pass, sampling scene and writing to OutputTex().
GLuint OutputTex() const
Definition PostProcess.h:38
Offscreen FBO with MRT colour + sampleable depth for low-resolution rendering.
Per-frame camera matrices and world-space position.
Definition Common.h:35