16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 22:59:19 +02:00
This commit is contained in:
milek7
2018-07-08 21:33:26 +02:00
parent 1c26096c5c
commit 13ba3fcd13
40 changed files with 917 additions and 506 deletions

View File

@@ -2,7 +2,6 @@
#include "bindable.h"
#define UBS_PAD(x) uint64_t : x * 4; uint64_t : x * 4;
#define DEFINE_UBS(x, y) _Pragma("pack(push, 1)"); struct x y; _Pragma("pack(pop)")
namespace gl
{
@@ -20,29 +19,82 @@ namespace gl
void update(void *data, int offset, int size);
};
// layout std140
// structs must match with GLSL
// ordered to minimize padding
_Pragma("pack(push, 1)")
struct scene_ubs
{
glm::mat4 projection;
void set(const glm::mat4 &m)
{
projection = m;
}
glm::mat4 lightview;
float time;
};
static_assert(sizeof(scene_ubs) == 132, "bad size of ubs");
const size_t MAX_PARAMS = 3;
struct model_ubs
{
glm::mat4 modelview;
glm::mat4 modelviewnormal;
glm::mat3x4 modelviewnormal;
glm::vec4 param[MAX_PARAMS];
void set(const glm::mat4 &m)
glm::vec3 velocity;
float opacity;
float emission;
void set_modelview(const glm::mat4 &mv)
{
modelview = m;
modelviewnormal = glm::mat3(glm::transpose(glm::inverse(m)));
modelview = mv;
modelviewnormal = glm::mat3(glm::transpose(glm::inverse(mv)));
}
};
static_assert(sizeof(model_ubs) == 156 + 8 * MAX_PARAMS, "bad size of ubs");
struct light_element_ubs
{
enum type_e
{
SPOT = 0,
POINT,
DIR
};
glm::vec3 pos;
type_e type;
glm::vec3 dir;
float in_cutoff;
glm::vec3 color;
float out_cutoff;
float linear;
float quadratic;
UBS_PAD(8);
};
static_assert(sizeof(light_element_ubs) == 64, "bad size of ubs");
const size_t MAX_LIGHTS = 16;
struct light_ubs
{
glm::vec3 ambient;
float fog_density;
glm::vec3 fog_color;
uint32_t lights_count;
light_element_ubs lights[MAX_LIGHTS];
};
static_assert(sizeof(light_ubs) == 32 + sizeof(light_element_ubs) * MAX_LIGHTS, "bad size of ubs");
_Pragma("pack(pop)")
}