I encountered a very strange problem while learning Raymarching. My equation cannot be displayed well. It can be displayed well in matlab. But it can't be shown on Shadertoy at all.
My equation:
f(x,y,z) = (x^2+y^2+z^2)^2+2*y*(x^2+y^2+z^2)+2*(x^2+z^2);
code in matlab:
f =@(x,y,z) (x.^2+y.^2+z.^2)^2+2*y*(x.^2+y.^2+z.^2)+2*(x.^2+z.^2);
fimplicit3(f)
matlab displays a normal picture
code in shadertoy:
float sdRound(vec3 p)
{
float lengthXYZ = (p.x * p.x+p.y * p.y+p.z * p.z);
return lengthXYZ * lengthXYZ+2.0 * p.y * lengthXYZ+2.0 * (p.x * p.x+p.z * p.z);
}
I learned, practiced, and modified the iq code. (https://www.shadertoy.com/view/Xds3zN).
But it cannot be displayed normally. Shadertoy displays abnormal pictures Shadertoy displays abnormal pictures
I don't know where the problem occurred. Please help me. Has troubled me for a long time.
Forgive my poor English. I use Google Translate.