Bump engine submodule and move samplers bindings to shaders.

This commit is contained in:
Roz K 2022-12-31 13:42:22 +01:00
parent 6701c8dbb3
commit 2efdcdca64
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
6 changed files with 16 additions and 25 deletions

2
engine

@ -1 +1 @@
Subproject commit 2095e335ead1967fde413b0d61d35e2f3b90461a
Subproject commit ae3333e22e36667a0c02817fafb16ab7b8d1341b

View File

@ -60,21 +60,15 @@ def main():
heightmap = create_texture(
TEXTURE_FORMAT_FLOAT_32, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
generated.packed_heights)
terrain_heightmap_sampler = resolve_input(terrain_shader, b'u_height_sampler')
tests_heightmap_sampler = resolve_input(tests_shader, b'u_height_sampler')
normalmap = create_texture(
TEXTURE_FORMAT_RGB10_A2, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
generated.packed_normals)
terrain_normalmap_sampler = resolve_input(terrain_shader, b'u_normal_sampler')
tests_normalmap_sampler = resolve_input(tests_shader, b'u_normal_sampler')
print("Loading resources...")
archive = RuntimeArchive.load('data/rk_island.rkar')
print("Building tiles...")
tiles_texture = archive.get_texture('tiles')
tiles_sampler = resolve_input(terrain_shader, b'u_texture_sampler')
tiles_vertices = archive.get_vertices('tiles')
water_model = archive.get_model('water')
sand_model = archive.get_model('sand')
@ -117,7 +111,6 @@ def main():
model.spawn(terrain_batch, vec3(float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0))
tests_texture = archive.get_texture('tests')
tests_sampler = resolve_input(tests_shader, b'u_texture_sampler')
tests_vertices = archive.get_vertices('tests')
blob_model = archive.get_model('blob')
cube_model = archive.get_model('cube')
@ -136,9 +129,7 @@ def main():
sea_phase = resolve_input(sky_shader, b'u_sea_phase')
sea_polar_textures = sea.load_polar_textures(('data/sea_bump1.png', 'data/sea_bump2.png'))
sea_polar_sampler = resolve_input(sky_shader, b'u_sea_polar_sampler')
sea_detail_texture = sea.load_detail_texture('data/sea_bump.png')
sea_detail_sampler = resolve_input(sky_shader, b'u_sea_detail_sampler')
sky_triangles = create_triangles(triangles.sky_triangles(64, proj_far_z - 0.1, proj_ratio))
camera = Camera()
@ -188,9 +179,9 @@ def main():
select_shader(terrain_shader)
camera.update_inputs(terrain_camera_inputs)
environment.update_inputs(terrain_environment_inputs)
select_texture(0, tiles_texture, tiles_sampler)
select_texture(1, heightmap, terrain_heightmap_sampler)
select_texture(2, normalmap, terrain_normalmap_sampler)
select_texture(0, tiles_texture)
select_texture(1, heightmap)
select_texture(2, normalmap)
draw_begin = time.thread_time()
terrain_batch.draw()
draw_end = time.thread_time()
@ -209,9 +200,9 @@ def main():
select_shader(tests_shader)
camera.update_inputs(tests_camera_inputs)
environment.update_inputs(tests_environment_inputs)
select_texture(0, tests_texture, tests_sampler)
select_texture(1, heightmap, tests_heightmap_sampler)
select_texture(2, normalmap, tests_normalmap_sampler)
select_texture(0, tests_texture)
select_texture(1, heightmap)
select_texture(2, normalmap)
tests_batch.draw()
unselect_texture(0, tests_texture)
unselect_texture(1, heightmap)
@ -224,8 +215,8 @@ def main():
camera.update_inputs(sky_camera_inputs)
environment.update_inputs(sky_environment_inputs)
set_input_float(sea_phase, (current_time * 0.023) % 1.0)
select_texture(0, sea_polar_textures, sea_polar_sampler)
select_texture(1, sea_detail_texture, sea_detail_sampler)
select_texture(0, sea_polar_textures)
select_texture(1, sea_detail_texture)
draw_triangles(sky_triangles)
unselect_texture(0, sea_polar_textures)
unselect_texture(1, sea_detail_texture)

View File

@ -26,7 +26,7 @@ in vec4 v_texcoord; // texture space (s, t, pixel_level, material_level)
uniform vec3 u_light_direction; // view space (-direction_x, -direction_y, -direction_z)
uniform vec3 u_light_color; // (color.r * power, color.g * power, color.b * power)
uniform highp sampler2DArray u_texture_sampler;
layout(binding=0) uniform highp sampler2DArray u_texture_sampler;
layout(location = 0) out vec4 o_color;

View File

@ -31,8 +31,8 @@ uniform float u_sea_phase;
#define u_up u_view[2].xyz
#define u_origin u_view[3].xyz
uniform highp sampler2DArray u_sea_polar_sampler;
uniform highp sampler2D u_sea_detail_sampler;
layout(binding=0) uniform highp sampler2DArray u_sea_polar_sampler;
layout(binding=1) uniform highp sampler2D u_sea_detail_sampler;
const float c_sea_radius = 637.1;
const float c_sea_radius_sq = c_sea_radius * c_sea_radius;

View File

@ -25,8 +25,8 @@ layout(location = 3) in vec3 i_translation; // per mesh, model space -> world sp
uniform mat4 u_view; // world space -> view space
uniform mat4 u_projection; // view space -> screen space
uniform highp sampler2D u_height_sampler;
uniform highp sampler2D u_normal_sampler;
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);

View File

@ -26,8 +26,8 @@ layout(location = 4) in mat3 i_orientation; // per mesh, model space -> world sp
uniform mat4 u_view; // world space -> view space
uniform mat4 u_projection; // view space -> screen space
uniform highp sampler2D u_height_sampler;
uniform highp sampler2D u_normal_sampler;
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);