From d9552f7ff432a7a9f8a731916820a4354f1968f0 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 19 Jan 2023 21:59:02 +0000 Subject: [PATCH] Added support for glowing sprites --- assets/voxygen/shaders/include/srgb.glsl | 6 ------ assets/voxygen/shaders/sprite-frag.glsl | 10 +++++++++- assets/voxygen/voxel/sprite/lantern/lantern-orange.vox | 4 ++-- assets/voxygen/voxel/sprite_manifest.ron | 4 ++-- voxygen/src/mesh/segment.rs | 6 ++++-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/assets/voxygen/shaders/include/srgb.glsl b/assets/voxygen/shaders/include/srgb.glsl index c7047404ad..b1abd93811 100644 --- a/assets/voxygen/shaders/include/srgb.glsl +++ b/assets/voxygen/shaders/include/srgb.glsl @@ -656,12 +656,6 @@ vec3 greedy_extract_col_light_terrain(texture2D t_col_light, sampler s_col_light return greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_light, f_glow, f_ao, _f_attr, f_sky_exposure); } -vec3 greedy_extract_col_light_sprite(texture2D t_col_light, sampler s_col_light, vec2 f_uv_pos, out float f_light) { - float _f_sky_exposure, _f_light, _f_glow, _f_ao; - uint _f_attr; - return greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_light, _f_glow, _f_ao, _f_attr, _f_sky_exposure); -} - vec3 greedy_extract_col_light_figure(texture2D t_col_light, sampler s_col_light, vec2 f_uv_pos, out float f_light, out uint f_attr) { float _f_sky_exposure, _f_light, _f_glow, _f_ao; return greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_light, _f_glow, _f_ao, f_attr, _f_sky_exposure); diff --git a/assets/voxygen/shaders/sprite-frag.glsl b/assets/voxygen/shaders/sprite-frag.glsl index 5faaaff6e9..3c68424396 100644 --- a/assets/voxygen/shaders/sprite-frag.glsl +++ b/assets/voxygen/shaders/sprite-frag.glsl @@ -42,7 +42,8 @@ const float FADE_DIST = 32.0; void main() { float f_ao; - vec3 f_col = greedy_extract_col_light_sprite(t_col_light, s_col_light, f_uv_pos, f_ao); + uint material = 0xFFu; + vec3 f_col = greedy_extract_col_light_figure(t_col_light, s_col_light, f_uv_pos, f_ao, material); #ifdef EXPERIMENTAL_BAREMINIMUM tgt_color = vec4(simple_lighting(f_pos.xyz, f_col, f_ao), 1); @@ -124,6 +125,13 @@ void main() { reflected_light *= point_shadow; emitted_light *= point_shadow; + // Apply emissive glow + // For now, just make glowing material light be the same colour as the surface + // TODO: Add a way to control this better outside the shaders + if ((material & (1u << 0u)) > 0u) { + emitted_light += 20 * surf_color; + } + surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light); surf_color += f_select * (surf_color + 0.1) * vec3(0.15, 0.15, 0.15); diff --git a/assets/voxygen/voxel/sprite/lantern/lantern-orange.vox b/assets/voxygen/voxel/sprite/lantern/lantern-orange.vox index 104ccaec39..f06d64aa8a 100644 --- a/assets/voxygen/voxel/sprite/lantern/lantern-orange.vox +++ b/assets/voxygen/voxel/sprite/lantern/lantern-orange.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:267dad1374260e2e072027ba005389ba66082f74e7c8ba64a83bb58d41a04fc3 -size 1860 +oid sha256:c683911a904f82e837314d06855bd8ca3758e552947b6dde45429f1aa7e1c2ff +size 2180 diff --git a/assets/voxygen/voxel/sprite_manifest.ron b/assets/voxygen/voxel/sprite_manifest.ron index 46e459826e..c51d53affb 100644 --- a/assets/voxygen/voxel/sprite_manifest.ron +++ b/assets/voxygen/voxel/sprite_manifest.ron @@ -3468,8 +3468,8 @@ Lantern: Some(( variations: [ ( model: "voxygen.voxel.sprite.lantern.lantern-orange", - offset: (-2.5, -2.5, 0.0), - lod_axes: (0.0, 0.0, 0.0), + offset: (-3.0, -3.0, 0.0), + lod_axes: (0.5, 0.5, 0.2), ), ], wind_sway: 0.0, diff --git a/voxygen/src/mesh/segment.rs b/voxygen/src/mesh/segment.rs index 37dd3c28ff..49d59a630f 100644 --- a/voxygen/src/mesh/segment.rs +++ b/voxygen/src/mesh/segment.rs @@ -236,8 +236,10 @@ where |atlas_pos, pos, norm, &meta| create_opaque(atlas_pos, pos, norm, meta), )); }, - make_face_texel: move |flat: &mut _, pos, light, glow, ao| { - TerrainVertex::make_col_light(light, glow, get_color(flat, pos), ao) + make_face_texel: move |flat: &mut _, pos, light, _glow, _ao| { + let cell = flat_get(flat, pos); + let (glowy, shiny) = (cell.is_glowy(), cell.is_shiny()); + TerrainVertex::make_col_light_figure(light, glowy, shiny, get_color(flat, pos)) }, });