-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f56d45
commit dd682e6
Showing
23 changed files
with
1,198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//? #version 430 | ||
//? uniform int u_NbOfParticles; uniform float u_aspectRatio; uniform int u_count; uniform int u_LR; uniform int u_UD; uniform int u_wheel; uniform int u_ctrlWheel; uniform int u_shiftWheel; uniform int u_altWheel; uniform float u_seed; uniform vec2 u_xySeed; float rand(float seedX, float seedY); | ||
|
||
//? vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
vec2 getPosition(uint particleID) { | ||
return shape(particleID / float(u_NbOfParticles), vec2(0.0), u_shiftWheel*0.1 + 0.9, u_wheel * 3.141592653 / 24.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//? #version 430 | ||
//? vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
// Included by the shape | ||
//? uniform int u_NbOfParticles; | ||
//? uniform float u_aspectRatio; | ||
//? // Params | ||
//? uniform int u_count; | ||
//? uniform int u_LR; | ||
//? uniform int u_UD; | ||
//? uniform int u_wheel; | ||
//? uniform int u_ctrlWheel; | ||
//? uniform int u_shiftWheel; | ||
//? uniform int u_altWheel; | ||
//? // Random | ||
//? uniform float u_seed; | ||
//? uniform vec2 u_xySeed; | ||
//? float rand(float id, float seed); | ||
|
||
vec2 getPosition(uint particleID) { | ||
int clusterSize = u_NbOfParticles / u_count; | ||
int clusterID = min(int(particleID) / clusterSize, u_count-1); | ||
float clusterCoord = (particleID % clusterSize) / float(clusterSize); | ||
|
||
vec2 center = vec2(rand(clusterID, u_seed + u_xySeed.y), rand(clusterID, u_seed + u_xySeed.x)); | ||
center.x *= u_aspectRatio; | ||
float radiusVar = 0.15; | ||
float radius = 0.33 * (u_shiftWheel*0.1+1.0) * (1 + 2 * radiusVar * rand(clusterID + 789.321, u_seed + 123.456) - radiusVar); | ||
center.x = clamp(center.x, -u_aspectRatio + radius, u_aspectRatio - radius); | ||
center.y = clamp(center.y, -1.0 + radius, 1.0 - radius); | ||
return shape(clusterCoord, center, radius, u_wheel * 3.141592653 / 24.0 + 6.28 * rand(clusterID, u_seed + 123.456)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//? #version 430 | ||
|
||
//? uniform int u_NbOfParticles; | ||
//? uniform float u_aspectRatio; | ||
// Parameters | ||
//? uniform int u_wheel; | ||
//? uniform int u_shiftWheel; | ||
//? uniform int u_altWheel; | ||
//? uniform int u_count; | ||
//? uniform int u_UD; | ||
//? uniform int u_LR; // I wouldn't recommend using this one for the layouts, see comments in the bottom section | ||
//? uniform int u_ctrlWheel; // I wouldn't recommend using this one for the layouts, see comments in the bottom section | ||
//Random | ||
//? uniform float u_seed; | ||
//? uniform vec2 u_xySeed; | ||
//? float rand(float seedX, float seedY); | ||
|
||
//? vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
vec2 getPosition(uint particleID) { | ||
float t = particleID / float(u_NbOfParticles); | ||
vec2 center = vec2(0.); | ||
float radius = u_shiftWheel*0.1 + 0.9; | ||
|
||
int N = max(u_UD + 6, 1); | ||
int id = int(floor(t * N)); | ||
t = fract(t * N); | ||
|
||
float a = 0.785398163 - id * 6.28 / N; | ||
center = radius * vec2(cos(a), sin(a)); | ||
|
||
return shape( | ||
t, // t | ||
center, // center | ||
radius, // radius | ||
u_wheel * 3.141592653 / 24.0 // rotation | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//? #version 430 | ||
// ||| Include all the available values. They are explained at the bottom of the file. | ||
// vvv | ||
//? uniform int u_NbOfParticles; uniform float u_aspectRatio; uniform int u_count; uniform int u_LR; uniform int u_UD; uniform int u_wheel; uniform int u_ctrlWheel; uniform int u_shiftWheel; uniform int u_altWheel; uniform float u_seed; uniform vec2 u_xySeed; float rand(float seedX, float seedY); vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
const float tau = 6.28318530717958647692; | ||
|
||
const mat3 rot = mat3( cos(tau/3.), sin(tau/3.), 0., | ||
-sin(tau/3.), cos(tau/3.), 0., | ||
0., 0., 1. | ||
); | ||
|
||
const mat3 rot2 = mat3( cos(2.*tau/3.), sin(2.*tau/3.), 0., | ||
-sin(2.*tau/3.), cos(2.*tau/3.), 0., | ||
0., 0., 1. | ||
); | ||
|
||
mat3 trans(vec2 v) { | ||
return mat3(1., 0., 0., | ||
0., 1., 0., | ||
v.x, v.y, 1.); | ||
} | ||
|
||
const vec2 dirUp = vec2(0.0, 1.0); | ||
const vec2 dirLeft = vec2(-0.866025403784439, -0.5); | ||
const vec2 dirRight = vec2(0.866025403784439, -0.5); | ||
|
||
vec2 getPosition(uint particleID) { | ||
int N = max(u_UD + 2, 0); | ||
float t = particleID / float(u_NbOfParticles); | ||
float radius = 2 / (1.5 + pow(0.5, N+1)); // Makes sure that the full height is always exactly 2 to fit in the screen | ||
float finalRadius = radius * pow(0.5, N); | ||
vec2 center = vec2(0.0, -1./3. + 1./3. * finalRadius); // Place the center of the "triangle footprint" so that the "circle footprint" will fit exactly in the screen | ||
mat3 transform = trans(center); | ||
|
||
for (int _ = 0; _ < N; _++) { | ||
radius /= 2.0; | ||
int id = int(floor(t * 3.0)); | ||
t = fract(t * 3.0); | ||
vec2 dir; | ||
switch (id) { | ||
case 0: | ||
dir = dirRight; | ||
break; | ||
case 1: | ||
dir = dirLeft; | ||
break; | ||
case 2: | ||
dir = dirUp; | ||
break; | ||
} | ||
transform *= trans(dir * radius); | ||
if (_ == 0) { | ||
switch (id) { | ||
case 0: | ||
transform *= rot; | ||
break; | ||
case 1: | ||
break; | ||
case 2: | ||
transform *= rot2; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
float scale = 0.1 * u_shiftWheel + 0.9; | ||
return scale * shape(t, (transform * vec3(0., 0., 1.)).xy, radius, u_wheel * 3.141592653 / 6.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//? #version 430 | ||
// ||| Include all the available values. They are explained at the bottom of the file. | ||
// vvv | ||
//? uniform int u_NbOfParticles; uniform float u_aspectRatio; uniform int u_count; uniform int u_LR; uniform int u_UD; uniform int u_wheel; uniform int u_ctrlWheel; uniform int u_shiftWheel; uniform int u_altWheel; uniform float u_seed; uniform vec2 u_xySeed; float rand(float seedX, float seedY); vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
const float tau = 6.28318530717958647692; | ||
|
||
const mat3 rot = mat3( cos(tau/3.), sin(tau/3.), 0., | ||
-sin(tau/3.), cos(tau/3.), 0., | ||
0., 0., 1. | ||
); | ||
|
||
const mat3 rot2 = mat3( cos(2.*tau/3.), sin(2.*tau/3.), 0., | ||
-sin(2.*tau/3.), cos(2.*tau/3.), 0., | ||
0., 0., 1. | ||
); | ||
|
||
mat3 trans(vec2 v) { | ||
return mat3(1., 0., 0., | ||
0., 1., 0., | ||
v.x, v.y, 1.); | ||
} | ||
|
||
mat3 rotWithOrigin(mat3 rot, vec2 origin) { | ||
return trans(origin) * rot * trans(-origin); | ||
} | ||
|
||
const vec2 dirUp = vec2(0.0, 1.0); | ||
const vec2 dirLeft = vec2(-0.866025403784439, -0.5); | ||
const vec2 dirRight = vec2(0.866025403784439, -0.5); | ||
|
||
vec2 getPosition(uint particleID) { | ||
int N = max(u_UD + 2, 0); | ||
float t = particleID / float(u_NbOfParticles); | ||
float radius = 2 / (1.5 + pow(0.5, N+1)); // Makes sure that the full height is always exactly 2 to fit in the screen | ||
float finalRadius = radius * pow(0.5, N); | ||
vec2 center = vec2(0.0, -1./3. + 1./3. * finalRadius); // Place the center of the "triangle footprint" so that the "circle footprint" will fit exactly in the screen | ||
mat3 transform = trans(center); | ||
|
||
for (int _ = 0; _ < max(u_UD + 2, 0); _++) { | ||
radius /= 2.0; | ||
int id = int(floor(t * 3.0)); | ||
t = fract(t * 3.0); | ||
vec2 dir; | ||
switch (id) { | ||
case 0: | ||
dir = dirUp; | ||
break; | ||
case 1: | ||
dir = dirLeft; | ||
break; | ||
case 2: | ||
dir = dirRight; | ||
break; | ||
} | ||
transform = trans(dir * radius) * transform; | ||
switch (id) { | ||
case 0: | ||
break; | ||
case 1: | ||
transform = rot * transform; | ||
break; | ||
case 2: | ||
transform = rot2 * transform; | ||
break; | ||
} | ||
} | ||
|
||
float scale = 0.1 * u_shiftWheel + 0.9; | ||
return scale * shape(t, (transform * vec3(0., 0., 1.)).xy, radius, u_wheel * 3.141592653 / 6.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
//? #version 430 | ||
|
||
//? uniform int u_NbOfParticles; | ||
//? uniform float u_aspectRatio; | ||
// Parameters | ||
//? uniform int u_wheel; | ||
//? uniform int u_shiftWheel; | ||
//? uniform int u_altWheel; | ||
//? uniform int u_count; | ||
//? uniform int u_UD; | ||
//? uniform int u_LR; // I wouldn't recommend using this one for the layouts, see comments in the bottom section | ||
//? uniform int u_ctrlWheel; // I wouldn't recommend using this one for the layouts, see comments in the bottom section | ||
//Random | ||
//? uniform float u_seed; | ||
//? uniform vec2 u_xySeed; | ||
//? float rand(float seedX, float seedY); | ||
|
||
|
||
// getPosition is called for every particle, each with a different ID going from 0 to u_NbOfParticles-1 | ||
|
||
// A layout configuration has this "shape" function passed to it and it's goal is to draw shapes whereever it wants | ||
// t is the position on the shape (0 for the beginning, 1 for the end) | ||
//? vec2 shape(float t, vec2 center, float radius, float rotation); | ||
|
||
vec2 getPosition(uint particleID) { | ||
return shape( | ||
particleID / float(u_NbOfParticles), // t | ||
vec2(0.0), // center | ||
u_shiftWheel*0.1 + 0.9, // radius | ||
u_wheel * 3.141592653 / 24.0 // rotation | ||
); | ||
} | ||
|
||
|
||
// The Coordinate System is : | ||
// (0, 0) is the center | ||
// The y values go from -1 (at the bottom) to 1 (at the top) | ||
// The x values go from -u_aspectRatio (on the left) to +u_aspectRatio (on the right) | ||
|
||
// float u_aspectRatio; | ||
// The aspect ratio (== width/height) of the window (e.g. 16/9 for a fullscreen window on a computer) | ||
|
||
// int u_NbOfParticles; | ||
// Obviously, the total number of particles | ||
|
||
// Random | ||
// float rand(float id, float seed); | ||
// float u_seed; | ||
// vec2 u_xySeed; | ||
// The intended usage is, to get a random float : | ||
// rand(id, u_seed) | ||
// Or, to get a random vec2 : | ||
// vec2(rand(id, u_seed + u_xySeed.y), rand(id, u_seed + u_xySeed.x)) | ||
// u_seed is changed randomly each time you press space | ||
// u_seed and u_xySeed can be controlled from the Random panel in the app | ||
|
||
// A lot of values are available to you when you create a configuration : | ||
// Please note that all the parameters default to 0 at the beginnning of the application (except u_count which starts at 5), so you should add your own offset to have the default value you want | ||
// For example, if you want a radius of 1 by default, you should use u_shiftWheel + 1.0 | ||
// Also all the parameters change by 1 each time, so you probably want to adapt the rate of change : | ||
// u_shiftWheel * 0.1 to change in steps of 0.1 | ||
|
||
// Also note that all the parameters can be positive or negative | ||
// You should clamp or abs them if you want to make sure they will be positive | ||
// ||| ||| | ||
// vvv vvv | ||
// max(param, 0) abs(param) | ||
|
||
// int u_wheel; | ||
// This number is controlled by the mouse wheel | ||
// Is is typically used to rotate the shapes | ||
|
||
// int u_shiftWheel; | ||
// This number is controlled by the mouse wheel while holding SHIFT | ||
// Is is typically used as the size of the shapes | ||
|
||
// int u_altWheel; | ||
// This number is controlled by the mouse wheel while holding ALT | ||
// Is is typically used as a parameter for the layouts or standalones | ||
|
||
// int u_count; | ||
// This number is controlled with the + and - keys, as well as the numbers (from the keypad as well as the row above qwerty) | ||
// Its default value is 5 at the start of the app | ||
// +/- change the count by 1 | ||
// The numbers 0, 1, 2... set the count to respectively 0, 1, 2, 4, 8, 16 etc. | ||
// Is is typically used as a parameter for the layouts or standalones | ||
|
||
// int u_UD; | ||
// This number is controlled by the up/down arrows | ||
// Is is typically used as a parameter for the layouts or standalones | ||
|
||
|
||
|
||
//------------------------------------------------- | ||
// The parameters below are meant to be used by the shapes. | ||
// I wouldn't recommend using them for the layouts as you would have one parameter controlling two things at the same time (one in the layout and one in the shape) | ||
//------------------------------------------------- | ||
|
||
// int u_ctrlWheel; | ||
// This number is controlled by the mouse wheel while holding CTRL | ||
// Is is typically used as a parameter for the shapes or standalones | ||
|
||
// uniform int u_LR; | ||
// This number is controlled by the left/right arrows | ||
// Is is typically used as a parameter for the shapes or standalones |
Oops, something went wrong.