From dc219205cb99203d3933343b9d968ce7fd2edbab Mon Sep 17 00:00:00 2001 From: Cory Petkovsek <632766+TokisanGames@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:03:51 +0700 Subject: [PATCH] Revert FMA usage in shader to fix compatibility mode --- src/shaders/main.glsl | 2 +- src/shaders/world_noise.glsl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shaders/main.glsl b/src/shaders/main.glsl index 991ddf9e0..9add592d8 100644 --- a/src/shaders/main.glsl +++ b/src/shaders/main.glsl @@ -222,7 +222,7 @@ vec4 height_blend(vec4 a_value, float a_height, vec4 b_value, float b_height, fl float ma = max(a_height + (1.0 - blend), b_height + blend) - (1.001 - blend_sharpness); float b1 = max(a_height + (1.0 - blend) - ma, 0.0); float b2 = max(b_height + blend - ma, 0.0); - return fma(a_value, vec4(b1), b_value * b2) / (b1 + b2); + return (a_value * b1 + b_value * b2) / (b1 + b2); } else { float contrast = 1.0 - blend_sharpness; float factor = (blend - contrast) / contrast; diff --git a/src/shaders/world_noise.glsl b/src/shaders/world_noise.glsl index 22d0a9a4e..02c48cc47 100644 --- a/src/shaders/world_noise.glsl +++ b/src/shaders/world_noise.glsl @@ -47,8 +47,8 @@ float hashv2(vec2 v) { vec3 noise2D(vec2 x) { vec2 f = fract(x); // Quintic Hermine Curve. Similar to SmoothStep() - vec2 u = f * f * f * fma(f, fma(f, vec2(6.0), vec2(-15.0)), vec2(10.0)); - vec2 du = 30.0 * f * f * fma(f, (f - 2.0), vec2(1.0)); + vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0); + vec2 du = 30.0*f*f*(f*(f-2.0)+1.0); vec2 p = floor(x); @@ -63,8 +63,8 @@ vec3 noise2D(vec2 x) { float k1 = b - a; float k2 = c - a; float k3 = a - b - c + d; - return vec3( fma(k3, u.x * u.y, fma(u.y, k2, fma(k1, u.x, k0))), - du * fma(u.yx, vec2(k3), vec2(k1, k2)) ); + return vec3( k0 + k1 * u.x + k2 * u.y + k3 * u.x * u.y, + du * ( vec2(k1, k2) + k3 * u.yx) ); } float world_noise(vec2 p) {