AnimEngine
GlobalIllumination.hpp
1 //
2 // GlobalIllumination.hpp
3 // AnimEngine
4 //
5 // Created by Cam Stocker on 11/11/19.
6 //
7 
8 #ifndef GlobalIllumination_hpp
9 #define GlobalIllumination_hpp
10 
11 #include <stdio.h>
12 #include "RenderSystem.hpp"
13 #define GLFW_INCLUDE_NONE
14 #include <GLFW/glfw3.h>
15 
16 #define VPLRESOLUTION 128
17 #define WRITEFRAMES true
18 #define LOOPS 6
19 
21 public:
22  static GlobalIllumination& getInstance() {
23  static GlobalIllumination _instance_;
24  return(_instance_);
25  }
26 
27  void init(GLFWwindow* window);
28 
29  void initQuad();
30  void initVPLBuffer();
31  void initGeometryBuffer();
32  void initCustomShaderBuffer();
33  void initRenderBuffer();
34  void initCompositeBuffer();
35 
36  const std::string& getOutputDir() const {return(mOutputDir);}
37  void setOutputDir(const std::string& aOutputDir) {mOutputDir = aOutputDir;}
38 
39  void process(Scene& scene);
40  virtual void processEntity(Scene& scene, const MVPset& MVP, Entity* entity, Program* shader) override;
41 
42  void VPLpass(Program &vplShader, Scene& scene);
43  void geometryPass(Program& geometryShader, Scene& scene);
44  void renderPass(Program& renderShader, Scene& scene);
45  void customShaderPass(Program &toonShader, Scene &scene);
46  void compositePass(Program& screenShader, Scene& scene);
47  void screenPass(Program& finalShader, Scene& scene);
48 
49  void drawQuad();
50 
51  glm::mat4 getLightProjMatrix();
52  glm::mat4 getLightViewMatrix(glm::vec3 position, glm::vec3 direction, glm::vec3 up);
53  glm::mat4 getProjectionMatrix();
54  glm::mat4 getViewMatrix(vec3 position, vec3 lookat);
55 
56 private:
57 
58  std::string mOutputDir = "./frames/";
59 
60  // temporary light position
61  glm::vec3 lightPos;
62  bool firstTime = true;
63  int frameNum = 0;
64 
65  int vplWidth;
66  int vplHeight;
67  // Set up VPL buffer object
68  GLuint depthBuf;
69 
70  GLuint VPLBuffer[6], VPLdepthBuf[6];
71  GLuint VPLpositions[6], VPLcolors[6];
72 
73  // set up deferred buffer object - referenced LearnOpenGL.com
74  GLuint geometryBuffer;
75  GLuint gNormals, gPositions, gDepth, baseColors;
76 
77  // texture for all positions of all GI objects that are not GI.
78  GLuint notGIPositions;
79 
80  // Set up render quad geometry - LearnOpenGL.com
81  GLuint quad_VertexArrayID;
82  GLuint quad_vertexbuffer;
83 
84  // custom shader FBO
85  GLuint customShaderFBO;
86  GLuint customShaderTexture;
87  GLuint customShaderDepthBuf;
88 
89  // Set up render FBO
90  GLuint renderFBO;
91  GLuint renderTexture;
92 
93  // Set up screen FBO
94  GLuint compositeFBO;
95  GLuint compositeTexture;
96  GLuint compositeDepthBuf;
97 };
98 
99 #endif /* GlobalIllumination_hpp */
Definition: Program.h:15
Definition: drawable.hpp:8
Definition: RenderSystem.hpp:10
Definition: EntitiesBase.hpp:18
Definition: Scene.hpp:12
Definition: GlobalIllumination.hpp:20