matriax
This shader using iterations for the precision (raymarching shader); You must need minimum 64 iterations
this is normal value, imagine some shaders have 200 iterations...
If you want gain a bit speed , you can break the loop if precision become lower than 0.001; the ray considering
nothing to hit;
// The perfomance problem?
float trace(vec3 o, vec3 r)
{
float t = 0.0; //
// Some kind of weird alpha around the cube ¿?
for (int i = 0; i < 64; ++i) { // 64 = 150cubes | 32 = 300 cubes | 16 = 450 cubes on screen (256x Sprites)
vec3 p = o + r * t;
float d = map(p).x;
if (d<0.001) break; //This will stop the loop ... and consider that the ray has nothing more to detect
t += d;
}
return t;
}
The first shader demo use triangles : http://gigatron3k.free.fr/html5/C2/FX/mcube
instead of raymarching like here ;