16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

build 200101. opengl 3.3 renderer projected headlights

This commit is contained in:
tmj-fstate
2020-01-01 20:41:05 +01:00
parent 10262f37dc
commit 14699a96de
11 changed files with 147 additions and 63 deletions

View File

@@ -19,6 +19,7 @@ void gl::glsl_common_setup()
const uint LIGHT_SPOT = 0U;
const uint LIGHT_POINT = 1U;
const uint LIGHT_DIR = 2U;
const uint LIGHT_HEADLIGHTS = 3U;
struct light_s
{
@@ -36,6 +37,9 @@ void gl::glsl_common_setup()
float intensity;
float ambient;
mat4 headlight_projection;
vec4 headlight_weights;
};
layout(std140) uniform light_ubo

View File

@@ -272,8 +272,9 @@ void gl::program::init()
glUniform1i(loc, e.id);
}
glUniform1i(glGetUniformLocation(*this, "shadowmap"), MAX_TEXTURES + 0);
glUniform1i(glGetUniformLocation(*this, "envmap"), MAX_TEXTURES + 1);
glUniform1i(glGetUniformLocation(*this, "shadowmap"), gl::SHADOW_TEX);
glUniform1i(glGetUniformLocation(*this, "envmap"), gl::ENV_TEX);
glUniform1i( glGetUniformLocation( *this, "headlightmap" ), gl::HEADLIGHT_TEX);
GLuint index;

View File

@@ -33,6 +33,10 @@ namespace gl
const size_t MAX_TEXTURES = 8;
const size_t ENVMAP_SIZE = 1024;
const size_t MAX_CASCADES = 3;
const size_t HELPER_TEXTURES = 4;
const size_t SHADOW_TEX = MAX_TEXTURES + 0;
const size_t ENV_TEX = MAX_TEXTURES + 1;
const size_t HEADLIGHT_TEX = MAX_TEXTURES + 2;
struct scene_ubs
{
@@ -76,7 +80,8 @@ namespace gl
{
SPOT = 0,
POINT,
DIR
DIR,
HEADLIGHTS
};
glm::vec3 pos;
@@ -93,9 +98,12 @@ namespace gl
float intensity;
float ambient;
glm::mat4 headlight_projection;
glm::vec4 headlight_weights;
};
static_assert(sizeof(light_element_ubs) == 64, "bad size of ubs");
static_assert(sizeof(light_element_ubs) == 144, "bad size of ubs");
const size_t MAX_LIGHTS = 8;