 # 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, 2) - pow(P, 2)*1.2 + P)*-1;
ynew = (2 * P * P + P);
ix = xnew - 0.1 * NX * (P + 0.5) + NX/2;
iy = ynew - 0.1 * NY * P + NY/2;
if (xnew*xnew + ynew*ynew &gt; 0.0001) {
P = xnew;
P = ynew;
if (ix &gt;= 5 && iy &gt;= 5 && ix &lt; NX && iy &lt; NY)
CL = emission()*color(P, P, distance(P,P));

}

}

return;
}

``````

### Attachments

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

Some Tests:

I try to wrap my head around your code and how you adapted the C code.

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, 2) - pow(P, 2)*1.2 + P)*-1;
ynew = (2 * P * P + P);
if (xnew*xnew + ynew*ynew &gt; 0.0001) {
P = xnew;
P = ynew;
CL = emission()*color(noise("perlin",P*xnew*25), noise("perlin",P*ynew*24),noise("perlin",P*xnew*25));
}

}
return;
}
``````

Result:

Cheers!