Very nice I like
Not sure if you noticed this
Using Pixel or Fragment Shaders
https://steamcommunity.com/sharedfiles/filedetails/?id=370165947
I converted that pixel shader to show on a 3D Plane
#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
// 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)
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 createShader()
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 uvVarying;")
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,"mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file," uvVarying = uv * uvBounds0.xy + uvBounds0.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 uvVarying;")
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 = uvVarying;")
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 colorResult0 = vec4(finalColor,1.0);")
WriteLine(file,"//vec4 colorResult1 = texture2D(texture1, z);")
WriteLine(file,"gl_FragColor = vec4(finalColor,1.0);")
WriteLine(file,"//gl_FragColor = mix(colorResult0, colorResult1, colorResult1.a);")
WriteLine(file,"}")
CloseFile(file)
endfunction
and in the process of making the shader so it mixes two textures so that only alpha channel does the fractal effect
so i can have a second texture created like
function createEllipse()
rem create an ellipse that can be used as a sprite and returns the value of the image
rem this was only used in early versions
SetClearColor(0,0,0)
ClearScreen()
Render()
DrawBox(0,0,100,100,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawEllipse(50,50,25,25,MakeColor(0,0,0),MakeColor(0,0,0),1)
Swap()
img = getimage(0,0,100,100)
sync()
endfunction img
And use it like its some sort of lava pool
fubar