Bump engine submodule and move samplers bindings to shaders.
This commit is contained in:
		
							
								
								
									
										2
									
								
								engine
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								engine
									
									
									
									
									
								
							 Submodule engine updated: 2095e335ea...ae3333e22e
									
								
							
							
								
								
									
										25
									
								
								game/game.py
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								game/game.py
									
									
									
									
									
								
							@ -60,21 +60,15 @@ def main():
 | 
				
			|||||||
    heightmap = create_texture(
 | 
					    heightmap = create_texture(
 | 
				
			||||||
        TEXTURE_FORMAT_FLOAT_32, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
 | 
					        TEXTURE_FORMAT_FLOAT_32, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
 | 
				
			||||||
        generated.packed_heights)
 | 
					        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(
 | 
					    normalmap = create_texture(
 | 
				
			||||||
        TEXTURE_FORMAT_RGB10_A2, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
 | 
					        TEXTURE_FORMAT_RGB10_A2, 256, 256, 0, TEXTURE_FLAG_MIN_LINEAR | TEXTURE_FLAG_MAG_LINEAR,
 | 
				
			||||||
        generated.packed_normals)
 | 
					        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...")
 | 
					    print("Loading resources...")
 | 
				
			||||||
    archive = RuntimeArchive.load('data/rk_island.rkar')
 | 
					    archive = RuntimeArchive.load('data/rk_island.rkar')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print("Building tiles...")
 | 
					    print("Building tiles...")
 | 
				
			||||||
    tiles_texture = archive.get_texture('tiles')
 | 
					    tiles_texture = archive.get_texture('tiles')
 | 
				
			||||||
    tiles_sampler = resolve_input(terrain_shader, b'u_texture_sampler')
 | 
					 | 
				
			||||||
    tiles_vertices = archive.get_vertices('tiles')
 | 
					    tiles_vertices = archive.get_vertices('tiles')
 | 
				
			||||||
    water_model = archive.get_model('water')
 | 
					    water_model = archive.get_model('water')
 | 
				
			||||||
    sand_model = archive.get_model('sand')
 | 
					    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))
 | 
					        model.spawn(terrain_batch, vec3(float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tests_texture = archive.get_texture('tests')
 | 
					    tests_texture = archive.get_texture('tests')
 | 
				
			||||||
    tests_sampler = resolve_input(tests_shader, b'u_texture_sampler')
 | 
					 | 
				
			||||||
    tests_vertices = archive.get_vertices('tests')
 | 
					    tests_vertices = archive.get_vertices('tests')
 | 
				
			||||||
    blob_model = archive.get_model('blob')
 | 
					    blob_model = archive.get_model('blob')
 | 
				
			||||||
    cube_model = archive.get_model('cube')
 | 
					    cube_model = archive.get_model('cube')
 | 
				
			||||||
@ -136,9 +129,7 @@ def main():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    sea_phase = resolve_input(sky_shader, b'u_sea_phase')
 | 
					    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_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_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))
 | 
					    sky_triangles = create_triangles(triangles.sky_triangles(64, proj_far_z - 0.1, proj_ratio))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    camera = Camera()
 | 
					    camera = Camera()
 | 
				
			||||||
@ -188,9 +179,9 @@ def main():
 | 
				
			|||||||
            select_shader(terrain_shader)
 | 
					            select_shader(terrain_shader)
 | 
				
			||||||
            camera.update_inputs(terrain_camera_inputs)
 | 
					            camera.update_inputs(terrain_camera_inputs)
 | 
				
			||||||
            environment.update_inputs(terrain_environment_inputs)
 | 
					            environment.update_inputs(terrain_environment_inputs)
 | 
				
			||||||
            select_texture(0, tiles_texture, tiles_sampler)
 | 
					            select_texture(0, tiles_texture)
 | 
				
			||||||
            select_texture(1, heightmap, terrain_heightmap_sampler)
 | 
					            select_texture(1, heightmap)
 | 
				
			||||||
            select_texture(2, normalmap, terrain_normalmap_sampler)
 | 
					            select_texture(2, normalmap)
 | 
				
			||||||
            draw_begin = time.thread_time()
 | 
					            draw_begin = time.thread_time()
 | 
				
			||||||
            terrain_batch.draw()
 | 
					            terrain_batch.draw()
 | 
				
			||||||
            draw_end = time.thread_time()
 | 
					            draw_end = time.thread_time()
 | 
				
			||||||
