Share a Shader!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Share a Shader!

Post by GijsB »

aaaaah thank you :D
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Share a Shader!

Post by vrld »

RGB to HSL and back utility function:

Code: Select all

// helper function, please ignore
number _hue(number s, number t, number h)
{
	h = mod(h, 1.);
	number six_h = 6.0 * h;
	if (six_h < 1.) return (t-s) * six_h + s;
	if (six_h < 3.) return t;
	if (six_h < 4.) return (t-s) * (4.-six_h) + s;
	return s;
}

// input: vec4(h,s,l,a), with h,s,l,a = 0..1
// output: vec4(r,g,b,a), with r,g,b,a = 0..1
vec4 hsl_to_rgb(vec4 c)
{
	if (c.y == 0)
		return vec4(vec3(c.z), c.a);

	number t = (c.z < .5) ? c.y*c.z + c.z : -c.y*c.z + (c.y+c.z);
	number s = 2.0 * c.z - t;
	return vec4(_hue(s,t,c.x + 1./3.), _hue(s,t,c.x), _hue(s,t,c.x - 1./3.), c.w);
}

// input: vec4(r,g,b,a), with r,g,b,a = 0..1
// output: vec4(h,s,l,a), with h,s,l,a = 0..1
vec4 rgb_to_hsl(vec4 c)
{
	number low = min(c.r, min(c.g, c.b));
	number high = max(c.r, max(c.g, c.b));
	number delta = high - low;
	number sum = high+low;

	vec4 hsl = vec4(.0, .0, .5 * sum, c.a);
	if (delta == .0)
		return hsl;

	hsl.y = (hsl.z < .5) ? delta / sum : delta / (2.0 - sum);

	if (high == c.r)
		hsl.x = (c.g - c.b) / delta;
	else if (high == c.g)
		hsl.x = (c.b - c.r) / delta + 2.0;
	else
		hsl.x = (c.r - c.g) / delta + 4.0;

	hsl.x = mod(hsl.x / 6., 1.);
	return hsl;
}
Can be used to shift the color or desaturate like this:

Code: Select all

function love.load()
	effect = love.graphics.newPixelEffect [[
(...)

extern vec2 color_shift;
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pc)
{
	color = rgb_to_hsl(Texel(tex, tc));
	color.x += color_shift.x;
	color.y = color_shift.y;
	return hsl_to_rgb(color);
}]]
	effect:send('color_shift', {0,0})
end

function love.update(dt)
	local x = love.mouse.getX() / love.graphics.getWidth()
	local y = love.mouse.getY() / love.graphics.getHeight()
	effect:send('color_shift', {x,y})
end

function love.draw()
	love.graphics.setPixelEffect(effect)
	love.graphics.draw(some_image, 0,0)
end
You can also use it for nice color transitions as the one in the attached .love.
Attachments
waves.love
(1.47 KiB) Downloaded 1039 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Share a Shader!

Post by vrld »

So there is this gallery of webgl shader experiments, including simple games, and some pretty amazing ray casting thingies.

As it turns out, those demos are pretty easy to port to PixelEffects, so I ported a more simple looking (code wise) demo. I annotated some of the code to make it more understandable.
Attachments
raycast.love
(1.1 KiB) Downloaded 1071 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Share a Shader!

Post by GijsB »

vrld wrote:So there is this gallery of webgl shader experiments, including simple games, and some pretty amazing ray casting thingies.

As it turns out, those demos are pretty easy to port to PixelEffects, so I ported a more simple looking (code wise) demo. I annotated some of the code to make it more understandable.
Oh my god :ultrashocked: thar freaking awesome :neko:
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Share a Shader!

Post by miko »

vrld wrote:So there is this gallery of webgl shader experiments, including simple games, and some pretty amazing ray casting thingies.

As it turns out, those demos are pretty easy to port to PixelEffects, so I ported a more simple looking (code wise) demo. I annotated some of the code to make it more understandable.
Intel i810 (GM45), linux, Mesa 7.11, GLX 1.4, GLSL 1.2.
After getting black screen and high CPU usage for some time i get this error:

Code: Select all

Error: [string "graphics.lua"]:1370: Cannot compile shader:
FS compile failed: no register to spill


stack traceback:
	[C]: in function 'newPixelEffect'
	[string "graphics.lua"]:1370: in function 'newPixelEffect'
	main.lua:61: in function 'load'
	[string "boot.lua"]:350: in function <[string "boot.lua"]:348>
	[C]: in function 'xpcall'
Based on this http://lists.freedesktop.org/archives/m ... 29800.html I suppose it is a Mesa/Intel problem :( Anyways, there is more output when run with INTEL_DEBUG=wm:

Code: Select all

GLSL IR for native fragment shader 1:
(
(declare (uniform ) float time)
(declare (out ) vec4 gl_FragColor)
(declare (in ) (array vec4 1) gl_TexCoord)
(function main
  (signature void
    (parameters
    )
    (
      (declare () int i)
      (declare () float t)
      (declare () vec4 c)
      (declare (temporary ) float d_x)
      (declare (temporary ) float d_y)
      (declare (temporary ) float o_x)
      (declare (temporary ) float o_y)
      (declare () float threshold)
      (assign  (x) (var_ref threshold)  (expression float + (expression float * (expression float sin (var_ref time) ) (constant float (0.300000)) ) (constant float (0.500000)) ) ) 
      (declare (temporary ) vec2 channel_expressions)
      (assign  (xy) (var_ref channel_expressions)  (swiz xy (array_ref (var_ref gl_TexCoord) (constant int (0)) ) )) 
      (declare (temporary ) float flattening_tmp_x)
      (declare (temporary ) float flattening_tmp_y)
      (assign  (x) (var_ref flattening_tmp_x)  (expression float + (expression float * (constant float (2.000000)) (swiz x (var_ref channel_expressions) )) (constant float (-1.000000)) ) ) 
      (assign  (x) (var_ref flattening_tmp_y)  (expression float + (expression float * (constant float (2.000000)) (swiz y (var_ref channel_expressions) )) (constant float (-1.000000)) ) ) 
      (assign  (x) (var_ref o_x)  (var_ref flattening_tmp_x) ) 
      (assign  (x) (var_ref o_y)  (expression float + (expression float * (var_ref flattening_tmp_y) (constant float (1.250000)) ) (constant float (-0.300000)) ) ) 
      (assign  (x) (var_ref d_x)  (expression float * (expression float + (var_ref flattening_tmp_x) (expression float * (expression float cos (var_ref time) ) (constant float (0.300000)) ) ) (constant float (0.015625)) ) ) 
      (assign  (x) (var_ref d_y)  (expression float * (var_ref flattening_tmp_y) (constant float (0.015625)) ) ) 
      (assign  (xyzw) (var_ref c)  (constant vec4 (0.000000 0.000000 0.000000 0.000000)) ) 
      (assign  (x) (var_ref t)  (constant float (0.000000)) ) 
      (assign  (x) (var_ref i)  (constant int (0)) ) 
      (loop ((declare () int i@2)) ((constant int (0)) ) ((constant int (75)) ) ((constant int (1)) ) (
        (declare (temporary ) float flattening_tmp_x@3)
        (declare (temporary ) float flattening_tmp_y@4)
        (declare (temporary ) float flattening_tmp_z)
        (assign  (x) (var_ref flattening_tmp_x@3)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_y@4)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_z)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
        (declare () float f)
        (declare (temporary ) float flattening_tmp_x@5)
        (declare (temporary ) float flattening_tmp_y@6)
        (declare (temporary ) float flattening_tmp_z@7)
        (assign  (x) (var_ref flattening_tmp_x@5)  (expression float + (var_ref flattening_tmp_x@3) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_y@6)  (expression float + (var_ref flattening_tmp_y@4) (constant float (-0.300000)) ) ) 
        (assign  (x) (var_ref flattening_tmp_z@7)  (expression float + (var_ref flattening_tmp_z) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
        (declare (temporary ) float flattening_tmp_x@8)
        (declare (temporary ) float flattening_tmp_y@9)
        (declare (temporary ) float flattening_tmp_z@10)
        (assign  (x) (var_ref flattening_tmp_x@8)  (expression float + (var_ref flattening_tmp_x@3) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_y@9)  (expression float + (var_ref flattening_tmp_y@4) (constant float (-0.300000)) ) ) 
        (assign  (x) (var_ref flattening_tmp_z@10)  (expression float + (var_ref flattening_tmp_z) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
        (assign  (x) (var_ref f)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@7) (var_ref flattening_tmp_z@7) ) (expression float + (expression float * (var_ref flattening_tmp_y@6) (var_ref flattening_tmp_y@6) ) (expression float * (var_ref flattening_tmp_x@5) (var_ref flattening_tmp_x@5) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@10) (var_ref flattening_tmp_z@10) ) (expression float + (expression float * (var_ref flattening_tmp_y@9) (var_ref flattening_tmp_y@9) ) (expression float * (var_ref flattening_tmp_x@8) (var_ref flattening_tmp_x@8) ) ) ) ) ) ) 
        (declare (temporary ) float flattening_tmp_x@11)
        (declare (temporary ) float flattening_tmp_y@12)
        (declare (temporary ) float flattening_tmp_z@13)
        (assign  (x) (var_ref flattening_tmp_x@11)  (expression float + (var_ref flattening_tmp_x@3) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_y@12)  (expression float + (var_ref flattening_tmp_y@4) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
        (assign  (x) (var_ref flattening_tmp_z@13)  (expression float + (var_ref flattening_tmp_z) (constant float (-2.000000)) ) ) 
        (assign  (x) (var_ref f)  (expression float * (var_ref f) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@13) (var_ref flattening_tmp_z@13) ) (expression float + (expression float * (var_ref flattening_tmp_y@12) (var_ref flattening_tmp_y@12) ) (expression float * (var_ref flattening_tmp_x@11) (var_ref flattening_tmp_x@11) ) ) ) ) ) ) 
        (declare (temporary ) float assignment_tmp)
        (assign  (x) (var_ref assignment_tmp)  (expression float * (var_ref f) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@4) ) (expression float cos (var_ref flattening_tmp_x@3) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@3) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@4) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
        (assign  (x) (var_ref f)  (var_ref assignment_tmp) ) 
        (if (expression bool < (var_ref assignment_tmp) (var_ref threshold) ) (
          (declare () vec3 n)
          (declare () int j)
          (assign  (x) (var_ref t)  (expression float + (var_ref t) (constant float (-5.000000)) ) ) 
          (assign  (x) (var_ref j)  (constant int (0)) ) 
          (loop () () () () (
            (if (expression bool >= (var_ref j) (constant int (5)) ) (
              break
            )
            ())

            (declare (temporary ) float flattening_tmp_x@14)
            (declare (temporary ) float flattening_tmp_y@15)
            (declare (temporary ) float flattening_tmp_z@16)
            (assign  (x) (var_ref flattening_tmp_x@14)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_y@15)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_z@16)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
            (declare () float f@17)
            (declare (temporary ) float flattening_tmp_x@18)
            (declare (temporary ) float flattening_tmp_y@19)
            (declare (temporary ) float flattening_tmp_z@20)
            (assign  (x) (var_ref flattening_tmp_x@18)  (expression float + (var_ref flattening_tmp_x@14) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_y@19)  (expression float + (var_ref flattening_tmp_y@15) (constant float (-0.300000)) ) ) 
            (assign  (x) (var_ref flattening_tmp_z@20)  (expression float + (var_ref flattening_tmp_z@16) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
            (declare (temporary ) float flattening_tmp_x@21)
            (declare (temporary ) float flattening_tmp_y@22)
            (declare (temporary ) float flattening_tmp_z@23)
            (assign  (x) (var_ref flattening_tmp_x@21)  (expression float + (var_ref flattening_tmp_x@14) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_y@22)  (expression float + (var_ref flattening_tmp_y@15) (constant float (-0.300000)) ) ) 
            (assign  (x) (var_ref flattening_tmp_z@23)  (expression float + (var_ref flattening_tmp_z@16) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
            (assign  (x) (var_ref f@17)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@20) (var_ref flattening_tmp_z@20) ) (expression float + (expression float * (var_ref flattening_tmp_y@19) (var_ref flattening_tmp_y@19) ) (expression float * (var_ref flattening_tmp_x@18) (var_ref flattening_tmp_x@18) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@23) (var_ref flattening_tmp_z@23) ) (expression float + (expression float * (var_ref flattening_tmp_y@22) (var_ref flattening_tmp_y@22) ) (expression float * (var_ref flattening_tmp_x@21) (var_ref flattening_tmp_x@21) ) ) ) ) ) ) 
            (declare (temporary ) float flattening_tmp_x@24)
            (declare (temporary ) float flattening_tmp_y@25)
            (declare (temporary ) float flattening_tmp_z@26)
            (assign  (x) (var_ref flattening_tmp_x@24)  (expression float + (var_ref flattening_tmp_x@14) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_y@25)  (expression float + (var_ref flattening_tmp_y@15) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
            (assign  (x) (var_ref flattening_tmp_z@26)  (expression float + (var_ref flattening_tmp_z@16) (constant float (-2.000000)) ) ) 
            (assign  (x) (var_ref f@17)  (expression float * (var_ref f@17) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@26) (var_ref flattening_tmp_z@26) ) (expression float + (expression float * (var_ref flattening_tmp_y@25) (var_ref flattening_tmp_y@25) ) (expression float * (var_ref flattening_tmp_x@24) (var_ref flattening_tmp_x@24) ) ) ) ) ) ) 
            (declare (temporary ) float assignment_tmp@27)
            (assign  (x) (var_ref assignment_tmp@27)  (expression float * (var_ref f@17) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@15) ) (expression float cos (var_ref flattening_tmp_x@14) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@16) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@14) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@15) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
            (assign  (x) (var_ref f@17)  (var_ref assignment_tmp@27) ) 
            (if (expression bool < (var_ref assignment_tmp@27) (var_ref threshold) ) (
              break
            )
            ())

            (assign  (x) (var_ref t)  (expression float + (var_ref t) (constant float (1.000000)) ) ) 
            (assign  (x) (var_ref j)  (expression int + (var_ref j) (constant int (1)) ) ) 
          ))

          (assign  (xyz) (var_ref n)  (constant vec3 (0.000000 0.000000 0.000000)) ) 
          (declare (temporary ) float flattening_tmp_x@28)
          (declare (temporary ) float flattening_tmp_y@29)
          (declare (temporary ) float flattening_tmp_z@30)
          (assign  (x) (var_ref flattening_tmp_x@28)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@29)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@30)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
          (declare () float f@31)
          (declare (temporary ) float flattening_tmp_x@32)
          (declare (temporary ) float flattening_tmp_y@33)
          (declare (temporary ) float flattening_tmp_z@34)
          (assign  (x) (var_ref flattening_tmp_x@32)  (expression float + (var_ref flattening_tmp_x@28) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@33)  (expression float + (var_ref flattening_tmp_y@29) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@34)  (expression float + (var_ref flattening_tmp_z@30) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@35)
          (declare (temporary ) float flattening_tmp_y@36)
          (declare (temporary ) float flattening_tmp_z@37)
          (assign  (x) (var_ref flattening_tmp_x@35)  (expression float + (var_ref flattening_tmp_x@28) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@36)  (expression float + (var_ref flattening_tmp_y@29) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@37)  (expression float + (var_ref flattening_tmp_z@30) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@31)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@34) (var_ref flattening_tmp_z@34) ) (expression float + (expression float * (var_ref flattening_tmp_y@33) (var_ref flattening_tmp_y@33) ) (expression float * (var_ref flattening_tmp_x@32) (var_ref flattening_tmp_x@32) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@37) (var_ref flattening_tmp_z@37) ) (expression float + (expression float * (var_ref flattening_tmp_y@36) (var_ref flattening_tmp_y@36) ) (expression float * (var_ref flattening_tmp_x@35) (var_ref flattening_tmp_x@35) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@38)
          (declare (temporary ) float flattening_tmp_y@39)
          (declare (temporary ) float flattening_tmp_z@40)
          (assign  (x) (var_ref flattening_tmp_x@38)  (expression float + (var_ref flattening_tmp_x@28) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@39)  (expression float + (var_ref flattening_tmp_y@29) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@40)  (expression float + (var_ref flattening_tmp_z@30) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@31)  (expression float * (var_ref f@31) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@40) (var_ref flattening_tmp_z@40) ) (expression float + (expression float * (var_ref flattening_tmp_y@39) (var_ref flattening_tmp_y@39) ) (expression float * (var_ref flattening_tmp_x@38) (var_ref flattening_tmp_x@38) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@41)
          (assign  (x) (var_ref assignment_tmp@41)  (expression float * (var_ref f@31) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@29) ) (expression float cos (var_ref flattening_tmp_x@28) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@30) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@28) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@29) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@31)  (var_ref assignment_tmp@41) ) 
          (declare (temporary ) float flattening_tmp_x@42)
          (declare (temporary ) float flattening_tmp_y@43)
          (declare (temporary ) float flattening_tmp_z@44)
          (assign  (x) (var_ref flattening_tmp_x@42)  (expression float + (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) (constant float (0.010000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@43)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@44)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
          (declare () float f@45)
          (declare (temporary ) float flattening_tmp_x@46)
          (declare (temporary ) float flattening_tmp_y@47)
          (declare (temporary ) float flattening_tmp_z@48)
          (assign  (x) (var_ref flattening_tmp_x@46)  (expression float + (var_ref flattening_tmp_x@42) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@47)  (expression float + (var_ref flattening_tmp_y@43) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@48)  (expression float + (var_ref flattening_tmp_z@44) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@49)
          (declare (temporary ) float flattening_tmp_y@50)
          (declare (temporary ) float flattening_tmp_z@51)
          (assign  (x) (var_ref flattening_tmp_x@49)  (expression float + (var_ref flattening_tmp_x@42) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@50)  (expression float + (var_ref flattening_tmp_y@43) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@51)  (expression float + (var_ref flattening_tmp_z@44) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@45)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@48) (var_ref flattening_tmp_z@48) ) (expression float + (expression float * (var_ref flattening_tmp_y@47) (var_ref flattening_tmp_y@47) ) (expression float * (var_ref flattening_tmp_x@46) (var_ref flattening_tmp_x@46) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@51) (var_ref flattening_tmp_z@51) ) (expression float + (expression float * (var_ref flattening_tmp_y@50) (var_ref flattening_tmp_y@50) ) (expression float * (var_ref flattening_tmp_x@49) (var_ref flattening_tmp_x@49) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@52)
          (declare (temporary ) float flattening_tmp_y@53)
          (declare (temporary ) float flattening_tmp_z@54)
          (assign  (x) (var_ref flattening_tmp_x@52)  (expression float + (var_ref flattening_tmp_x@42) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@53)  (expression float + (var_ref flattening_tmp_y@43) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@54)  (expression float + (var_ref flattening_tmp_z@44) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@45)  (expression float * (var_ref f@45) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@54) (var_ref flattening_tmp_z@54) ) (expression float + (expression float * (var_ref flattening_tmp_y@53) (var_ref flattening_tmp_y@53) ) (expression float * (var_ref flattening_tmp_x@52) (var_ref flattening_tmp_x@52) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@55)
          (assign  (x) (var_ref assignment_tmp@55)  (expression float * (var_ref f@45) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@43) ) (expression float cos (var_ref flattening_tmp_x@42) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@44) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@42) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@43) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@45)  (var_ref assignment_tmp@55) ) 
          (assign  (x) (var_ref n)  (expression float + (var_ref assignment_tmp@41) (expression float neg (var_ref assignment_tmp@55) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@56)
          (declare (temporary ) float flattening_tmp_y@57)
          (declare (temporary ) float flattening_tmp_z@58)
          (assign  (x) (var_ref flattening_tmp_x@56)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@57)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@58)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
          (declare () float f@59)
          (declare (temporary ) float flattening_tmp_x@60)
          (declare (temporary ) float flattening_tmp_y@61)
          (declare (temporary ) float flattening_tmp_z@62)
          (assign  (x) (var_ref flattening_tmp_x@60)  (expression float + (var_ref flattening_tmp_x@56) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@61)  (expression float + (var_ref flattening_tmp_y@57) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@62)  (expression float + (var_ref flattening_tmp_z@58) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@63)
          (declare (temporary ) float flattening_tmp_y@64)
          (declare (temporary ) float flattening_tmp_z@65)
          (assign  (x) (var_ref flattening_tmp_x@63)  (expression float + (var_ref flattening_tmp_x@56) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@64)  (expression float + (var_ref flattening_tmp_y@57) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@65)  (expression float + (var_ref flattening_tmp_z@58) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@59)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@62) (var_ref flattening_tmp_z@62) ) (expression float + (expression float * (var_ref flattening_tmp_y@61) (var_ref flattening_tmp_y@61) ) (expression float * (var_ref flattening_tmp_x@60) (var_ref flattening_tmp_x@60) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@65) (var_ref flattening_tmp_z@65) ) (expression float + (expression float * (var_ref flattening_tmp_y@64) (var_ref flattening_tmp_y@64) ) (expression float * (var_ref flattening_tmp_x@63) (var_ref flattening_tmp_x@63) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@66)
          (declare (temporary ) float flattening_tmp_y@67)
          (declare (temporary ) float flattening_tmp_z@68)
          (assign  (x) (var_ref flattening_tmp_x@66)  (expression float + (var_ref flattening_tmp_x@56) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@67)  (expression float + (var_ref flattening_tmp_y@57) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@68)  (expression float + (var_ref flattening_tmp_z@58) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@59)  (expression float * (var_ref f@59) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@68) (var_ref flattening_tmp_z@68) ) (expression float + (expression float * (var_ref flattening_tmp_y@67) (var_ref flattening_tmp_y@67) ) (expression float * (var_ref flattening_tmp_x@66) (var_ref flattening_tmp_x@66) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@69)
          (assign  (x) (var_ref assignment_tmp@69)  (expression float * (var_ref f@59) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@57) ) (expression float cos (var_ref flattening_tmp_x@56) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@58) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@56) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@57) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@59)  (var_ref assignment_tmp@69) ) 
          (declare (temporary ) float flattening_tmp_x@70)
          (declare (temporary ) float flattening_tmp_y@71)
          (declare (temporary ) float flattening_tmp_z@72)
          (assign  (x) (var_ref flattening_tmp_x@70)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@71)  (expression float + (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) (constant float (0.010000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@72)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
          (declare () float f@73)
          (declare (temporary ) float flattening_tmp_x@74)
          (declare (temporary ) float flattening_tmp_y@75)
          (declare (temporary ) float flattening_tmp_z@76)
          (assign  (x) (var_ref flattening_tmp_x@74)  (expression float + (var_ref flattening_tmp_x@70) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@75)  (expression float + (var_ref flattening_tmp_y@71) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@76)  (expression float + (var_ref flattening_tmp_z@72) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@77)
          (declare (temporary ) float flattening_tmp_y@78)
          (declare (temporary ) float flattening_tmp_z@79)
          (assign  (x) (var_ref flattening_tmp_x@77)  (expression float + (var_ref flattening_tmp_x@70) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@78)  (expression float + (var_ref flattening_tmp_y@71) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@79)  (expression float + (var_ref flattening_tmp_z@72) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@73)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@76) (var_ref flattening_tmp_z@76) ) (expression float + (expression float * (var_ref flattening_tmp_y@75) (var_ref flattening_tmp_y@75) ) (expression float * (var_ref flattening_tmp_x@74) (var_ref flattening_tmp_x@74) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@79) (var_ref flattening_tmp_z@79) ) (expression float + (expression float * (var_ref flattening_tmp_y@78) (var_ref flattening_tmp_y@78) ) (expression float * (var_ref flattening_tmp_x@77) (var_ref flattening_tmp_x@77) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@80)
          (declare (temporary ) float flattening_tmp_y@81)
          (declare (temporary ) float flattening_tmp_z@82)
          (assign  (x) (var_ref flattening_tmp_x@80)  (expression float + (var_ref flattening_tmp_x@70) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@81)  (expression float + (var_ref flattening_tmp_y@71) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@82)  (expression float + (var_ref flattening_tmp_z@72) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@73)  (expression float * (var_ref f@73) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@82) (var_ref flattening_tmp_z@82) ) (expression float + (expression float * (var_ref flattening_tmp_y@81) (var_ref flattening_tmp_y@81) ) (expression float * (var_ref flattening_tmp_x@80) (var_ref flattening_tmp_x@80) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@83)
          (assign  (x) (var_ref assignment_tmp@83)  (expression float * (var_ref f@73) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@71) ) (expression float cos (var_ref flattening_tmp_x@70) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@72) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@70) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@71) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@73)  (var_ref assignment_tmp@83) ) 
          (assign  (y) (var_ref n)  (expression float + (var_ref assignment_tmp@69) (expression float neg (var_ref assignment_tmp@83) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@84)
          (declare (temporary ) float flattening_tmp_y@85)
          (declare (temporary ) float flattening_tmp_z@86)
          (assign  (x) (var_ref flattening_tmp_x@84)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@85)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@86)  (expression float * (constant float (0.015625)) (var_ref t) ) ) 
          (declare () float f@87)
          (declare (temporary ) float flattening_tmp_x@88)
          (declare (temporary ) float flattening_tmp_y@89)
          (declare (temporary ) float flattening_tmp_z@90)
          (assign  (x) (var_ref flattening_tmp_x@88)  (expression float + (var_ref flattening_tmp_x@84) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@89)  (expression float + (var_ref flattening_tmp_y@85) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@90)  (expression float + (var_ref flattening_tmp_z@86) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@91)
          (declare (temporary ) float flattening_tmp_y@92)
          (declare (temporary ) float flattening_tmp_z@93)
          (assign  (x) (var_ref flattening_tmp_x@91)  (expression float + (var_ref flattening_tmp_x@84) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@92)  (expression float + (var_ref flattening_tmp_y@85) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@93)  (expression float + (var_ref flattening_tmp_z@86) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@87)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@90) (var_ref flattening_tmp_z@90) ) (expression float + (expression float * (var_ref flattening_tmp_y@89) (var_ref flattening_tmp_y@89) ) (expression float * (var_ref flattening_tmp_x@88) (var_ref flattening_tmp_x@88) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@93) (var_ref flattening_tmp_z@93) ) (expression float + (expression float * (var_ref flattening_tmp_y@92) (var_ref flattening_tmp_y@92) ) (expression float * (var_ref flattening_tmp_x@91) (var_ref flattening_tmp_x@91) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@94)
          (declare (temporary ) float flattening_tmp_y@95)
          (declare (temporary ) float flattening_tmp_z@96)
          (assign  (x) (var_ref flattening_tmp_x@94)  (expression float + (var_ref flattening_tmp_x@84) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@95)  (expression float + (var_ref flattening_tmp_y@85) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@96)  (expression float + (var_ref flattening_tmp_z@86) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@87)  (expression float * (var_ref f@87) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@96) (var_ref flattening_tmp_z@96) ) (expression float + (expression float * (var_ref flattening_tmp_y@95) (var_ref flattening_tmp_y@95) ) (expression float * (var_ref flattening_tmp_x@94) (var_ref flattening_tmp_x@94) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@97)
          (assign  (x) (var_ref assignment_tmp@97)  (expression float * (var_ref f@87) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@85) ) (expression float cos (var_ref flattening_tmp_x@84) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@86) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@84) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@85) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@87)  (var_ref assignment_tmp@97) ) 
          (declare (temporary ) float flattening_tmp_x@98)
          (declare (temporary ) float flattening_tmp_y@99)
          (declare (temporary ) float flattening_tmp_z@100)
          (assign  (x) (var_ref flattening_tmp_x@98)  (expression float + (var_ref o_x) (expression float * (var_ref d_x) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@99)  (expression float + (var_ref o_y) (expression float * (var_ref d_y) (var_ref t) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@100)  (expression float + (expression float * (constant float (0.015625)) (var_ref t) ) (constant float (0.010000)) ) ) 
          (declare () float f@101)
          (declare (temporary ) float flattening_tmp_x@102)
          (declare (temporary ) float flattening_tmp_y@103)
          (declare (temporary ) float flattening_tmp_z@104)
          (assign  (x) (var_ref flattening_tmp_x@102)  (expression float + (var_ref flattening_tmp_x@98) (expression float neg (expression float + (expression float cos (var_ref time) ) (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@103)  (expression float + (var_ref flattening_tmp_y@99) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@104)  (expression float + (var_ref flattening_tmp_z@100) (expression float neg (expression float + (constant float (2.000000)) (expression float * (expression float cos (expression float * (var_ref time) (constant float (0.500000)) ) ) (constant float (0.500000)) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@105)
          (declare (temporary ) float flattening_tmp_y@106)
          (declare (temporary ) float flattening_tmp_z@107)
          (assign  (x) (var_ref flattening_tmp_x@105)  (expression float + (var_ref flattening_tmp_x@98) (expression float neg (expression float neg (expression float cos (expression float * (var_ref time) (constant float (0.700000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@106)  (expression float + (var_ref flattening_tmp_y@99) (constant float (-0.300000)) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@107)  (expression float + (var_ref flattening_tmp_z@100) (expression float neg (expression float + (constant float (2.000000)) (expression float sin (expression float * (var_ref time) (constant float (0.500000)) ) ) ) ) ) ) 
          (assign  (x) (var_ref f@101)  (expression float * (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@104) (var_ref flattening_tmp_z@104) ) (expression float + (expression float * (var_ref flattening_tmp_y@103) (var_ref flattening_tmp_y@103) ) (expression float * (var_ref flattening_tmp_x@102) (var_ref flattening_tmp_x@102) ) ) ) ) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@107) (var_ref flattening_tmp_z@107) ) (expression float + (expression float * (var_ref flattening_tmp_y@106) (var_ref flattening_tmp_y@106) ) (expression float * (var_ref flattening_tmp_x@105) (var_ref flattening_tmp_x@105) ) ) ) ) ) ) 
          (declare (temporary ) float flattening_tmp_x@108)
          (declare (temporary ) float flattening_tmp_y@109)
          (declare (temporary ) float flattening_tmp_z@110)
          (assign  (x) (var_ref flattening_tmp_x@108)  (expression float + (var_ref flattening_tmp_x@98) (expression float neg (expression float * (expression float neg (expression float sin (expression float * (var_ref time) (constant float (0.200000)) ) ) ) (constant float (0.500000)) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@109)  (expression float + (var_ref flattening_tmp_y@99) (expression float neg (expression float sin (var_ref time) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@110)  (expression float + (var_ref flattening_tmp_z@100) (constant float (-2.000000)) ) ) 
          (assign  (x) (var_ref f@101)  (expression float * (var_ref f@101) (expression float sqrt (expression float + (expression float * (var_ref flattening_tmp_z@110) (var_ref flattening_tmp_z@110) ) (expression float + (expression float * (var_ref flattening_tmp_y@109) (var_ref flattening_tmp_y@109) ) (expression float * (var_ref flattening_tmp_x@108) (var_ref flattening_tmp_x@108) ) ) ) ) ) ) 
          (declare (temporary ) float assignment_tmp@111)
          (assign  (x) (var_ref assignment_tmp@111)  (expression float * (var_ref f@101) (expression float + (expression float + (expression float * (expression float cos (var_ref flattening_tmp_y@99) ) (expression float cos (var_ref flattening_tmp_x@98) ) ) (constant float (-0.100000)) ) (expression float neg (expression float * (expression float * (expression float * (expression float cos (expression float + (expression float * (var_ref flattening_tmp_z@100) (constant float (7.000000)) ) (expression float * (var_ref time) (constant float (7.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_x@98) (constant float (3.000000)) ) ) ) (expression float cos (expression float * (var_ref flattening_tmp_y@99) (constant float (4.000000)) ) ) ) (constant float (0.100000)) ) ) ) ) ) 
          (assign  (x) (var_ref f@101)  (var_ref assignment_tmp@111) ) 
          (assign  (z) (var_ref n)  (expression float + (var_ref assignment_tmp@97) (expression float neg (var_ref assignment_tmp@111) ) ) ) 
          (declare (temporary ) float flattening_tmp_y@112)
          (declare (temporary ) float flattening_tmp_z@113)
          (declare (temporary ) float channel_expressions@114)
          (assign  (x) (var_ref channel_expressions@114)  (expression float rsq (expression float + (expression float * (swiz z (var_ref n) )(swiz z (var_ref n) )) (expression float + (expression float * (swiz y (var_ref n) )(swiz y (var_ref n) )) (expression float * (swiz x (var_ref n) )(swiz x (var_ref n) )) ) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@112)  (expression float * (swiz y (var_ref n) )(var_ref channel_expressions@114) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@113)  (expression float * (swiz z (var_ref n) )(var_ref channel_expressions@114) ) ) 
          (assign  (x) (var_ref n)  (expression float * (swiz x (var_ref n) )(var_ref channel_expressions@114) ) ) 
          (assign  (y) (var_ref n)  (var_ref flattening_tmp_y@112) ) 
          (assign  (z) (var_ref n)  (var_ref flattening_tmp_z@113) ) 
          (declare (temporary ) float flattening_tmp_y@115)
          (declare (temporary ) float flattening_tmp_z@116)
          (declare (temporary ) float flattening_tmp_w)
          (declare (temporary ) float channel_expressions@117)
          (assign  (x) (var_ref channel_expressions@117)  (expression float + (expression float max (expression float * (constant float (-0.500000)) (var_ref flattening_tmp_z@113) ) (constant float (0.000000)) ) (expression float * (expression float max (expression float + (expression float * (constant float (0.500000)) (var_ref flattening_tmp_z@113) ) (expression float * (constant float (-0.500000)) (var_ref flattening_tmp_y@112) ) ) (constant float (0.000000)) ) (constant float (0.500000)) ) ) ) 
          (assign  (x) (var_ref flattening_tmp_y@115)  (expression float + (swiz y (var_ref c) )(var_ref channel_expressions@117) ) ) 
          (assign  (x) (var_ref flattening_tmp_z@116)  (expression float + (swiz z (var_ref c) )(var_ref channel_expressions@117) ) ) 
          (assign  (x) (var_ref flattening_tmp_w)  (expression float + (swiz w (var_ref c) )(var_ref channel_expressions@117) ) ) 
          (assign  (x) (var_ref c)  (expression float + (swiz x (var_ref c) )(var_ref channel_expressions@117) ) ) 
          (assign  (y) (var_ref c)  (var_ref flattening_tmp_y@115) ) 
          (assign  (z) (var_ref c)  (var_ref flattening_tmp_z@116) ) 
          (assign  (w) (var_ref c)  (var_ref flattening_tmp_w) ) 
          break
        )
        ())

        (assign  (x) (var_ref t)  (expression float + (var_ref t) (constant float (5.000000)) ) ) 
        (assign  (x) (var_ref i)  (expression int + (var_ref i) (constant int (1)) ) ) 
      ))

      (assign  (x) (var_ref gl_FragColor)  (expression float + (swiz x (var_ref c) )(expression float * (var_ref t) (constant float (0.002500)) ) ) ) 
      (assign  (y) (var_ref gl_FragColor)  (expression float + (swiz y (var_ref c) )(expression float * (var_ref t) (constant float (0.005000)) ) ) ) 
      (assign  (z) (var_ref gl_FragColor)  (expression float + (swiz z (var_ref c) )(expression float * (var_ref t) (constant float (0.012500)) ) ) ) 
      (assign  (w) (var_ref gl_FragColor)  (expression float + (swiz w (var_ref c) )(expression float * (var_ref t) (constant float (0.025000)) ) ) ) 
    ))

)


)

FS compile failed: no register to spill

Error: [string "graphics.lua"]:1370: Cannot compile shader:
FS compile failed: no register to spill


stack traceback:
	[C]: in function 'newPixelEffect'
	[string "graphics.lua"]:1370: in function 'newPixelEffect'
	main.lua:61: in function 'load'
	[string "boot.lua"]:350: in function <[string "boot.lua"]:348>
	[C]: in function 'xpcall'
pre-fp:
# Fragment Program/Shader 0
  0: TXP TEMP[0], INPUT[4], texture[0], 2D;
  1: MUL OUTPUT[2], TEMP[0], STATE[0];
  2: END

pass_fp:
  0: PIXELXY TEMP[97].xy, FILE15[30], UNDEFINED[0], UNDEFINED[0];
  1: DELTAXY TEMP[96].xy, TEMP[97], FILE15[30], UNDEFINED[0];
  2: PIXELW TEMP[98].w, FILE15[0], TEMP[96], UNDEFINED[0];
  3: PINTERP INPUT[4], FILE15[4], TEMP[96], TEMP[98];
  4: TEX TEMP[0], INPUT[4], texture[0], 2D;
  5: MUL OUTPUT[2], TEMP[0], STATE[0];
  6: FB_WRITE  ???, OUTPUT[2], FILE15[30], OUTPUT[0];

pass0:
[r0,r1,#,#].xy = PIXELXY
[r2,r3,#,#].xy = DELTAXY [r0,r1,undef,undef]
[#,#,#,r4].w = PIXELW [i0,undef,undef,undef] [r2,r3,undef,undef]
[r5,r6,r7,r8] = PINTERP [i4,undef,undef,undef] [r2,r3,undef,undef] [undef,undef,undef,r4]
[r9,r10,r11,r12] = TEX [r5,r6,r7,r8]
[r13,r14,r15,r16] = MUL [r9,r10,r11,r12] [c0,c0->0.4,c0->0.8,c0->0.12]
[#,#,#,#]. = FB_WRITE [r13,r14,r15,r16] [d0,d0,d0,d0] [undef,undef,undef,undef]

pass1:
[r0,r1,#,#].xy = PIXELXY
[r2,r3,#,#].xy = DELTAXY [r0,r1,%,%]
[#,#,#,r4].w = PIXELW [i0,%,%,%] [r2,r3,%,%]
[r5,r6,#,#].xy = PINTERP [i4,%,%,%] [r2,r3,%,%] [%,%,%,r4]
[r9,r10,r11,r12] = TEX [r5,r6,%,%]
[r13,r14,r15,r16] = MUL [r9,r10,r11,r12] [c0,c0->0.4,c0->0.8,c0->0.12]
[#,#,#,#]. = FB_WRITE [r13,r14,r15,r16] [d0,d0,d0,d0] [%,%,%,%]

pass2:
[r0,r1,#,#].xy = PIXELXY
[r2,r3,#,#].xy = DELTAXY [r0,r1,%,%]
[#,#,#,r4].w = PIXELW [i0,%,%,%] [r2,r3,%,%]
[r5,r6,#,#].xy = PINTERP [i4,%,%,%] [r2,r3,%,%] [%,%,%,r4]
[r9,r10,r11,r12] = TEX [r5,r6,%,%]
[r13,r14,r15,r16] = MUL [r9,r10,r11,r12] [c0,c0->0.4,c0->0.8,c0->0.12]
[#,#,#,#]. = FB_WRITE [r13,r14,r15,r16] [d0,d0,d0,d0] [%,%,%,%]

pass2/done:
[vec8,vec10,#,#].xy = PIXELXY
[vec12,vec14,#,#].xy = DELTAXY [vec8,vec10,%,%]
[#,#,#,vec8].w = PIXELW [vec4,%,%,%] [vec12,vec14,%,%]
[vec4,vec10,#,#].xy = PINTERP [vec6,%,%,%] [vec12,vec14,%,%] [%,%,%,vec8]
[vec12,vec14,vec16,vec18] = TEX [vec4,vec10,%,%]
[vec4,vec6,vec8,vec10] = MUL [vec12,vec14,vec16,vec18] [scl2.0,scl2.1,scl2.2,scl2.3]
[#,#,#,#]. = FB_WRITE [vec4,vec6,vec8,vec10] [vec0,vec0,vec0,vec0] [%,%,%,%]

wm-native:
add(16)         g8<1>UW         g1.4<2,4,0>UW   0x10101010V     { align1 };
add(16)         g10<1>UW        g1.5<2,4,0>UW   0x11001100V     { align1 };
add(16)         g12<1>F         g8<8,8,1>UW     -g1<0,1,0>F     { align1 compr };
add(16)         g14<1>F         g10<8,8,1>UW    -g1.1<0,1,0>F   { align1 compr };
line(16)        null            g5.4<0,1,0>F    g12<8,8,1>F     { align1 compr };
mac(16)         m2<1>F          g5.5<0,1,0>F    g14<8,8,1>F     { align1 compr };
send(8) 2       g8<1>F          null
                math inv mlen 1 rlen 1                          { align1 };
send(8) 3       g9<1>F          null
                math inv mlen 1 rlen 1                          { align1 sechalf };
line(16)        null            g6<0,1,0>F      g12<8,8,1>F     { align1 compr };
mac(16)         g4<1>F          g6.1<0,1,0>F    g14<8,8,1>F     { align1 compr };
line(16)        null            g6.4<0,1,0>F    g12<8,8,1>F     { align1 compr };
mac(16)         g10<1>F         g6.5<0,1,0>F    g14<8,8,1>F     { align1 compr };
mul(16)         g4<1>F          g4<8,8,1>F      g8<8,8,1>F      { align1 compr };
mul(16)         g10<1>F         g10<8,8,1>F     g8<8,8,1>F      { align1 compr };
mov(16)         m2<1>F          g4<8,8,1>F                      { align1 compr };
mov(16)         m4<1>F          g10<8,8,1>F                     { align1 compr };
send(16) 1      g12<1>UW        g0<8,8,1>UW
                sampler (9, 0, F) mlen 5 rlen 8                 { align1 };
mul(16)         g4<1>F          g12<8,8,1>F     g2<0,1,0>F      { align1 compr };
mul(16)         g6<1>F          g14<8,8,1>F     g2.1<0,1,0>F    { align1 compr };
mul(16)         g8<1>F          g16<8,8,1>F     g2.2<0,1,0>F    { align1 compr };
mul(16)         g10<1>F         g18<8,8,1>F     g2.3<0,1,0>F    { align1 compr };
mov.sat(16)     m2<1>F          g4<8,8,1>F                      { align1 compr4 };
mov.sat(16)     m3<1>F          g6<8,8,1>F                      { align1 compr4 };
mov.sat(16)     m4<1>F          g8<8,8,1>F                      { align1 compr4 };
mov.sat(16)     m5<1>F          g10<8,8,1>F                     { align1 compr4 };
mov(8)          m1<1>F          g1<8,8,1>F                      { align1 nomask };
send(16) 0      null            g0<8,8,1>UW
                write (0, 8, 4, 0) mlen 10 rlen 0               { align1 EOT };
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
RPG
Party member
Posts: 157
Joined: Wed Mar 02, 2011 5:02 am
Location: Russia
Contact:

Re: Share a Shader!

Post by RPG »

vrld wrote:So there is this gallery of webgl shader experiments, including simple games, and some pretty amazing ray casting thingies.

As it turns out, those demos are pretty easy to port to PixelEffects, so I ported a more simple looking (code wise) demo. I annotated some of the code to make it more understandable.
Maybe, ray tracing?
Ray cast - from light to camera.
Ray trace - from camera to light.

See also "shader toy"
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Share a Shader!

Post by GijsB »

RPG wrote:
vrld wrote:So there is this gallery of webgl shader experiments, including simple games, and some pretty amazing ray casting thingies.

As it turns out, those demos are pretty easy to port to PixelEffects, so I ported a more simple looking (code wise) demo. I annotated some of the code to make it more understandable.
Maybe, ray tracing?
Ray cast - from light to camera.
Ray trace - from camera to light.

See also "shader toy"
someone should really explain the real diffrence to me ._.
User avatar
slime
Solid Snayke
Posts: 3161
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Share a Shader!

Post by slime »

You would pick the metaball one. :P
I put one of the tunnel ones in LÖVE a while ago, but it was a straight port (overwriting the EffectCodeToGLSL function).
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Share a Shader!

Post by vrld »

RPG wrote:Maybe, ray tracing?
Ray cast - from light to camera.
Ray trace - from camera to light.
"Ray casting" is the general term for algorithms involving rays that intersect surfaces.
Because the use of a distance field/isosurface, it's not really ray tracing either. It's impossible (or at least very difficult) to analytically calculate the intersection of an isosurface with a ray, so they sample some points on the ray (the outer loop) and test if the point lies on or behind the surface (h(o + d*t) < threshold). This method is known as ray marching.
The thing I don't quite understand is how one conceives the formula of the distance field:

Code: Select all

number h(vec3 q)
{
	number f = distance(q, vec3(cos(time)+sin(time*.2), .3, 2.+cos(time*.5)*.5) );
	f *= distance( q, vec3(-cos(time*.7), .3,2. + sin(time*.5)) );
	f *= distance( q, vec3(-sin(time*.2) * .5, sin(time), 2.));
	f *= cos(q.y)*cos(q.x) - .1 - cos(q.z*7. + time*7.) * cos(q.x*3.) * cos(q.y*4.) * .1; // in particular this line
	return f;
}
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
RPG
Party member
Posts: 157
Joined: Wed Mar 02, 2011 5:02 am
Location: Russia
Contact:

Re: Share a Shader!

Post by RPG »

vrld wrote: The thing I don't quite understand is how one conceives the formula of the distance field:

Code: Select all

number h(vec3 q)
{
	number f = distance(q, vec3(cos(time)+sin(time*.2), .3, 2.+cos(time*.5)*.5) );
	f *= distance( q, vec3(-cos(time*.7), .3,2. + sin(time*.5)) );
	f *= distance( q, vec3(-sin(time*.2) * .5, sin(time), 2.));
	f *= cos(q.y)*cos(q.x) - .1 - cos(q.z*7. + time*7.) * cos(q.x*3.) * cos(q.y*4.) * .1; // in particular this line
	return f;
}
I think this code represents geometric primitives, that can be calculated mathematically (and intersection with the ray is solvable).
But ray tracing absolutely useless in games:)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests