Compare commits

...

2 Commits

Author SHA1 Message Date
7c1f85e03f
Cleanup: some renaming. 2022-12-20 09:00:45 +01:00
0e6183011e
Bump engine submodule. 2022-12-20 08:43:00 +01:00
2 changed files with 35 additions and 36 deletions

2
engine

@ -1 +1 @@
Subproject commit ddb9b0598f182ad84ef3f5501ac3934eb7959578 Subproject commit eaff99a5b61355f2c6fa138eb54feb654ba24e78

View File

@ -71,13 +71,13 @@ def main():
tiles_texture = archive.get_texture('tiles') tiles_texture = archive.get_texture('tiles')
tiles_sampler = resolve_input(terrain_shader, b'u_texture_sampler') tiles_sampler = resolve_input(terrain_shader, b'u_texture_sampler')
tiles_vertices = archive.get_vertices('tiles') tiles_vertices = archive.get_vertices('tiles')
water = archive.get_model('water') water_model = archive.get_model('water')
sand = archive.get_model('sand') sand_model = archive.get_model('sand')
grass = archive.get_model('grass') grass_model = archive.get_model('grass')
forest = archive.get_model('forest') forest_model = archive.get_model('forest')
rock = archive.get_model('rock') rock_model = archive.get_model('rock')
mud = archive.get_model('mud') mud_model = archive.get_model('mud')
lava = archive.get_model('lava') lava_model = archive.get_model('lava')
terrain_batch = batch.Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT)) terrain_batch = batch.Batch(tiles_vertices, generated.size ** 2, params_format(PARAM_FORMAT_VEC3_SHORT))
#TODO: generator & for real #TODO: generator & for real
@ -90,42 +90,40 @@ def main():
if h == 0.0: if h == 0.0:
continue continue
if r > 0.0: if r > 0.0:
model = water model = water_model
elif h < 2.0: elif h < 2.0:
model = sand model = sand_model
elif h < 180: elif h < 180:
if nz > 0.9: if nz > 0.9:
if ny < -0.01 and nz > 0.93: if ny < -0.01 and nz > 0.93:
model = forest model = forest_model
else: else:
model = grass model = grass_model
else: else:
model = rock model = rock_model
elif vd < vr - 3.0 and nz > 0.999: elif vd < vr - 3.0 and nz > 0.999:
model = lava model = lava_model
elif vd < vr + 2.0: elif vd < vr + 2.0:
model = mud model = mud_model
elif vd < vr + 6.0 and nz < 0.67: elif vd < vr + 6.0 and nz < 0.67:
model = mud model = mud_model
else: else:
model = rock model = rock_model
model.spawn(terrain_batch, (float(((mx - 128) * 8) + 4), float(((127 - my) * 8) + 4), 0.0)) model.spawn(terrain_batch, (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_sampler = resolve_input(tests_shader, b'u_texture_sampler')
tests_vertices = archive.get_vertices('tests') tests_vertices = archive.get_vertices('tests')
blob = archive.get_model('blob') blob_model = archive.get_model('blob')
cube = archive.get_model('cube') cube_model = archive.get_model('cube')
clouds = archive.get_model('clouds') clouds_model = archive.get_model('clouds')
tests_batch = batch.Batch(tests_vertices, 3, tests_batch = batch.Batch(tests_vertices, 3,
params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE)) params_format(PARAM_FORMAT_VEC3_FLOAT, PARAM_FORMAT_VEC3_INT10 | PARAM_FORMAT_NORMALIZE))
blob_translation = vec3((-100.0, -500.0, 0.0)) blob_spawn_translation = vec3((-100.0, -500.0, 0.0))
cube_translation = vec3((100.0, -500.0, 0.0)) cube_spawn_translation = vec3((100.0, -500.0, 0.0))
cube_orientation = vec3(vec3_forward) blob_id = blob_model.spawn(tests_batch, blob_spawn_translation, vec3_forward)
clouds_orientation = vec3(vec3_forward) cube_id = cube_model.spawn(tests_batch, cube_spawn_translation, vec3_forward)
blob_id = blob.spawn(tests_batch, blob_translation, vec3_forward) clouds_id = clouds_model.spawn(tests_batch, (0.0, 0.0, 32.0), vec3_forward)
cube_id = cube.spawn(tests_batch, cube_translation, cube_orientation)
clouds_id = clouds.spawn(tests_batch, (0.0, 0.0, 32.0), clouds_orientation)
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'))
@ -145,7 +143,8 @@ def main():
tests_environment_inputs = environment.resolve_inputs(tests_shader) tests_environment_inputs = environment.resolve_inputs(tests_shader)
sky_environment_inputs = environment.resolve_inputs(sky_shader) sky_environment_inputs = environment.resolve_inputs(sky_shader)
up = vec3(vec3_up) _forward = vec3(vec3_forward)
_up = vec3(vec3_up)
_rotation = mat3() _rotation = mat3()
_origin = vec3() _origin = vec3()
_lookat = vec3() _lookat = vec3()
@ -171,20 +170,20 @@ def main():
begin_frame() begin_frame()
frame_begin = time.thread_time() frame_begin = time.thread_time()
mat3_rotation(_rotation, up, (current_time * 0.21) % tau) mat3_rotation(_rotation, _up, (current_time * 0.21) % tau)
mat3_mul_vec3(_blob_translation, _rotation, blob_translation) mat3_mul_vec3(_blob_translation, _rotation, blob_spawn_translation)
tests_batch.set_param(0, blob_id, _blob_translation) tests_batch.set_param(0, blob_id, _blob_translation)
tests_batch.set_param(1, blob_id, vec3(math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0)))) tests_batch.set_param(1, blob_id, vec3(math.vec3_normalize((sun_direction[0], sun_direction[1], 0.0))))
mat3_mul_vec3(_cube_translation, _rotation, cube_translation) mat3_mul_vec3(_cube_translation, _rotation, cube_spawn_translation)
tests_batch.set_param(0, cube_id, _cube_translation) tests_batch.set_param(0, cube_id, _cube_translation)
mat3_rotation(_rotation, up, (current_time * 0.43) % tau) mat3_rotation(_rotation, _up, (current_time * 0.43) % tau)
mat3_mul_vec3(_cube_orientation, _rotation, cube_orientation) mat3_mul_vec3(_cube_orientation, _rotation, _forward)
tests_batch.set_param(1, cube_id, _cube_orientation) tests_batch.set_param(1, cube_id, _cube_orientation)
mat3_rotation(_rotation, up, (current_time * -0.037) % tau) mat3_rotation(_rotation, _up, (current_time * -0.037) % tau)
mat3_mul_vec3(_clouds_orientation, _rotation, clouds_orientation) mat3_mul_vec3(_clouds_orientation, _rotation, _forward)
tests_batch.set_param(1, clouds_id, _clouds_orientation) tests_batch.set_param(1, clouds_id, _clouds_orientation)
mat3_rotation(_rotation, up, (current_time * 0.05) % tau) mat3_rotation(_rotation, _up, (current_time * 0.05) % tau)
mat3_mul_vec3(_origin, _rotation, vec3(camera_origin)) mat3_mul_vec3(_origin, _rotation, vec3(camera_origin))
mat3_mul_vec3(_lookat, _rotation, vec3(camera_lookat)) mat3_mul_vec3(_lookat, _rotation, vec3(camera_lookat))
camera.set_view(_origin, _lookat) camera.set_view(_origin, _lookat)