What's SparkSL date equivalent?

I searched a lot in the internet and couldn’t find “date” equivalent for SparkSL
anybody knows how can we convert iDate from shaderToy to SparkSL ?

You will need to use script to get the date, then pass it to patches, then pass it to the shader. When they say “uniforms,” they mean the shader inputs. You are expected to get delta time, date, and mouse position by some method outside of the shader, then supply it as an input.

The date API in spark has been a little buggy, but you can use the standard date object, same as on the web. Date - JavaScript | MDN

1 Like

Thank you so much Mr. Beckwith
I converted a clock shader from shadertoy to Spark SL based on your solution and I also uploaded the project for anybody who may need it in the future :pray:
ShaderToy Clock Example.arexport (48.8 KB)

1 Like

Nice, thanks for sharing! I made a video so others can see what it looks like.


Very cool!
What is the easiest way to remove the background? Leave the watch alone. Failed to try :cry:

The background color is defined under the comment. You can replace this with your own background by sampling a texture, or just defining a solid color. This is a white background (which is probably not what you want, but here it is for reference)

// background color
// vec3 nightColor = vec3( 0.2, 0.2, 0.2 ) + 0.1*uv.y;
// vec3 dayColor   = vec3( 0.5, 0.6, 0.7 ) + 0.2*uv.y;
// vec3 col = mix( nightColor, dayColor, smoothstep( 5.0, 7.0, hors ) - 
// 			                          smoothstep(19.0,21.0, hors ) );
vec3 col = vec3(1., 1., 1.);

You can also disable this line if you want the face to be transparent.

// inner watch body	
// col = mix( col, vec3(0.9-0.4*pow(r,4.0)), 1.0-smoothstep(0.94,0.95,r) );