2016-07-26 19:27:02 +00:00
|
|
|
#ifndef __GL_RENDERBUFFERS_H
|
|
|
|
#define __GL_RENDERBUFFERS_H
|
|
|
|
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
|
2016-07-27 19:50:30 +00:00
|
|
|
class FGLBloomTextureLevel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLuint VTexture = 0;
|
|
|
|
GLuint VFramebuffer = 0;
|
|
|
|
GLuint HTexture = 0;
|
|
|
|
GLuint HFramebuffer = 0;
|
|
|
|
GLuint Width = 0;
|
|
|
|
GLuint Height = 0;
|
|
|
|
};
|
|
|
|
|
2016-09-18 13:57:22 +00:00
|
|
|
class FGLExposureTextureLevel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLuint Texture = 0;
|
|
|
|
GLuint Framebuffer = 0;
|
|
|
|
GLuint Width = 0;
|
|
|
|
GLuint Height = 0;
|
|
|
|
};
|
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
class FGLRenderBuffers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FGLRenderBuffers();
|
|
|
|
~FGLRenderBuffers();
|
|
|
|
|
2016-08-28 16:07:44 +00:00
|
|
|
bool Setup(int width, int height, int sceneWidth, int sceneHeight);
|
2016-08-04 15:16:49 +00:00
|
|
|
|
2016-08-29 11:10:22 +00:00
|
|
|
void BindSceneFB(bool sceneData);
|
|
|
|
void BindSceneColorTexture(int index);
|
2016-10-05 05:57:27 +00:00
|
|
|
void BindSceneFogTexture(int index);
|
|
|
|
void BindSceneNormalTexture(int index);
|
2016-08-29 11:10:22 +00:00
|
|
|
void BindSceneDepthTexture(int index);
|
2016-08-04 15:16:49 +00:00
|
|
|
void BlitSceneToTexture();
|
|
|
|
|
|
|
|
void BindCurrentTexture(int index);
|
|
|
|
void BindCurrentFB();
|
|
|
|
void BindNextFB();
|
|
|
|
void NextTexture();
|
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
void BindOutputFB();
|
|
|
|
|
2016-09-07 18:31:42 +00:00
|
|
|
void BlitToEyeTexture(int eye);
|
|
|
|
void BindEyeTexture(int eye, int texunit);
|
2016-09-07 19:52:43 +00:00
|
|
|
void BindEyeFB(int eye, bool readBuffer = false);
|
2016-09-07 18:31:42 +00:00
|
|
|
|
2017-03-01 16:17:33 +00:00
|
|
|
void BindShadowMapFB();
|
|
|
|
void BindShadowMapTexture(int index);
|
|
|
|
|
2016-07-27 19:50:30 +00:00
|
|
|
enum { NumBloomLevels = 4 };
|
|
|
|
FGLBloomTextureLevel BloomLevels[NumBloomLevels];
|
|
|
|
|
2016-09-18 13:57:22 +00:00
|
|
|
TArray<FGLExposureTextureLevel> ExposureLevels;
|
|
|
|
GLuint ExposureTexture = 0;
|
|
|
|
GLuint ExposureFB = 0;
|
|
|
|
bool FirstExposureFrame = true;
|
|
|
|
|
2016-08-29 11:10:22 +00:00
|
|
|
// Ambient occlusion buffers
|
2016-10-09 04:17:48 +00:00
|
|
|
GLuint LinearDepthTexture = 0;
|
|
|
|
GLuint LinearDepthFB = 0;
|
2016-08-29 11:10:22 +00:00
|
|
|
GLuint AmbientTexture0 = 0;
|
|
|
|
GLuint AmbientTexture1 = 0;
|
|
|
|
GLuint AmbientFB0 = 0;
|
|
|
|
GLuint AmbientFB1 = 0;
|
|
|
|
int AmbientWidth = 0;
|
|
|
|
int AmbientHeight = 0;
|
2016-10-06 05:36:49 +00:00
|
|
|
enum { NumAmbientRandomTextures = 3 };
|
|
|
|
GLuint AmbientRandomTexture[NumAmbientRandomTextures];
|
2016-08-29 11:10:22 +00:00
|
|
|
|
2016-07-29 19:31:20 +00:00
|
|
|
static bool IsEnabled();
|
|
|
|
|
2016-07-31 14:23:21 +00:00
|
|
|
int GetWidth() const { return mWidth; }
|
|
|
|
int GetHeight() const { return mHeight; }
|
|
|
|
|
2016-09-01 05:15:40 +00:00
|
|
|
int GetSceneWidth() const { return mSceneWidth; }
|
|
|
|
int GetSceneHeight() const { return mSceneHeight; }
|
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
private:
|
2016-07-30 13:33:30 +00:00
|
|
|
void ClearScene();
|
2016-08-04 15:16:49 +00:00
|
|
|
void ClearPipeline();
|
2016-09-07 18:31:42 +00:00
|
|
|
void ClearEyeBuffers();
|
2016-07-30 13:33:30 +00:00
|
|
|
void ClearBloom();
|
2016-09-18 13:57:22 +00:00
|
|
|
void ClearExposureLevels();
|
2016-08-29 11:10:22 +00:00
|
|
|
void ClearAmbientOcclusion();
|
2016-10-05 01:56:58 +00:00
|
|
|
void CreateScene(int width, int height, int samples, bool needsSceneTextures);
|
2016-08-04 15:16:49 +00:00
|
|
|
void CreatePipeline(int width, int height);
|
2016-07-30 13:33:30 +00:00
|
|
|
void CreateBloom(int width, int height);
|
2016-09-18 13:57:22 +00:00
|
|
|
void CreateExposureLevels(int width, int height);
|
2016-09-07 18:31:42 +00:00
|
|
|
void CreateEyeBuffers(int eye);
|
2017-03-01 16:17:33 +00:00
|
|
|
void CreateShadowMap();
|
2016-08-29 11:10:22 +00:00
|
|
|
void CreateAmbientOcclusion(int width, int height);
|
2016-09-18 13:57:22 +00:00
|
|
|
GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr);
|
2016-08-29 11:10:22 +00:00
|
|
|
GLuint Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations);
|
2016-08-17 21:18:47 +00:00
|
|
|
GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height);
|
2016-10-09 04:17:48 +00:00
|
|
|
GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height, int samples);
|
2016-08-17 21:18:47 +00:00
|
|
|
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer);
|
2016-10-05 01:56:58 +00:00
|
|
|
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer);
|
2016-10-05 05:57:27 +00:00
|
|
|
GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer0, GLuint colorbuffer1, GLuint colorbuffer2, GLuint depthstencil, bool multisample);
|
2016-08-28 16:07:44 +00:00
|
|
|
bool CheckFrameBufferCompleteness();
|
2016-08-17 22:21:33 +00:00
|
|
|
void ClearFrameBuffer(bool stencil, bool depth);
|
2016-07-29 19:31:20 +00:00
|
|
|
void DeleteTexture(GLuint &handle);
|
|
|
|
void DeleteRenderBuffer(GLuint &handle);
|
|
|
|
void DeleteFrameBuffer(GLuint &handle);
|
2016-07-27 19:50:30 +00:00
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
int mWidth = 0;
|
|
|
|
int mHeight = 0;
|
2016-07-30 13:33:30 +00:00
|
|
|
int mSamples = 0;
|
2016-08-17 15:59:47 +00:00
|
|
|
int mMaxSamples = 0;
|
2016-09-18 13:57:22 +00:00
|
|
|
int mSceneWidth = 0;
|
|
|
|
int mSceneHeight = 0;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2016-08-04 15:16:49 +00:00
|
|
|
static const int NumPipelineTextures = 2;
|
|
|
|
int mCurrentPipelineTexture = 0;
|
|
|
|
|
|
|
|
// Buffers for the scene
|
2016-07-30 13:33:30 +00:00
|
|
|
GLuint mSceneMultisample = 0;
|
2016-07-26 19:27:02 +00:00
|
|
|
GLuint mSceneDepthStencil = 0;
|
2016-10-05 05:57:27 +00:00
|
|
|
GLuint mSceneFog = 0;
|
|
|
|
GLuint mSceneNormal = 0;
|
2016-07-26 19:27:02 +00:00
|
|
|
GLuint mSceneFB = 0;
|
2016-08-29 11:10:22 +00:00
|
|
|
GLuint mSceneDataFB = 0;
|
2016-10-05 01:56:58 +00:00
|
|
|
bool mSceneUsesTextures = false;
|
2016-08-04 15:16:49 +00:00
|
|
|
|
|
|
|
// Effect/HUD buffers
|
|
|
|
GLuint mPipelineTexture[NumPipelineTextures];
|
|
|
|
GLuint mPipelineFB[NumPipelineTextures];
|
|
|
|
|
|
|
|
// Back buffer frame buffer
|
2016-07-26 19:27:02 +00:00
|
|
|
GLuint mOutputFB = 0;
|
2016-08-28 16:07:44 +00:00
|
|
|
|
2016-09-07 18:31:42 +00:00
|
|
|
// Eye buffers
|
|
|
|
TArray<GLuint> mEyeTextures;
|
|
|
|
TArray<GLuint> mEyeFBs;
|
|
|
|
|
2017-03-01 16:17:33 +00:00
|
|
|
// Shadow map texture
|
|
|
|
GLuint mShadowMapTexture = 0;
|
|
|
|
GLuint mShadowMapFB = 0;
|
|
|
|
|
2016-08-28 16:07:44 +00:00
|
|
|
static bool FailedCreate;
|
2016-09-02 22:13:05 +00:00
|
|
|
static bool BuffersActive;
|
2016-07-26 19:27:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|