jf_knight
Member
I'm working on a shader that contains the line:
When I try to compile, it gives me an error saying I should use abs on the "s" variable because the base of the pow function, "s", must never be negative though I need the negative value so I can complete the effect the shader is supposed to perform. I've tried it with abs(s) and it compiles and runs, but it does not look how its supped to. GML's "power" function does not work in "fragment either.
I tried using an if/else if conditional hoping to get the same values;
but shaders don't necessarily "loop" and just defaults to whatever the value of s was on the initial run, plus I read on here that shaders are not supposed to have conditionals anyway.
If this line of code works on shadertoy.com, should it not work on gamemaker as well?
Should I try writing my own power function from scratch?
Is there another way around this?
Code:
float s = mix(r.x, (sin((iTime * 2.5 + 60.0) * r.y) * 0.5 + 0.5) * ((r.y * r.y) * (r.y * r.y)), 0.04);
color += pow(s, 70.0) * (1.0 - v);
I tried using an if/else if conditional hoping to get the same values;
Code:
if (s < 0.0)
{
color += (pow(abs(s), 70.0) * (1.0 - v)) * -1.0;
}
else if (s > 0.0)
{
color += pow(abs(s), 70.0) * (1.0 - v);
}
If this line of code works on shadertoy.com, should it not work on gamemaker as well?
Should I try writing my own power function from scratch?
Is there another way around this?