Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 54dd060

Browse files
committed
moving examples to root
1 parent a8e9977 commit 54dd060

File tree

75 files changed

+164
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+164
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// From cloud textures from
2+
// Realistic and Fast Cloud Rendering, Niniane Wang
3+
// http://jgt.akpeters.com/papers/Wang04/
4+
// fig. 6
5+
6+
PShader pointShader;
7+
PImage cloud1;
8+
PImage cloud2;
9+
PImage cloud3;
10+
11+
float weight = 100;
12+
13+
void setup() {
14+
size(640, 360, P3D);
15+
16+
pointShader = loadShader("spritefrag.glsl", "spritevert.glsl");
17+
pointShader.set("weight", weight);
18+
cloud1 = loadImage("cloud1.png");
19+
cloud2 = loadImage("cloud2.png");
20+
cloud3 = loadImage("cloud3.png");
21+
pointShader.set("sprite", cloud1);
22+
23+
strokeWeight(weight);
24+
strokeCap(SQUARE);
25+
stroke(255, 70);
26+
27+
background(0);
28+
}
29+
30+
void draw() {
31+
shader(pointShader, POINTS);
32+
if (mousePressed) {
33+
point(mouseX, mouseY);
34+
}
35+
}
36+
37+
void mousePressed() {
38+
if (key == '1') {
39+
pointShader.set("sprite", cloud1);
40+
} else if (key == '2') {
41+
pointShader.set("sprite", cloud2);
42+
} else if (key == '3') {
43+
pointShader.set("sprite", cloud3);
44+
}
45+
}
24.3 KB
30.4 KB
34.6 KB
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifdef GL_ES
2+
precision mediump float;
3+
precision mediump int;
4+
#endif
5+
6+
uniform sampler2D sprite;
7+
8+
varying vec4 vertColor;
9+
varying vec2 texCoord;
10+
11+
void main() {
12+
gl_FragColor = texture2D(sprite, texCoord) * vertColor;
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#define PROCESSING_POINT_SHADER
2+
3+
uniform mat4 projection;
4+
uniform mat4 modelview;
5+
6+
uniform float weight;
7+
8+
attribute vec4 vertex;
9+
attribute vec4 color;
10+
attribute vec2 offset;
11+
12+
varying vec4 vertColor;
13+
varying vec2 texCoord;
14+
15+
void main() {
16+
vec4 pos = modelview * vertex;
17+
vec4 clip = projection * pos;
18+
19+
gl_Position = clip + projection * vec4(offset, 0, 0);
20+
21+
texCoord = (vec2(0.5) + offset / weight);
22+
23+
vertColor = color;
24+
}
File renamed without changes.

0 commit comments

Comments
 (0)