diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index ee737311f5b3..b98dda6aa7c3 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -1160,6 +1160,9 @@ def factor_but(layout, toggle, factor, name): col = split.column() factor_but(col, "use_map_zenith_up", "zenith_up_factor", "Zenith Up") factor_but(col, "use_map_zenith_down", "zenith_down_factor", "Zenith Down") + + col = split.column() + col.prop(tex, "lod_bias") elif isinstance(idblock, ParticleSettings): split = layout.split() diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 32add5122958..18ddb127437c 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -2090,16 +2090,16 @@ static void do_world_tex(GPUShadeInput *shi, struct World *wo, GPUNodeLink **hor if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f) GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco); if (mtex->texco == TEXCO_EQUIRECTMAP) { - GPU_link(mat, "node_tex_environment_equirectangular", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb); + GPU_link(mat, "node_tex_environment_equirectangular", texco, GPU_image(tex->ima, &tex->iuser, false), GPU_uniform(&mtex->lodbias), &trgb); } else if (mtex->texco == TEXCO_ANGMAP) { - GPU_link(mat, "node_tex_environment_mirror_ball", texco, GPU_image(tex->ima, &tex->iuser, false), &trgb); + GPU_link(mat, "node_tex_environment_mirror_ball", texco, GPU_image(tex->ima, &tex->iuser, false), GPU_uniform(&mtex->lodbias), &trgb); } else { if (tex->type == TEX_ENVMAP) - GPU_link(mat, "mtex_cube_map", texco, GPU_cube_map(tex->ima, &tex->iuser, false), GPU_uniform(&zero), &tin, &trgb); + GPU_link(mat, "mtex_cube_map", texco, GPU_cube_map(tex->ima, &tex->iuser, false), GPU_uniform(&mtex->lodbias), &tin, &trgb); else if (tex->type == TEX_IMAGE) - GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), GPU_uniform(&zero), &tin, &trgb); + GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser, false), GPU_uniform(&mtex->lodbias), &tin, &trgb); } rgbnor = TEX_RGB; if (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 38c69ab6638e..9692d986de60 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2940,16 +2940,16 @@ void node_tex_clouds(vec3 co, float size, out vec4 color, out float fac) fac = 1.0; } -void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color) +void node_tex_environment_equirectangular(vec3 co, sampler2D ima, float lodbias, out vec4 color) { vec3 nco = normalize(co); float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5; float v = atan(nco.z, hypot(nco.x, nco.y)) / M_PI + 0.5; - color = texture2D(ima, vec2(u, v)); + color = texture2D(ima, vec2(u, v), lodbias); } -void node_tex_environment_mirror_ball(vec3 co, sampler2D ima, out vec4 color) +void node_tex_environment_mirror_ball(vec3 co, sampler2D ima, float lodbias, out vec4 color) { vec3 nco = normalize(co); @@ -2962,7 +2962,7 @@ void node_tex_environment_mirror_ball(vec3 co, sampler2D ima, out vec4 color) float u = 0.5 * (nco.x + 1.0); float v = 0.5 * (nco.z + 1.0); - color = texture2D(ima, vec2(u, v)); + color = texture2D(ima, vec2(u, v), lodbias); } void node_tex_environment_empty(vec3 co, out vec4 color) diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 7c1ef6b0d87b..984aad3507d5 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -164,6 +164,12 @@ static void rna_def_world_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Zenith Down", "Affect the color of the zenith below"); RNA_def_property_update(prop, 0, "rna_World_update"); + prop = RNA_def_property(srna, "lod_bias", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "lodbias"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 10, 3); + RNA_def_property_ui_text(prop, "Lod Bias", "Amount bias on mipmapping"); + RNA_def_property_update(prop, 0, "rna_World_update"); + prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "texco"); RNA_def_property_enum_items(prop, texco_items);