From fc13d6c2a9bc724409fe4b2c88d4d1e1e2b90dd8 Mon Sep 17 00:00:00 2001 From: milek7 Date: Fri, 27 Sep 2019 20:07:52 +0200 Subject: [PATCH] gfx.extraeffects setting, parallax shader changes --- Globals.cpp | 5 +++++ Globals.h | 1 + gl/glsl_common.cpp | 1 + shaders/mat_parallax.frag | 16 +++++++++------- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Globals.cpp b/Globals.cpp index 022f1765..b7aa7533 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -827,6 +827,11 @@ global_settings::ConfigParse(cParser &Parser) { Parser.getTokens(1); Parser >> gfx_skippipeline; } + else if (token == "gfx.extraeffects") + { + Parser.getTokens(1); + Parser >> gfx_extraeffects; + } else if (token == "gfx.usegles") { Parser.getTokens(1); diff --git a/Globals.h b/Globals.h index 8dade0df..084d0ba2 100644 --- a/Globals.h +++ b/Globals.h @@ -219,6 +219,7 @@ struct global_settings { GLenum gfx_format_color = GL_RGB16F; GLenum gfx_format_depth = GL_DEPTH_COMPONENT32F; bool gfx_skippipeline = false; + bool gfx_extraeffects = true; bool gfx_shadergamma = false; bool gfx_usegles = false; diff --git a/gl/glsl_common.cpp b/gl/glsl_common.cpp index 7ebbcce6..4215a475 100644 --- a/gl/glsl_common.cpp +++ b/gl/glsl_common.cpp @@ -10,6 +10,7 @@ void gl::glsl_common_setup() "#define ENVMAP_ENABLED " + std::to_string((int)Global.gfx_envmap_enabled) + "\n" + "#define MOTIONBLUR_ENABLED " + std::to_string((int)Global.gfx_postfx_motionblur_enabled) + "\n" + "#define POSTFX_ENABLED " + std::to_string((int)!Global.gfx_skippipeline) + "\n" + + "#define EXTRAEFFECTS_ENABLED " + std::to_string((int)Global.gfx_extraeffects) + "\n" + "#define USE_GLES " + std::to_string((int)Global.gfx_usegles) + "\n" + "const uint MAX_LIGHTS = " + std::to_string(MAX_LIGHTS) + "U;\n" + "const uint MAX_PARAMS = " + std::to_string(MAX_PARAMS) + "U;\n" + diff --git a/shaders/mat_parallax.frag b/shaders/mat_parallax.frag index 55b18e57..0121f5bc 100644 --- a/shaders/mat_parallax.frag +++ b/shaders/mat_parallax.frag @@ -104,14 +104,16 @@ void main() } vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir) { -#if ENVMAP_ENABLED + float pos_len = length(f_pos.xyz); + + if (pos_len > 100.0) { + return f_coord; + } + +#if EXTRAEFFECTS_ENABLED const float minLayers = 8.0; const float maxLayers = 32.0; - float LayersWeight = 1.0; - if (length(f_pos.xyz) > 20.0) - LayersWeight = 1.0; - else - LayersWeight = (length(f_pos.xyz) / 20.0); + float LayersWeight = pos_len / 20.0; vec2 currentTexCoords = f_coord; float currentDepthMapValue = texture(normalmap, currentTexCoords).b; LayersWeight = min(abs(dot(vec3(0.0, 0.0, 1.0), viewDir)),LayersWeight); @@ -140,7 +142,7 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir) return finalTexCoords; #else float height = texture(normalmap, f_coord).b; - vec2 p = viewDir.xy / viewDir.z * (height * param[2].y - param[2].z); + vec2 p = viewDir.xy / viewDir.z * (height * (param[2].y - param[2].z) * 0.2); return f_coord - p; #endif }