Move common shader data to uniform buffer
This commit is contained in:
@@ -45,7 +45,12 @@ uniform Material material;
|
||||
uniform DirLight directional_light;
|
||||
uniform PointLight point_lights[POINT_LIGHT_COUNT];
|
||||
uniform SpotLight spot_light;
|
||||
uniform vec3 camera_position;
|
||||
|
||||
layout (std140) uniform Common {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
vec3 camera_position;
|
||||
};
|
||||
|
||||
vec3 calc_dir_light(DirLight light, vec3 normal, vec3 view_direction);
|
||||
vec3 calc_point_light(PointLight light, vec3 normal, vec3 frag_position, vec3 view_direction);
|
||||
|
||||
@@ -6,9 +6,14 @@ in VS_OUT {
|
||||
vec2 uv_coords;
|
||||
} fs_in;
|
||||
|
||||
uniform vec3 camera_position;
|
||||
uniform samplerCube cubemap;
|
||||
|
||||
layout (std140) uniform Common {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
vec3 camera_position;
|
||||
};
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -9,9 +9,14 @@ in VS_OUT {
|
||||
vec2 uv_coords;
|
||||
} fs_in;
|
||||
|
||||
uniform vec3 camera_position;
|
||||
uniform samplerCube cubemap;
|
||||
|
||||
layout (std140) uniform Common {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
vec3 camera_position;
|
||||
};
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -4,13 +4,18 @@ layout(location=0) in vec3 position;
|
||||
layout(location=1) in vec3 normal;
|
||||
layout(location=2) in vec2 uv;
|
||||
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 sb_view;
|
||||
|
||||
layout (std140) uniform Common {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
vec3 camera_position;
|
||||
};
|
||||
|
||||
out vec3 uv_coords;
|
||||
|
||||
void main() {
|
||||
vec4 pos = projection * view * vec4(position, 1.0);
|
||||
vec4 pos = projection * sb_view * vec4(position, 1.0);
|
||||
gl_Position = pos.xyww;
|
||||
uv_coords = position;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ layout(location=2) in vec2 uv;
|
||||
|
||||
uniform mat3 normal_mat;
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
layout (std140) uniform Common {
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
vec3 camera_position;
|
||||
};
|
||||
|
||||
// interface block
|
||||
out VS_OUT {
|
||||
|
||||
Reference in New Issue
Block a user