Welcome to Fractal Forums

Fractal Software => Mandelbulb 3d => Topic started by: Mrz00m on January 06, 2017, 11:52:41 AM




Title: sprite and labyringth generator formula
Post by: Mrz00m on January 06, 2017, 11:52:41 AM
Here's a formula that multiplies a square wave with a random frequency on the X and Y planes and then moves the resulting surface through X and Y by the same random frequency square waves at a 10-20 times lower frequency create a totally unpredictable labyrinth type formula, and there are also C64 type game sprites on it. it's very very fast and it is perhaps a good addition to fractal hybrid programs. If you can figure a way to make it have many gradients of size that would be awesome.

http://www.thingiverse.com/thing:1985936

There's a lot of control of the random startpoint, the shapes, and the density/void ratio of the render:

 labyrinthIsoSurface();
  
    ridgeDensity = 1222;//higher values compress the random oscillator at higher frequency
    brickDensity = 0.45;//regulates the difficulty of maze
    mixIntensity= 0.02;
    mazeSize = 100;
    
module labyrinthIsoSurface (){

 for( j = [ 1 : mazeSize ])
   for( i = [ 1 : mazeSize ])
   {  

        li = lfo(i*ridgeDensity)*547.154;//random lfo values
        lj = lfo(j*ridgeDensity)*457;
        xc= (lfo(j*mixIntensity+li) + lfo(i*mixIntensity+lj))*.25+brickDensity;//
       //xc= (lfo(li) + lfo(lj))*.25+mixIntensity;//run this version to see simple version of maze
        
        rd = round(xc)*55;
        //echo(xc);
        if (xc > .5) // if isosurface is small, build wall cube
        {
            translate( [j ,i, 0])
            cube(1);
        }
   }
}

function mod(a,m) = a - m*floor(a/m);
function lfo(xx)= mod(abs((sin(floor(xx))*0.01246)*32718.927),1.0)*2.0 - 1.0  ; //erratic sin
    //low frequency oscillator function similar to synthesizer robot sound like R2D2




Title: Re: sprite and labyringth generator formula
Post by: Spain2points on January 09, 2017, 09:40:33 AM
That looks really cool, I hope thwy can implement it.


Title: Re: sprite and labyringth generator formula
Post by: DarkBeam on January 09, 2017, 09:57:56 AM
Can you code this using mb3d's jit or using my DIFS framework?
I don't understand fully your code


Title: Re: sprite and labyringth generator formula
Post by: Mrz00m on January 10, 2017, 06:47:57 PM
Thanks, hi, yes i should learn jit and DIFS framework, sounds fun. I'm a fan of online copy paste graphing tools. i think i found a jit tutorial. will see.

Here is a C style implementation, it's actually .JS :
Code:
function Start () {




startPos is current world position;

for (var h:int = -100; h < 100 ; h ++)
for (var j:int = -100; j < 100 ; j ++){
    var current :Vector3= startPos+Vector3(h*10.0,0,j*10.0);
if (equation1(current) > .5)
{
var cube : GameObject  =  instantiate cube in maze variable current
// if equation there is higher than .5 it means that it's a wall in space there, if it's less than zero it void space. the height of the walls is vaguely 55 world spaces according to the equation formula.
}

//
}
}

function Update () {

}

function  equation1 ( vtx: Vector3 ): float//  Labyrinth
{
var xi = lfo(vtx.x*.0025)*542;
var zi = lfo(vtx.z*.002)*222;//xi zi shuffles the straighter maze formula, without is less maze
var xc= (lfo(vtx.x*.05+zi) + lfo(vtx.z*.05+xi))*.25+.49;//+.49 regulates difficulty of maze, .35 is easy
return Math.Round(xc)*55; //multiply at the end to get different heights
}

function  lfo (xx: float): float//
{
return (Math.Abs((Math.Sin(Math.Floor(xx))*.01246)*32718.927)%1)*2-1;
}