Skip to content

Commit

Permalink
Generate mipmaps for colormap, and set filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Dec 15, 2023
1 parent 71a465f commit 7e4f9eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/shaders/main.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ uniform int _region_map[256];
uniform vec2 _region_offsets[256];
uniform sampler2DArray _height_maps : repeat_disable;
uniform usampler2DArray _control_maps : repeat_disable;
uniform sampler2DArray _color_maps : source_color, repeat_disable;
//INSERT: TEXTURE_SAMPLERS_NEAREST
//INSERT: TEXTURE_SAMPLERS_LINEAR
uniform float _texture_uv_scale_array[32];
Expand Down
4 changes: 3 additions & 1 deletion src/shaders/uniforms.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
R"(

//INSERT: TEXTURE_SAMPLERS_LINEAR
uniform sampler2DArray _color_maps : source_color, filter_linear_mipmap_anisotropic, repeat_disable;
uniform sampler2DArray _texture_array_albedo : source_color, filter_linear_mipmap_anisotropic, repeat_enable;
uniform sampler2DArray _texture_array_normal : hint_normal, filter_linear_mipmap_anisotropic, repeat_enable;
uniform sampler2D noise_texture : source_color, filter_linear_mipmap_anisotropic, repeat_enable;

//INSERT: TEXTURE_SAMPLERS_NEAREST
uniform sampler2DArray _color_maps : source_color, filter_nearest_mipmap_anisotropic, repeat_disable;
uniform sampler2DArray _texture_array_albedo : source_color, filter_nearest_mipmap_anisotropic, repeat_enable;
uniform sampler2DArray _texture_array_normal : hint_normal, filter_nearest_mipmap_anisotropic, repeat_enable;
uniform sampler2D noise_texture : source_color, filter_nearest, repeat_enable;
uniform sampler2D noise_texture : source_color, filter_nearest_mipmap_anisotropic, repeat_enable;

)"
6 changes: 6 additions & 0 deletions src/terrain_3d_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ void Terrain3DStorage::update_regions(bool force_emit) {

if (_generated_color_maps.is_dirty()) {
LOG(DEBUG_CONT, "Regenerating color layered texture from ", _color_maps.size(), " maps");
for (int i = 0; i < _color_maps.size(); i++) {
Ref<Image> map = _color_maps[i];
if (!map->has_mipmaps()) {
map->generate_mipmaps();
}
}
_generated_color_maps.create(_color_maps);
force_emit = true;
_modified = true;
Expand Down

0 comments on commit 7e4f9eb

Please sign in to comment.