@ -209,9 +200,9 @@ def main():
 | 
				
			|||||||
            select_shader(tests_shader)
 | 
					            select_shader(tests_shader)
 | 
				
			||||||
            camera.update_inputs(tests_camera_inputs)
 | 
					            camera.update_inputs(tests_camera_inputs)
 | 
				
			||||||
            environment.update_inputs(tests_environment_inputs)
 | 
					            environment.update_inputs(tests_environment_inputs)
 | 
				
			||||||
            select_texture(0, tests_texture, tests_sampler)
 | 
					            select_texture(0, tests_texture)
 | 
				
			||||||
            select_texture(1, heightmap, tests_heightmap_sampler)
 | 
					            select_texture(1, heightmap)
 | 
				
			||||||
            select_texture(2, normalmap, tests_normalmap_sampler)
 | 
					            select_texture(2, normalmap)
 | 
				
			||||||
            tests_batch.draw()
 | 
					            tests_batch.draw()
 | 
				
			||||||
            unselect_texture(0, tests_texture)
 | 
					            unselect_texture(0, tests_texture)
 | 
				
			||||||
            unselect_texture(1, heightmap)
 | 
					            unselect_texture(1, heightmap)
 | 
				
			||||||
@ -224,8 +215,8 @@ def main():
 | 
				
			|||||||
            camera.update_inputs(sky_camera_inputs)
 | 
					            camera.update_inputs(sky_camera_inputs)
 | 
				
			||||||
            environment.update_inputs(sky_environment_inputs)
 | 
					            environment.update_inputs(sky_environment_inputs)
 | 
				
			||||||
            set_input_float(sea_phase, (current_time * 0.023) % 1.0)
 | 
					            set_input_float(sea_phase, (current_time * 0.023) % 1.0)
 | 
				
			||||||
            select_texture(0, sea_polar_textures, sea_polar_sampler)
 | 
					            select_texture(0, sea_polar_textures)
 | 
				
			||||||
            select_texture(1, sea_detail_texture, sea_detail_sampler)
 | 
					            select_texture(1, sea_detail_texture)
 | 
				
			||||||
            draw_triangles(sky_triangles)
 | 
					            draw_triangles(sky_triangles)
 | 
				
			||||||
            unselect_texture(0, sea_polar_textures)
 | 
					            unselect_texture(0, sea_polar_textures)
 | 
				
			||||||
            unselect_texture(1, sea_detail_texture)
 | 
					            unselect_texture(1, sea_detail_texture)
 | 
				
			||||||
 | 
				
			|||||||
@ -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_direction; // view space (-direction_x, -direction_y, -direction_z)
 | 
				
			||||||
uniform vec3 u_light_color; // (color.r * power, color.g * power, color.b * power)
 | 
					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;
 | 
					layout(location = 0) out vec4 o_color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -31,8 +31,8 @@ uniform float u_sea_phase;
 | 
				
			|||||||
#define u_up u_view[2].xyz
 | 
					#define u_up u_view[2].xyz
 | 
				
			||||||
#define u_origin u_view[3].xyz
 | 
					#define u_origin u_view[3].xyz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uniform highp sampler2DArray u_sea_polar_sampler;
 | 
					layout(binding=0) uniform highp sampler2DArray u_sea_polar_sampler;
 | 
				
			||||||
uniform highp sampler2D u_sea_detail_sampler;
 | 
					layout(binding=1) uniform highp sampler2D u_sea_detail_sampler;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const float c_sea_radius = 637.1;
 | 
					const float c_sea_radius = 637.1;
 | 
				
			||||||
const float c_sea_radius_sq = c_sea_radius * c_sea_radius;
 | 
					const float c_sea_radius_sq = c_sea_radius * c_sea_radius;
 | 
				
			||||||
 | 
				
			|||||||
@ -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_view; // world space -> view space
 | 
				
			||||||
uniform mat4 u_projection; // view space -> screen space
 | 
					uniform mat4 u_projection; // view space -> screen space
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uniform highp sampler2D u_height_sampler;
 | 
					layout(binding=1) uniform highp sampler2D u_height_sampler;
 | 
				
			||||||
uniform highp sampler2D u_normal_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_scale = vec3(2.0, 2.0, 1.0);
 | 
				
			||||||
const vec3 c_normal_shift = vec3(-1.0, -1.0, 0.0);
 | 
					const vec3 c_normal_shift = vec3(-1.0, -1.0, 0.0);
 | 
				
			||||||
 | 
				
			|||||||
@ -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_view; // world space -> view space
 | 
				
			||||||
uniform mat4 u_projection; // view space -> screen space
 | 
					uniform mat4 u_projection; // view space -> screen space
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uniform highp sampler2D u_height_sampler;
 | 
					layout(binding=1) uniform highp sampler2D u_height_sampler;
 | 
				
			||||||
uniform highp sampler2D u_normal_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_scale = vec3(2.0, 2.0, 1.0);
 | 
				
			||||||
const vec3 c_normal_shift = vec3(-1.0, -1.0, 0.0);
 | 
					const vec3 c_normal_shift = vec3(-1.0, -1.0, 0.0);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user