The
Kaleidoscope Shader now has the ability to have a mask texture
by adding a second texture to the object it will not draw on transparency
sections where they exist on the second layer
#constant screenWidth=1024
#constant screenHeight=768
SetWindowSize(screenWidth,screenHeight,0)
Setvirtualresolution(screenWidth,screenHeight)
// set variables for camera's starting position
pos_x# = 0
pos_y# = 50
pos_z# = 0
createEllipseForPortals(2)
// orientate camera
SetCameraRotation(1,30,0,0)
SetCameraPosition(1,pos_x#,pos_y#,pos_z#)
CreateObjectPlane(2,500,500)
SetObjectRotation(2,90,0,0)
SetObjectPosition(2,0,-17,250)
//dont set a second image if you dont want to have transparency layer added where any color that isnt transparent makes use of the Kali
SetObjectImage(2,2,1)
SetObjectTransparency(2,1) //needed or the transparency will show as black on the object
createShader()
Shader=LoadShader( "Kaliset.vs","Kaliset.ps" )
SetObjectShader(2,Shader)
SetShaderConstantByName( Shader,"iResolution",500,500,0,0 )
do
SetShaderConstantByName( Shader,"iGlobalTime",Timer()*.5,0,0,0 ) `tell the shader what time it is - so it can update its animations
print(ScreenFPS())
sync()
loop
function createEllipseForPortals(img as integer)
rem create an ellipse that can be used as a sprite
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,100,100,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawEllipse(50,50,50,50,MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawEllipse(50,50,20,20,MakeColor(0,0,0),MakeColor(0,0,0),1) //comment out this line if you dont like donuts lol
Swap()
getimage(img,0,0,100,100)
SetImageTransparentColor(img,0,0,0)
sync()
endfunction
function createShader()
//create the shader used for the port holes
if GetFileExists("Kaliset.vs") then DeleteFile("Kaliset.vs")
file = OpenToWrite("Kaliset.vs")
WriteLine(file,"attribute highp vec3 position;")
WriteLine(file,"attribute mediump vec3 normal;")
WriteLine(file,"attribute mediump vec2 uv;")
WriteLine(file,"varying highp vec3 posVarying;")
WriteLine(file,"varying mediump vec3 normalVarying;")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"varying mediump vec3 lightVarying;")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"uniform vec3 iChannelResolution[10]; // channel resolution (in pixels)")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"uniform highp mat3 agk_WorldNormal;")
WriteLine(file,"uniform highp mat4 agk_World;")
WriteLine(file,"uniform highp mat4 agk_ViewProj;")
WriteLine(file,"uniform mediump vec4 uvBounds0;")
WriteLine(file,"uniform mediump vec4 uvBounds1;")
WriteLine(file,"mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file," uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;")
WriteLine(file," uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;")
WriteLine(file," highp vec4 pos = agk_World * vec4(position,1.0);")
WriteLine(file," gl_Position = agk_ViewProj * pos;")
WriteLine(file," mediump vec3 norm = normalize(agk_WorldNormal * normal);")
WriteLine(file," posVarying = pos.xyz;")
WriteLine(file," normalVarying = norm;")
WriteLine(file," lightVarying = GetVSLighting( norm, posVarying );")
WriteLine(file,"}")
CloseFile(file)
if GetFileExists("Kaliset.ps") then DeleteFile("Kaliset.ps")
file = OpenToWrite("Kaliset.ps")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel ")
WriteLine(file,"uniform sampler2D texture1; // input channel ")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"const int iterations=12;")
WriteLine(file,"void main(void)")
WriteLine(file,"{")
WriteLine(file,"//this takes the pixel we are working with to determine where it is on the screen")
//WriteLine(file,"vec2 z = gl_FragCoord.xy/iResolution.xy;")
WriteLine(file,"vec2 z = uv0Varying;")
WriteLine(file,"//fixes aspect ratio in favor of symmety. comment it and see what it looks like")
WriteLine(file,"//z.y*=iResolution.y/iResolution.x;")
WriteLine(file,"//gloobywavez")
WriteLine(file,"z.x += sin(z.y*2.0+iGlobalTime * .2)/10.0;")
WriteLine(file,"//zooom")
WriteLine(file,"//z*= 1.2 + sin(iGlobalTime*.15);")
WriteLine(file,"//pan")
WriteLine(file,"//z+=vec2(sin(iGlobalTime*.2),cos(iGlobalTime*.01));")
WriteLine(file,"//rotate")
WriteLine(file,"//z=vec2(z.x*cos(iGlobalTime*.2)- z.y*sin(iGlobalTime*.2),z.y*cos(iGlobalTime*.2));")
WriteLine(file,"vec2 c=vec2(0.5, 1.1);")
WriteLine(file,"")
WriteLine(file,"float average=0.;")
WriteLine(file,"float l=length(z);")
WriteLine(file,"float prevl;")
WriteLine(file,"for (int i=0; i<iterations; i++)")
WriteLine(file,"{")
WriteLine(file,"//kaliset base form")
WriteLine(file,"z=abs(z)/dot(z,z) -c;")
WriteLine(file,"//this is another function that can be iterated to produce some different fractals")
WriteLine(file,"//comment out the previous kaliset and experiment with values with this one!!")
WriteLine(file,"//z = abs(z)/(z.x*z.y)-c;")
WriteLine(file,"prevl=l;")
WriteLine(file,"l=length(z);")
WriteLine(file,"average+=abs(l-prevl);")
WriteLine(file,"}")
WriteLine(file,"//get the average length based upon the amount of iterations elapsed. multiply it to adjust definition")
WriteLine(file,"average/=float(iterations) * 15.;")
WriteLine(file,"//color fluctuation")
WriteLine(file,"average+=iGlobalTime*0.08;")
WriteLine(file,"vec3 myColor=vec3(0.2,0.21,.62);")
WriteLine(file,"vec3 finalColor;")
WriteLine(file,"//set the colors!")
WriteLine(file,"finalColor.r = (fract(float(average)/myColor.r));")
WriteLine(file,"finalColor.g = (fract(float(average)/myColor.g));")
WriteLine(file,"finalColor.b = (fract(float(average)/myColor.b));")
WriteLine(file,"vec4 colorResult1 = texture2D(texture1, uv1Varying);")
WriteLine(file,"gl_FragColor = mix(colorResult1,vec4(finalColor,1.0), colorResult1.a);")
WriteLine(file,"}")
CloseFile(file)
endfunction
3D Kaleidoscope using 3 textures and blended allowing for the kali to be placed on a wall for example
#constant screenWidth=1024
#constant screenHeight=768
SetWindowSize(screenWidth,screenHeight,0)
Setvirtualresolution(screenWidth,screenHeight)
// set variables for camera's starting position
pos_x# = 0
pos_y# = 50
pos_z# = 0
createEllipseForPortals(2)
createWallTexture(3)
// orientate camera
SetCameraRotation(1,30,0,0)
SetCameraPosition(1,pos_x#,pos_y#,pos_z#)
CreateObjectPlane(2,500,500)
SetObjectRotation(2,90,0,0)
SetObjectPosition(2,0,-17,250)
//dont set a second image if you dont want to have transparency layer added where any color that isnt transparent makes use of the Kali
SetObjectImage(2,2,1)
SetObjectImage(2,3,2)
SetObjectTransparency(2,1) //needed or the transparency will show as black on the object
createShader()
Shader=LoadShader( "Kaliset.vs","Kaliset.ps" )
SetObjectShader(2,Shader)
SetShaderConstantByName( Shader,"iResolution",500,500,0,0 )
do
SetShaderConstantByName( Shader,"iGlobalTime",Timer()*.5,0,0,0 ) `tell the shader what time it is - so it can update its animations
print(ScreenFPS())
sync()
loop
function createEllipseForPortals(img as integer)
rem create an ellipse that can be used as a sprite
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,512,512,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//DrawEllipse(50,50,50,50,MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawEllipse(256,256,256,256,MakeColor(255,255,255),MakeColor(0,0,0),1) //comment out this line if you dont like donuts lol
Swap()
getimage(img,0,0,512,512)
SetImageTransparentColor(img,0,0,0)
sync()
endfunction
function createWallTexture(img as integer)
ClearScreen()
Render()
DrawBox(0,0,512,512,MakeColor(155,155,155),MakeColor(155,155,155),MakeColor(155,155,155),MakeColor(155,155,155),1)
x=-5:y=0:oldX=0
repeat
repeat
DrawBox(x,y,x+5,y+1,MakeColor(155,5,5),MakeColor(155,5,5),MakeColor(155,5,5),MakeColor(155,5,5),1)
x=x+6
until x>512+5
if oldx=-5
x=-2:oldx=-2
else
x=-5:oldx=-5
endif
y=y+3
until y>512+2
Swap()
getimage(img,0,0,512,512)
sync()
endfunction
function createShader()
//create the shader used for the port holes
if GetFileExists("Kaliset.vs") then DeleteFile("Kaliset.vs")
file = OpenToWrite("Kaliset.vs")
WriteLine(file,"attribute highp vec3 position;")
WriteLine(file,"attribute mediump vec3 normal;")
WriteLine(file,"attribute mediump vec2 uv;")
WriteLine(file,"varying highp vec3 posVarying;")
WriteLine(file,"varying mediump vec3 normalVarying;")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"varying mediump vec2 uv2Varying;")
WriteLine(file,"varying mediump vec3 lightVarying;")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"uniform vec3 iChannelResolution[10]; // channel resolution (in pixels)")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"uniform highp mat3 agk_WorldNormal;")
WriteLine(file,"uniform highp mat4 agk_World;")
WriteLine(file,"uniform highp mat4 agk_ViewProj;")
WriteLine(file,"uniform mediump vec4 uvBounds0;")
WriteLine(file,"uniform mediump vec4 uvBounds1;")
WriteLine(file,"uniform mediump vec4 uvBounds2;")
WriteLine(file,"mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file," uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;")
WriteLine(file," uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;")
WriteLine(file," uv2Varying = uv * uvBounds2.xy + uvBounds2.zw;")
WriteLine(file," highp vec4 pos = agk_World * vec4(position,1.0);")
WriteLine(file," gl_Position = agk_ViewProj * pos;")
WriteLine(file," mediump vec3 norm = normalize(agk_WorldNormal * normal);")
WriteLine(file," posVarying = pos.xyz;")
WriteLine(file," normalVarying = norm;")
WriteLine(file," lightVarying = GetVSLighting( norm, posVarying );")
WriteLine(file,"}")
CloseFile(file)
if GetFileExists("Kaliset.ps") then DeleteFile("Kaliset.ps")
file = OpenToWrite("Kaliset.ps")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel ")
WriteLine(file,"uniform sampler2D texture1; // input channel ")
WriteLine(file,"uniform sampler2D texture2; // input channel ")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"varying mediump vec2 uv2Varying;")
WriteLine(file,"const int iterations=12;")
WriteLine(file,"void main(void)")
WriteLine(file,"{")
WriteLine(file,"//this takes the pixel we are working with to determine where it is on the screen")
//WriteLine(file,"vec2 z = gl_FragCoord.xy/iResolution.xy;")
WriteLine(file,"vec2 z = uv0Varying;")
WriteLine(file,"//fixes aspect ratio in favor of symmety. comment it and see what it looks like")
WriteLine(file,"//z.y*=iResolution.y/iResolution.x;")
WriteLine(file,"//gloobywavez")
WriteLine(file,"z.x += sin(z.y*2.0+iGlobalTime * .2)/10.0;")
WriteLine(file,"//zooom")
WriteLine(file,"//z*= 1.2 + sin(iGlobalTime*.15);")
WriteLine(file,"//pan")
WriteLine(file,"//z+=vec2(sin(iGlobalTime*.2),cos(iGlobalTime*.01));")
WriteLine(file,"//rotate")
WriteLine(file,"//z=vec2(z.x*cos(iGlobalTime*.2)- z.y*sin(iGlobalTime*.2),z.y*cos(iGlobalTime*.2));")
WriteLine(file,"vec2 c=vec2(0.5, 1.1);")
WriteLine(file,"")
WriteLine(file,"float average=0.;")
WriteLine(file,"float l=length(z);")
WriteLine(file,"float prevl;")
WriteLine(file,"for (int i=0; i<iterations; i++)")
WriteLine(file,"{")
WriteLine(file,"//kaliset base form")
WriteLine(file,"z=abs(z)/dot(z,z) -c;")
WriteLine(file,"//this is another function that can be iterated to produce some different fractals")
WriteLine(file,"//comment out the previous kaliset and experiment with values with this one!!")
WriteLine(file,"//z = abs(z)/(z.x*z.y)-c;")
WriteLine(file,"prevl=l;")
WriteLine(file,"l=length(z);")
WriteLine(file,"average+=abs(l-prevl);")
WriteLine(file,"}")
WriteLine(file,"//get the average length based upon the amount of iterations elapsed. multiply it to adjust definition")
WriteLine(file,"average/=float(iterations) * 15.;")
WriteLine(file,"//color fluctuation")
WriteLine(file,"average+=iGlobalTime*0.08;")
WriteLine(file,"vec3 myColor=vec3(0.2,0.21,.62);")
WriteLine(file,"vec3 finalColor;")
WriteLine(file,"//set the colors!")
WriteLine(file,"finalColor.r = (fract(float(average)/myColor.r));")
WriteLine(file,"finalColor.g = (fract(float(average)/myColor.g));")
WriteLine(file,"finalColor.b = (fract(float(average)/myColor.b));")
WriteLine(file,"vec4 colorResult1 = texture2D(texture1, uv1Varying);")
WriteLine(file,"vec4 colorResult2 = mix(colorResult1,vec4(finalColor,1.0), colorResult1.a);")
//WriteLine(file,"vec4 colorResult3 = texture2D(texture2, uv2Varying);")
WriteLine(file,"vec4 colorResult3 = mix(texture2D(texture2,uv2Varying),colorResult2,colorResult1.a);")
//WriteLine(file,"gl_FragColor = mix(colorResult3,colorResult1,colorResult2);")
WriteLine(file,"gl_FragColor = colorResult3;")
WriteLine(file,"}")
CloseFile(file)
endfunction
3D Kaleidoscope A slightly different method of blending 3 textures with it that should just be tried but the most usefull of the lot I think
#constant screenWidth=1024
#constant screenHeight=768
SetWindowSize(screenWidth,screenHeight,0)
Setvirtualresolution(screenWidth,screenHeight)
// set variables for camera's starting position
pos_x# = 0
pos_y# = 50
pos_z# = 0
createEllipseForPortals(2)
createWallTexture(3)
// orientate camera
SetCameraRotation(1,30,0,0)
SetCameraPosition(1,pos_x#,pos_y#,pos_z#)
CreateObjectPlane(2,500,500)
SetObjectRotation(2,90,0,0)
SetObjectPosition(2,0,-17,250)
//dont set a second image if you dont want to have transparency layer added where any color that isnt transparent makes use of the Kali
SetObjectImage(2,2,1)
SetObjectImage(2,3,2)
SetObjectTransparency(2,1) //needed or the transparency will show as black on the object
createShader()
Shader=LoadShader( "Kaliset.vs","Kaliset.ps" )
SetObjectShader(2,Shader)
SetShaderConstantByName( Shader,"iResolution",500,500,0,0 )
do
SetShaderConstantByName( Shader,"iGlobalTime",Timer()*.5,0,0,0 ) `tell the shader what time it is - so it can update its animations
print(ScreenFPS())
sync()
loop
function createEllipseForPortals(img as integer)
rem create an ellipse that can be used as a sprite
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,512,512,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//DrawEllipse(50,50,50,50,MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawEllipse(256,256,256,256,MakeColor(255,255,255),MakeColor(0,0,0),1) //comment out this line if you dont like donuts lol
Swap()
getimage(img,0,0,512,512)
SetImageTransparentColor(img,0,0,0)
sync()
endfunction
function createWallTexture(img as integer)
ClearScreen()
Render()
DrawBox(0,0,512,512,MakeColor(155,155,155),MakeColor(155,155,155),MakeColor(155,155,155),MakeColor(155,155,155),1)
x=-5:y=0:oldX=0
repeat
repeat
DrawBox(x,y,x+5,y+1,MakeColor(155,5,5),MakeColor(155,5,5),MakeColor(155,5,5),MakeColor(155,5,5),1)
x=x+6
until x>512+5
if oldx=-5
x=-2:oldx=-2
else
x=-5:oldx=-5
endif
y=y+3
until y>512+2
Swap()
getimage(img,0,0,512,512)
sync()
endfunction
function createShader()
//create the shader used for the port holes
if GetFileExists("Kaliset.vs") then DeleteFile("Kaliset.vs")
file = OpenToWrite("Kaliset.vs")
WriteLine(file,"attribute highp vec3 position;")
WriteLine(file,"attribute mediump vec3 normal;")
WriteLine(file,"attribute mediump vec2 uv;")
WriteLine(file,"varying highp vec3 posVarying;")
WriteLine(file,"varying mediump vec3 normalVarying;")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"varying mediump vec2 uv2Varying;")
WriteLine(file,"varying mediump vec3 lightVarying;")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"uniform vec3 iChannelResolution[10]; // channel resolution (in pixels)")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"uniform highp mat3 agk_WorldNormal;")
WriteLine(file,"uniform highp mat4 agk_World;")
WriteLine(file,"uniform highp mat4 agk_ViewProj;")
WriteLine(file,"uniform mediump vec4 uvBounds0;")
WriteLine(file,"uniform mediump vec4 uvBounds1;")
WriteLine(file,"uniform mediump vec4 uvBounds2;")
WriteLine(file,"mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file," uv0Varying = uv * uvBounds0.xy + uvBounds0.zw;")
WriteLine(file," uv1Varying = uv * uvBounds1.xy + uvBounds1.zw;")
WriteLine(file," uv2Varying = uv * uvBounds2.xy + uvBounds2.zw;")
WriteLine(file," highp vec4 pos = agk_World * vec4(position,1.0);")
WriteLine(file," gl_Position = agk_ViewProj * pos;")
WriteLine(file," mediump vec3 norm = normalize(agk_WorldNormal * normal);")
WriteLine(file," posVarying = pos.xyz;")
WriteLine(file," normalVarying = norm;")
WriteLine(file," lightVarying = GetVSLighting( norm, posVarying );")
WriteLine(file,"}")
CloseFile(file)
if GetFileExists("Kaliset.ps") then DeleteFile("Kaliset.ps")
file = OpenToWrite("Kaliset.ps")
WriteLine(file,"uniform vec3 iResolution; // viewport resolution (in pixels)")
WriteLine(file,"uniform float iGlobalTime; // shader playback time (in seconds)")
WriteLine(file,"uniform float iChannelTime[10]; // channel playback time (in seconds)")
WriteLine(file,"")
WriteLine(file,"//uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down)")
WriteLine(file,"uniform sampler2D texture0; // input channel ")
WriteLine(file,"uniform sampler2D texture1; // input channel ")
WriteLine(file,"uniform sampler2D texture2; // input channel ")
WriteLine(file,"uniform vec4 iDate; // (year, month, day, time in seconds)")
WriteLine(file,"varying mediump vec2 uv0Varying;")
WriteLine(file,"varying mediump vec2 uv1Varying;")
WriteLine(file,"varying mediump vec2 uv2Varying;")
WriteLine(file,"const int iterations=12;")
WriteLine(file,"void main(void)")
WriteLine(file,"{")
WriteLine(file,"//this takes the pixel we are working with to determine where it is on the screen")
//WriteLine(file,"vec2 z = gl_FragCoord.xy/iResolution.xy;")
WriteLine(file,"vec2 z = uv0Varying;")
WriteLine(file,"//fixes aspect ratio in favor of symmety. comment it and see what it looks like")
WriteLine(file,"//z.y*=iResolution.y/iResolution.x;")
WriteLine(file,"//gloobywavez")
WriteLine(file,"z.x += sin(z.y*2.0+iGlobalTime * .2)/10.0;")
WriteLine(file,"//zooom")
WriteLine(file,"//z*= 1.2 + sin(iGlobalTime*.15);")
WriteLine(file,"//pan")
WriteLine(file,"//z+=vec2(sin(iGlobalTime*.2),cos(iGlobalTime*.01));")
WriteLine(file,"//rotate")
WriteLine(file,"//z=vec2(z.x*cos(iGlobalTime*.2)- z.y*sin(iGlobalTime*.2),z.y*cos(iGlobalTime*.2));")
WriteLine(file,"vec2 c=vec2(0.5, 1.1);")
WriteLine(file,"")
WriteLine(file,"float average=0.;")
WriteLine(file,"float l=length(z);")
WriteLine(file,"float prevl;")
WriteLine(file,"for (int i=0; i<iterations; i++)")
WriteLine(file,"{")
WriteLine(file,"//kaliset base form")
WriteLine(file,"z=abs(z)/dot(z,z) -c;")
WriteLine(file,"//this is another function that can be iterated to produce some different fractals")
WriteLine(file,"//comment out the previous kaliset and experiment with values with this one!!")
WriteLine(file,"//z = abs(z)/(z.x*z.y)-c;")
WriteLine(file,"prevl=l;")
WriteLine(file,"l=length(z);")
WriteLine(file,"average+=abs(l-prevl);")
WriteLine(file,"}")
WriteLine(file,"//get the average length based upon the amount of iterations elapsed. multiply it to adjust definition")
WriteLine(file,"average/=float(iterations) * 15.;")
WriteLine(file,"//color fluctuation")
WriteLine(file,"average+=iGlobalTime*0.08;")
WriteLine(file,"vec3 myColor=vec3(0.2,0.21,.62);")
WriteLine(file,"vec3 finalColor;")
WriteLine(file,"//set the colors!")
WriteLine(file,"finalColor.r = (fract(float(average)/myColor.r));")
WriteLine(file,"finalColor.g = (fract(float(average)/myColor.g));")
WriteLine(file,"finalColor.b = (fract(float(average)/myColor.b));")
WriteLine(file,"vec4 colorResult1 = texture2D(texture1, uv1Varying);")
WriteLine(file,"vec4 colorResult2 = mix(colorResult1,vec4(finalColor,1.0), colorResult1.a);")
WriteLine(file,"vec4 colorResult3 = texture2D(texture2, uv2Varying);")
//WriteLine(file,"vec4 colorResult3 = mix(texture2D(texture2,uv2Varying),colorResult2,colorResult1.a);")
WriteLine(file,"gl_FragColor = mix(colorResult3,colorResult1,colorResult2);")
//WriteLine(file,"gl_FragColor = colorResult3;")
WriteLine(file,"}")
CloseFile(file)
endfunction
Using 3 Textures makes a great portal on a wall it really can be any shape you want now (perhaps even a person outline)
or used in one section of the model
Here is what happens when you turn the bonnet of the car into a Kali
SetObjectImage(carID,1,1) //the masking texture
SetObjectImage(carID,2,2) //the normal texture
SetObjectImage(carID,2,0) //the normal texture
fubar