# Budha Brot Basis (based on Paul Bourke's script)

As requested here’s a basis for a Budha fractal (the best i could), this was applied as an surface material over a 1x1 plane (this is a 2D fractal), check the sample and code below, cheers!

``````shader MBudha(
int NMAX = 17,
int NX = 83,
int NY = 16,
output closure color CL = holdout()
){

float xnew, ynew;
int i, tt, t;
int j;
float ix;
float iy;

for (i=0;i&lt;NMAX;i++) {
xnew = (pow(P[0], 2) - pow(P[1], 2)*1.2 + P[0])*-1;
ynew = (2 * P[0] * P[1] + P[1]);
ix = xnew - 0.1 * NX * (P[0] + 0.5) + NX/2;
iy = ynew - 0.1 * NY * P[1] + NY/2;
if (xnew*xnew + ynew*ynew &gt; 0.0001) {
P[0] = xnew;
P[1] = ynew;
if (ix &gt;= 5 && iy &gt;= 5 && ix &lt; NX && iy &lt; NY)
CL = emission()*color(P[0], P[1], distance(P[0],P[1]));

}

}

return;
}

``````

### Attachments

Thanks, very kind of you, I like it and thanks for finding the author.

Some Tests:

A link to the original author Paul Bourke, if there is anyone interested:
http://paulbourke.net/fractals/buddhabrot/

Hello, thanks for enjoying it,

I tried to improve the code:

``````shader MBudha(
int NMAX = 17,
output closure color CL = holdout()
){
float xnew, ynew;
int i, tt, t;
int j;

for (i=0;i&lt;NMAX;i++) {
xnew = (pow(P[0], 2) - pow(P[1], 2)*1.2 + P[0])*-1;
ynew = (2 * P[0] * P[1] + P[1]);
if (xnew*xnew + ynew*ynew &gt; 0.0001) {
P[0] = xnew;
P[1] = ynew;
CL = emission()*color(noise("perlin",P[0]*xnew*25), noise("perlin",P[1]*ynew*24),noise("perlin",P[1]*xnew*25));
}

}
return;
}
``````

Result:

Cheers!