FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Replaced old Landscape example with Elevated from shadertoy · markluffel/processing@ef4e1aa · GitHub

Repository navigation

Commit ef4e1aa

Browse files
committed
Replaced old Landscape example with Elevated from shadertoy
1 parent c05adf1 commit ef4e1aa

2 files changed

Lines changed: 309 additions & 186 deletions

File tree

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
/**
2-
* Landscape
3-
* Simple raymarching shader with camera, originally by Paulo Falcão
4-
* Ported from the webGL version in GLSL Sandbox:
5-
* http://glsl.heroku.com/e#3213.0
6-
*
2+
* Elevated
3+
* https://www.shadertoy.com/view/MdX3Rr by inigo quilez
4+
* Created by inigo quilez - iq/2013
5+
* License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
6+
* Processing port by Raphaël de Courville.
77
*/
88

9-
PShader landscape;
10-
PGraphics pg;
9+
PShader shader;
1110

1211
void setup() {
1312
size(640, 360, P2D);
14-
15-
// This effect can be too demanding on older GPUs,
16-
// so we render it on a smaller res offscreen surface
17-
pg = createGraphics(320, 180, P2D);
18-
pg.noStroke();
19-
20-
landscape = loadShader("landscape.glsl");
21-
landscape.set("resolution", float(width), float(height));
13+
noStroke();
14+
15+
// The code of this shader shows how to integrate shaders from shadertoy
16+
// into Processing with minimal changes.
17+
shader = loadShader("landscape.glsl");
18+
shader.set("resolution", float(width), float(height));
2219
}
2320

2421
void draw() {
25-
landscape.set("time", millis() / 1000.0);
26-
landscape.set("mouse", float(mouseX), height - float(mouseY));
27-
28-
// This kind of raymarching effects are entirely implemented in the
29-
// fragment shader, they only need a quad covering the entire view
30-
// area so every pixel is pushed through the shader.
31-
pg.beginDraw();
32-
pg.shader(landscape);
33-
pg.rect(0, 0, width, height);
34-
pg.endDraw();
22+
background(0);
23+
24+
shader.set("time", (float)(millis()/1000.0));
25+
shader(shader);
26+
rect(0, 0, width, height);
3527

36-
// Scaling up offscreen surface to cover entire screen.
37-
image(pg, 0, 0, width, height);
28+
frame.setTitle("frame: " + frameCount + " - fps: " + frameRate);
3829
}
30+

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL