Remove "generate normal maps" feature (#10313)

Erase all traces of normal "generation" from fragment shaders
Remove the "feature" from the engine and default config
Remove any leftover documentation of it
This commit is contained in:
hecks 2020-09-14 19:27:25 +02:00 committed by GitHub
parent 3fb1f45301
commit fcff9f2911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 158 deletions

@ -191,15 +191,13 @@ local function formspec(tabview, name, tabdata)
.. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" .. .. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" ..
"checkbox[8.25,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";" "checkbox[8.25,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
.. dump(core.settings:get_bool("tone_mapping")) .. "]" .. .. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
"checkbox[8.25,1.5;cb_generate_normalmaps;" .. fgettext("Generate Normal Maps") .. ";" "checkbox[8.25,1.5;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
.. dump(core.settings:get_bool("generate_normalmaps")) .. "]" ..
"checkbox[8.25,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
.. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" .. .. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" ..
"checkbox[8.25,2.5;cb_waving_water;" .. fgettext("Waving Liquids") .. ";" "checkbox[8.25,2;cb_waving_water;" .. fgettext("Waving Liquids") .. ";"
.. dump(core.settings:get_bool("enable_waving_water")) .. "]" .. .. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
"checkbox[8.25,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";" "checkbox[8.25,2.5;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
.. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" .. .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
"checkbox[8.25,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";" "checkbox[8.25,3;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
.. dump(core.settings:get_bool("enable_waving_plants")) .. "]" .. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
else else
tab_string = tab_string .. tab_string = tab_string ..
@ -208,14 +206,12 @@ local function formspec(tabview, name, tabdata)
"label[8.38,1.2;" .. core.colorize("#888888", "label[8.38,1.2;" .. core.colorize("#888888",
fgettext("Tone Mapping")) .. "]" .. fgettext("Tone Mapping")) .. "]" ..
"label[8.38,1.7;" .. core.colorize("#888888", "label[8.38,1.7;" .. core.colorize("#888888",
fgettext("Generate Normal Maps")) .. "]" ..
"label[8.38,2.2;" .. core.colorize("#888888",
fgettext("Parallax Occlusion")) .. "]" .. fgettext("Parallax Occlusion")) .. "]" ..
"label[8.38,2.7;" .. core.colorize("#888888", "label[8.38,2.2;" .. core.colorize("#888888",
fgettext("Waving Liquids")) .. "]" .. fgettext("Waving Liquids")) .. "]" ..
"label[8.38,3.2;" .. core.colorize("#888888", "label[8.38,2.7;" .. core.colorize("#888888",
fgettext("Waving Leaves")) .. "]" .. fgettext("Waving Leaves")) .. "]" ..
"label[8.38,3.7;" .. core.colorize("#888888", "label[8.38,3.2;" .. core.colorize("#888888",
fgettext("Waving Plants")) .. "]" fgettext("Waving Plants")) .. "]"
end end
@ -275,10 +271,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
core.settings:set("tone_mapping", fields["cb_tonemapping"]) core.settings:set("tone_mapping", fields["cb_tonemapping"])
return true return true
end end
if fields["cb_generate_normalmaps"] then
core.settings:set("generate_normalmaps", fields["cb_generate_normalmaps"])
return true
end
if fields["cb_parallax"] then if fields["cb_parallax"] then
core.settings:set("enable_parallax_occlusion", fields["cb_parallax"]) core.settings:set("enable_parallax_occlusion", fields["cb_parallax"])
return true return true

@ -543,22 +543,10 @@ tone_mapping (Filmic tone mapping) bool false
[***Bumpmapping] [***Bumpmapping]
# Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack # Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack.
# or need to be auto-generated.
# Requires shaders to be enabled. # Requires shaders to be enabled.
enable_bumpmapping (Bumpmapping) bool false enable_bumpmapping (Bumpmapping) bool false
# Enables on the fly normalmap generation (Emboss effect).
# Requires bumpmapping to be enabled.
generate_normalmaps (Generate normalmaps) bool false
# Strength of generated normalmaps.
normalmaps_strength (Normalmaps strength) float 0.6
# Defines sampling step of texture.
# A higher value results in smoother normal maps.
normalmaps_smooth (Normalmaps sampling) int 0 0 2
[***Parallax Occlusion] [***Parallax Occlusion]
# Enables parallax occlusion mapping. # Enables parallax occlusion mapping.

@ -71,16 +71,6 @@ void get_texture_flags()
} }
} }
float intensity(vec3 color)
{
return (color.r + color.g + color.b) / 3.0;
}
float get_rgb_height(vec2 uv)
{
return intensity(texture2D(baseTexture, uv).rgb);
}
vec4 get_normal_map(vec2 uv) vec4 get_normal_map(vec2 uv)
{ {
vec4 bump = texture2D(normalTexture, uv).rgba; vec4 bump = texture2D(normalTexture, uv).rgba;
@ -115,19 +105,6 @@ float find_intersection(vec2 dp, vec2 ds)
return best_depth; return best_depth;
} }
float find_intersectionRGB(vec2 dp, vec2 ds)
{
const float depth_step = 1.0 / 24.0;
float depth = 1.0;
for (int i = 0 ; i < 24 ; i++) {
float h = get_rgb_height(dp + ds * depth);
if (h >= depth)
break;
depth -= depth_step;
}
return depth;
}
void main(void) void main(void)
{ {
vec3 color; vec3 color;
@ -149,21 +126,17 @@ void main(void)
float h = normal.a * scale - bias; float h = normal.a * scale - bias;
uv += h * normal.z * eyeRay; uv += h * normal.z * eyeRay;
} }
}
#endif #endif
#if PARALLAX_OCCLUSION_MODE == 1 #if PARALLAX_OCCLUSION_MODE == 1
// Relief mapping // Relief mapping
if (normalTexturePresent && area_enable_parallax > 0.0) { if (normalTexturePresent && area_enable_parallax > 0.0) {
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE; vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
float dist = find_intersection(uv, ds); float dist = find_intersection(uv, ds);
uv += dist * ds; uv += dist * ds;
#endif
} else if (GENERATE_NORMALMAPS == 1 && area_enable_parallax > 0.0) {
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
float dist = find_intersectionRGB(uv, ds);
uv += dist * ds;
} }
#endif #endif
#endif
#if USE_NORMALMAPS == 1 #if USE_NORMALMAPS == 1
if (normalTexturePresent) { if (normalTexturePresent) {
@ -172,22 +145,6 @@ void main(void)
} }
#endif #endif
#if GENERATE_NORMALMAPS == 1
if (normalTexturePresent == false) {
float tl = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y + SAMPLE_STEP));
float t = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y - SAMPLE_STEP));
float tr = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y + SAMPLE_STEP));
float r = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y));
float br = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y - SAMPLE_STEP));
float b = get_rgb_height(vec2(uv.x, uv.y - SAMPLE_STEP));
float bl = get_rgb_height(vec2(uv.x -SAMPLE_STEP, uv.y - SAMPLE_STEP));
float l = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y));
float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
bump = vec4(normalize(vec3 (dX, dY, NORMALMAPS_STRENGTH)), 1.0);
use_normalmap = true;
}
#endif
vec4 base = texture2D(baseTexture, uv).rgba; vec4 base = texture2D(baseTexture, uv).rgba;
#ifdef USE_DISCARD #ifdef USE_DISCARD

@ -74,20 +74,6 @@ void get_texture_flags()
} }
} }
float intensity(vec3 color)
{
return (color.r + color.g + color.b) / 3.0;
}
float get_rgb_height(vec2 uv)
{
if (texSeamless) {
return intensity(texture2D(baseTexture, uv).rgb);
} else {
return intensity(texture2D(baseTexture, clamp(uv, 0.0, 0.999)).rgb);
}
}
vec4 get_normal_map(vec2 uv) vec4 get_normal_map(vec2 uv)
{ {
vec4 bump = texture2D(normalTexture, uv).rgba; vec4 bump = texture2D(normalTexture, uv).rgba;
@ -110,23 +96,6 @@ void main(void)
} }
#endif #endif
#if GENERATE_NORMALMAPS == 1
if (normalTexturePresent == false) {
float tl = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y + SAMPLE_STEP));
float t = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y - SAMPLE_STEP));
float tr = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y + SAMPLE_STEP));
float r = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y));
float br = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y - SAMPLE_STEP));
float b = get_rgb_height(vec2(uv.x, uv.y - SAMPLE_STEP));
float bl = get_rgb_height(vec2(uv.x -SAMPLE_STEP, uv.y - SAMPLE_STEP));
float l = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y));
float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
bump = vec4(normalize(vec3 (dX, dY, NORMALMAPS_STRENGTH)), 1.0);
use_normalmap = true;
}
#endif
vec4 base = texture2D(baseTexture, uv).rgba; vec4 base = texture2D(baseTexture, uv).rgba;
#ifdef USE_DISCARD #ifdef USE_DISCARD

