opengl 3.3 renderer cascaded shadow maps, minor gfx renderer optimizations

This commit is contained in:
tmj-fstate
2019-12-05 15:42:54 +01:00
parent 194400e1af
commit 63619d13a6
21 changed files with 416 additions and 443 deletions

View File

@@ -25,6 +25,12 @@ void gl::framebuffer::attach(const opengl_texture &tex, GLenum location)
glFramebufferTexture2D(GL_FRAMEBUFFER, location, tex.target, tex.id, 0);
}
void gl::framebuffer::attach(const opengl_texture &tex, GLenum location, GLint layer)
{
bind();
glFramebufferTextureLayer(GL_FRAMEBUFFER, location, tex.id, 0, layer);
}
void gl::framebuffer::attach(const cubemap &tex, int face, GLenum location)
{
bind();

View File

@@ -15,6 +15,7 @@ namespace gl
~framebuffer();
void attach(const opengl_texture &tex, GLenum location);
void attach( const opengl_texture &tex, GLenum location, GLint layer );
void attach(const cubemap &tex, int face, GLenum location);
void attach(const renderbuffer &rb, GLenum location);
void setup_drawing(int attachments);

View File

@@ -13,6 +13,7 @@ void gl::glsl_common_setup()
"#define EXTRAEFFECTS_ENABLED " + std::to_string((int)Global.gfx_extraeffects) + "\n" +
"#define USE_GLES " + std::to_string((int)Global.gfx_usegles) + "\n" +
"const uint MAX_LIGHTS = " + std::to_string(MAX_LIGHTS) + "U;\n" +
"const uint MAX_CASCADES = " + std::to_string(MAX_CASCADES) + "U;\n" +
"const uint MAX_PARAMS = " + std::to_string(MAX_PARAMS) + "U;\n" +
R"STRING(
const uint LIGHT_SPOT = 0U;
@@ -64,9 +65,9 @@ void gl::glsl_common_setup()
layout (std140) uniform scene_ubo
{
mat4 projection;
mat4 lightview;
mat4 inv_view;
vec3 scene_extra;
mat4 lightview[MAX_CASCADES];
vec4 cascade_end;
float time;
};

View File

@@ -32,17 +32,18 @@ namespace gl
const size_t MAX_TEXTURES = 8;
const size_t ENVMAP_SIZE = 1024;
const size_t MAX_CASCADES = 3;
struct scene_ubs
{
glm::mat4 projection;
glm::mat4 lightview;
glm::mat4 inv_view;
glm::vec3 scene_extra;
glm::mat4 lightview[MAX_CASCADES];
glm::vec4 cascade_end;
float time;
};
static_assert(sizeof(scene_ubs) == 208, "bad size of ubs");
static_assert(sizeof(scene_ubs) == 340, "bad size of ubs");
const size_t MAX_PARAMS = 3;