Initial Commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
//-------------------------------------------------------------
|
||||
// Display endless moving background using a tile texture.
|
||||
// Contributed by martiSteiger
|
||||
//-------------------------------------------------------------
|
||||
|
||||
PImage tileTexture;
|
||||
PShader tileShader;
|
||||
|
||||
void setup() {
|
||||
size(640, 480, P2D);
|
||||
textureWrap(REPEAT);
|
||||
tileTexture = loadImage("penrose.jpg");
|
||||
loadTileShader();
|
||||
}
|
||||
|
||||
void loadTileShader() {
|
||||
tileShader = loadShader("scroller.glsl");
|
||||
tileShader.set("resolution", float(width), float(height));
|
||||
tileShader.set("tileImage", tileTexture);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
tileShader.set("time", millis() / 1000.0);
|
||||
shader(tileShader);
|
||||
rect(0, 0, width, height);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
@@ -0,0 +1,17 @@
|
||||
//---------------------------------------------------------
|
||||
// Display endless moving background using a tile texture.
|
||||
// Contributed by martiSteiger
|
||||
//---------------------------------------------------------
|
||||
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform sampler2D tileImage;
|
||||
|
||||
#define TILES_COUNT_X 4.0
|
||||
|
||||
void main() {
|
||||
vec2 pos = gl_FragCoord.xy - vec2(4.0 * time);
|
||||
vec2 p = (resolution - TILES_COUNT_X * pos) / resolution.x;
|
||||
vec3 col = texture2D (tileImage, p).xyz;
|
||||
gl_FragColor = vec4 (col, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user