Skip to content

Commit 1e29c55

Browse files
committed
converted to sksl
1 parent 0509ee6 commit 1e29c55

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

shadowtoy/Mouse "Tutorial".sksl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
uniform vec3 iResolution; // viewport resolution (in pixels)
2+
uniform float iTime; // shader playback time (in seconds)
3+
uniform float iTimeDelta; // render time (in seconds)
4+
uniform float iFrameRate; // shader frame rate
5+
uniform int iFrame; // shader playback frame
6+
uniform float iChannelTime[4]; // channel playback time (in seconds)
7+
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
8+
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
9+
uniform vec4 iDate; // (year, month, day, time in seconds)
10+
uniform float iSampleRate; // sound sample rate (i.e., 44100)
11+
12+
vec4 main(vec2 fragCoord)
13+
{
14+
vec3 col = vec3(0.);
15+
16+
//Draw a red cross where the mouse button was last down.
17+
if(abs(iMouse.x-fragCoord.x) < 4.) {
18+
col = vec3(1.,0.,0.);
19+
}
20+
if(abs(iMouse.y-fragCoord.y) < 4.) {
21+
col = vec3(1.,0.,0.);
22+
}
23+
24+
//If the button is currently up, (iMouse.z, iMouse.w) is where the mouse
25+
//was when the button last went down.
26+
if(abs(iMouse.z-fragCoord.x) < 2.) {
27+
col = vec3(0.,0.,1.);
28+
}
29+
if(abs(iMouse.w-fragCoord.y) < 2.) {
30+
col = vec3(0.,0.,1.);
31+
}
32+
33+
//If the button is currently down, (-iMouse.z, -iMouse.w) is where
34+
//the button was when the click occurred.
35+
if(abs(-iMouse.z-fragCoord.x) < 2.) {
36+
col = vec3(0.,1.,0.);
37+
}
38+
if(abs(-iMouse.w-fragCoord.y) < 2.) {
39+
col = vec3(0.,1.,0.);
40+
}
41+
42+
return vec4(col, 1.0);
43+
}

0 commit comments

Comments
 (0)