projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.22k stars 365 forks source link

Match math function behavior to DX9 implementation #778

Closed dpw13 closed 4 months ago

dpw13 commented 4 months ago

See https://github.com/projectM-visualizer/projectm/issues/724

kblaschke commented 4 months ago

        else if (String_Equal(functionName, "pow"))
        {
            HLSLExpression* argument[2];
            if (GetFunctionArguments(functionCall, argument, 2) != 2)
            {
                Error("%s expects 2 arguments", functionName);
                return;
            }
            // See rsqrt above regarding abs().
            m_writer.Write("pow(abs(");
            OutputExpression(argument[0]);
            m_writer.Write("),");
            OutputExpression(argument[1], &functionCall->function->argument->type);
            m_writer.Write(")");
            handled = true;
        }

Adding this after handling log10 in GLSLGenerator.cpp fixes "stormy sea", as pow() is also affected by the NaN madness.