Page 1 of 1

Mandelbrot ISL shader

Posted: Wed Oct 06, 2010 9:19 pm
by OnoSendai
Hi Everyone,
for a bit of fun, I implemented rendering of the Mandelbrot set in ISL.

The material with shader is as follows:

Code: Select all

<material>
		<name>mat1</name>
		<diffuse>
			
			<albedo>
        <shader>
          <shader>
            <![CDATA[
            # x^2 = (a + bi)^2 = aa + 2abi + bbii
            # = a^2 + 2abi -b^2
            # = a^2-b^2 + 2abi
            
            # Does one iteration (application of f)
            # Returns (re(x), im(x), i)
            # Where i is the number of iterations before the point escaped.
            def f(vec3 x, vec2 c) vec3 :
              vec3(
                e0(x)*e0(x) - e1(x)*e1(x) + e0(c),
                2.0*e0(x)*e1(x) + e1(c),
                if((e0(x)*e0(x) + e1(x)*e1(x)) < 2.0, e2(x) + 1.0, e2(x))
              )
              
            # The composition of f with itself.  Does 2 iterations.
            # ISL doesn't support recursion for various reasons,
            # so we'll use the following composition technique for bounded 'recursion'.
            def f2(vec3 x, vec2 c) vec3:
              f(f(x, c), c)
              
            # Does 4 iterations
            def f4(vec3 x, vec2 c) vec3:
              f2(f2(x, c), c)
            
            # etc..
            def f8(vec3 x, vec2 c) vec3:
              f4(f4(x, c), c)
              
            def f16(vec3 x, vec2 c) vec3:
              f8(f8(x, c), c)

            def f32(vec3 x, vec2 c) vec3:
              f16(f16(x, c), c)

            def f64(vec3 x, vec2 c) vec3:
              f32(f32(x, c), c)

            def f128(vec3 x, vec2 c) vec3:
              f64(f64(x, c), c)
              
            def colour(real i) vec3:
              vec3(i * 0.02, i * 0.04, i * 0.08)

            def eval(vec3 pos) vec3 :
              # We will use the texture coordinates for c.
              # Return a colour based on the number of iterations before escape,
              # which is in the third vector component of the returned vector, hence the e2()
              # We call f128 to do 128 iterations.
              colour(e2(f128(vec3(0.0,0.0,0.0), getTexCoords(0))))
             ]]>
          </shader>
        </shader>
			</albedo>
		</diffuse>
	</material>

Re: Mandelbrot ISL shader

Posted: Wed Oct 06, 2010 9:25 pm
by fused
nooooooooooooooooooooooooooooooooooooooooooooooo!

Re: Mandelbrot ISL shader

Posted: Wed Oct 06, 2010 9:26 pm
by zeitmeister
Hehe!

Re: Mandelbrot ISL shader

Posted: Wed Oct 06, 2010 9:27 pm
by lycium
nicely done mr chapman! i am ashamed you beat me to it :oops:

Re: Mandelbrot ISL shader

Posted: Thu Oct 07, 2010 2:18 am
by StompinTom
lycium wrote:nicely done mr chapman! i am ashamed you beat me to it :oops:
http://en.wikipedia.org/wiki/Seppuku

Re: Mandelbrot ISL shader

Posted: Thu Oct 07, 2010 2:51 am
by Borgleader
lycium wrote:nicely done mr chapman! i am ashamed you beat me to it :oops:
I guess his edumaction paid off :lol:

Re: Mandelbrot ISL shader

Posted: Thu Oct 07, 2010 3:14 am
by CTZn
Hey StompinTom, it seems like there was a challenge between the guys but I don't think that seppuku was involved.

lol though :lol:

Re: Mandelbrot ISL shader

Posted: Thu Oct 07, 2010 10:20 am
by galinette
Hey, not fair! Please advise when starting that kind of contest :)

Re: Mandelbrot ISL shader

Posted: Thu Oct 07, 2010 9:07 pm
by OnoSendai
galinette wrote:Hey, not fair! Please advise when starting that kind of contest :)
Will do for next one :)

Re: Mandelbrot ISL shader

Posted: Fri Oct 08, 2010 7:22 am
by Godzilla
I was bored, so..


Image


Click the image for a larger version, or go here for the 'Holy shit thats huge' version.

Largest image done in Indigo?

Re: Mandelbrot ISL shader

Posted: Fri Oct 08, 2010 9:00 am
by StompinTom
Godzilla wrote:I was bored, so..


Image


Click the image for a larger version, or go here for the 'Holy shit thats huge' version.

Largest image done in Indigo?
Geez, you couldn't have gotten rid of all the noise? I think that's begging for a challenge... How much RAM did that eat up?

Re: Mandelbrot ISL shader

Posted: Fri Oct 08, 2010 9:09 am
by Godzilla
About 6.5GB of RAM @ 1 Super Samples

Re: Mandelbrot ISL shader

Posted: Fri Oct 08, 2010 9:41 am
by pixie
Godzilla wrote:About 6.5GB of RAM @ 1 Super Samples
I wonder how much memory if you had used indigo_console

Re: Mandelbrot ISL shader

Posted: Wed May 24, 2017 6:44 am
by arc en ciel
Image
is someone could write a Mandelbrot ISL shader for blend channel, please :?:
I can't figure out how to do it...