Add support for includes when loading shaders.

This commit is contained in:
2022-12-31 14:38:53 +01:00
parent 2efdcdca64
commit 09dcaae95b
10 changed files with 88 additions and 74 deletions

View File

@ -0,0 +1,7 @@
#ifndef CAMERA_INCLUDED
#define CAMERA_INCLUDED
uniform mat4 u_view; // world space -> view space
uniform mat4 u_projection; // view space -> screen space
#endif // CAMERA_INCLUDED

View File

@ -0,0 +1,20 @@
#ifndef COMMON_INCLUDED
#define COMMON_INCLUDED
layout(binding=1) uniform highp sampler2D u_height_sampler;
layout(binding=2) uniform highp sampler2D u_normal_sampler;
const vec3 c_normal_scale = vec3(2.0, 2.0, 1.0);
const vec3 c_normal_shift = vec3(-1.0, -1.0, 0.0);
const vec2 c_st_scale = vec2(1.0 / 1023.0, 1.0 / 1023.0);
const vec2 c_terrain_scale = vec2(1.0 / 2048.0, -1.0 / 2048.0);
const vec2 c_terrain_shift = vec2(0.5, 0.5);
const float c_weight_scale = 1.0 / 64.f;
const vec3 c_world_forward = vec3(0.0, 1.0, 0.0);
out vec4 v_position; // view space
out vec4 v_normal; // view space
out vec4 v_terrain_normal; // view space (x, y, z, weigth)
out vec4 v_texcoord; // texture space (s, t, pixel_level, material_level)
#endif // COMMON_INCLUDED

View File

@ -0,0 +1,10 @@
#ifndef ENVIRONMENT_INCLUDED
#define ENVIRONMENT_INCLUDED
uniform vec3 u_light_direction; // view space
uniform vec3 u_light_color;
uniform vec3 u_horizon_color;
uniform vec3 u_sky_color;
uniform vec3 u_sun_color;
#endif // ENVIRONMENT_INCLUDED

View File

@ -0,0 +1,8 @@
#ifndef VERTEX_FORMAT_INCLUDED
#define VERTEX_FORMAT_INCLUDED
layout(location = 0) in vec3 a_position; // model space
layout(location = 1) in vec3 a_normal; // model space
layout(location = 2) in vec3 a_texcoord; // texture space
#endif // VERTEX_FORMAT_INCLUDED