@ -604,26 +604,11 @@
#### Bumpmapping #### Bumpmapping
# Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack # Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack.
# or need to be auto-generated.
# Requires shaders to be enabled. # Requires shaders to be enabled.
# type: bool # type: bool
# enable_bumpmapping = false # enable_bumpmapping = false
# Enables on the fly normalmap generation (Emboss effect).
# Requires bumpmapping to be enabled.
# type: bool
# generate_normalmaps = false
# Strength of generated normalmaps.
# type: float
# normalmaps_strength = 0.6
# Defines sampling step of texture.
# A higher value results in smoother normal maps.
# type: int min: 0 max: 2
# normalmaps_smooth = 0
#### Parallax Occlusion #### Parallax Occlusion
# Enables parallax occlusion mapping. # Enables parallax occlusion mapping.

@ -688,34 +688,6 @@ ShaderInfo generate_shader(const std::string &name, u8 material_type, u8 drawtyp
shaders_header += itos(drawtype); shaders_header += itos(drawtype);
shaders_header += "\n"; shaders_header += "\n";
if (g_settings->getBool("generate_normalmaps")) {
shaders_header += "#define GENERATE_NORMALMAPS 1\n";
} else {
shaders_header += "#define GENERATE_NORMALMAPS 0\n";
}
shaders_header += "#define NORMALMAPS_STRENGTH ";
shaders_header += ftos(g_settings->getFloat("normalmaps_strength"));
shaders_header += "\n";
float sample_step;
int smooth = (int)g_settings->getFloat("normalmaps_smooth");
switch (smooth){
case 0:
sample_step = 0.0078125; // 1.0 / 128.0
break;
case 1:
sample_step = 0.00390625; // 1.0 / 256.0
break;
case 2:
sample_step = 0.001953125; // 1.0 / 512.0
break;
default:
sample_step = 0.0078125;
break;
}
shaders_header += "#define SAMPLE_STEP ";
shaders_header += ftos(sample_step);
shaders_header += "\n";
if (g_settings->getBool("enable_bumpmapping")) if (g_settings->getBool("enable_bumpmapping"))
shaders_header += "#define ENABLE_BUMPMAPPING\n"; shaders_header += "#define ENABLE_BUMPMAPPING\n";

@ -253,9 +253,6 @@ void set_default_settings(Settings *settings)
settings->setDefault("tone_mapping", "false"); settings->setDefault("tone_mapping", "false");
settings->setDefault("enable_bumpmapping", "false"); settings->setDefault("enable_bumpmapping", "false");
settings->setDefault("enable_parallax_occlusion", "false"); settings->setDefault("enable_parallax_occlusion", "false");
settings->setDefault("generate_normalmaps", "false");
settings->setDefault("normalmaps_strength", "0.6");
settings->setDefault("normalmaps_smooth", "1");
settings->setDefault("parallax_occlusion_mode", "1"); settings->setDefault("parallax_occlusion_mode", "1");
settings->setDefault("parallax_occlusion_iterations", "4"); settings->setDefault("parallax_occlusion_iterations", "4");
settings->setDefault("parallax_occlusion_scale", "0.08"); settings->setDefault("parallax_occlusion_scale", "0.08");

@ -242,13 +242,7 @@ fake_function() {
gettext("Enables Hable's 'Uncharted 2' filmic tone mapping.\nSimulates the tone curve of photographic film and how this approximates the\nappearance of high dynamic range images. Mid-range contrast is slightly\nenhanced, highlights and shadows are gradually compressed."); gettext("Enables Hable's 'Uncharted 2' filmic tone mapping.\nSimulates the tone curve of photographic film and how this approximates the\nappearance of high dynamic range images. Mid-range contrast is slightly\nenhanced, highlights and shadows are gradually compressed.");
gettext("Bumpmapping"); gettext("Bumpmapping");
gettext("Bumpmapping"); gettext("Bumpmapping");
gettext("Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack\nor need to be auto-generated.\nRequires shaders to be enabled."); gettext("Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack.\nRequires shaders to be enabled.");
gettext("Generate normalmaps");
gettext("Enables on the fly normalmap generation (Emboss effect).\nRequires bumpmapping to be enabled.");
gettext("Normalmaps strength");
gettext("Strength of generated normalmaps.");
gettext("Normalmaps sampling");
gettext("Defines sampling step of texture.\nA higher value results in smoother normal maps.");
gettext("Parallax Occlusion"); gettext("Parallax Occlusion");
gettext("Parallax occlusion"); gettext("Parallax occlusion");
gettext("Enables parallax occlusion mapping.\nRequires shaders to be enabled."); gettext("Enables parallax occlusion mapping.\nRequires shaders to be enabled.");