Skip to content

Commit

Permalink
More tiny tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
slerpyyy committed Sep 17, 2021
1 parent 0977e52 commit 6904549
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion example/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ uniform sampler2D tex;
uniform float sliders[32];
uniform vec4 buttons[32];

vec3 gay(float x) {
vec3 rainbow(float x) {
x = x * 3.0 - 1.5;
return clamp(vec3(-x, 1.0-abs(x), x), 0.0, 1.0);
}
20 changes: 10 additions & 10 deletions example/compute/test_comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ layout(local_size_x = 1, local_size_y = 1) in;
layout(rgba32f) uniform image2D img_output;

void main() {
// base pixel colour for image
vec4 pixel = vec4(0.0, 0.0, 1.0, 1.0);
// get index in global work group i.e x,y position
ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
pixel.rg = pixel_coords / vec2(512.);
//
// interesting stuff happens here later
//
// base pixel colour for image
vec4 pixel = vec4(0, 0, 1, 1);

// output to a specific pixel in the image
imageStore(img_output, pixel_coords, pixel);
// get index in global work group i.e x,y position
ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
pixel.rg = pixel_coords / vec2(512);

// interesting stuff goes here

// output to a specific pixel in the image
imageStore(img_output, pixel_coords, pixel);
}
2 changes: 1 addition & 1 deletion example/post.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
float x = float(i) / float(iter - 1);
float s = 1.0 + 0.3 * (sliders[0]) * (x - 0.5);
vec2 tuv = 0.5 + s * (uv - 0.5);
acc += vec4(gay(x), 1) * texture2D(tex, tuv);
acc += vec4(rainbow(x), 1) * texture2D(tex, tuv);
}

acc /= float(iter);
Expand Down
28 changes: 13 additions & 15 deletions example/vertex/shader.vert
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,25 @@ uniform float time;

const float pi = acos(-1.0);

mat2 rot(float a)
{
float s=sin(a), c=cos(a);
return mat2(c,s,-s,c);
mat2 rot(float a) {
float s=sin(a), c=cos(a);
return mat2(c,s,-s,c);
}

void main() {
float a = 8.0 * pi * gl_VertexID / vertex_count;
float a = 8.0 * pi * gl_VertexID / vertex_count;

float r = 26.0 / 8.0;
vec2 off = vec2(sin(r*a) + 2.3, cos(r*a) + 1.0);
vec3 p = vec3(sin(a), 1, cos(a)) * off.xyx;
float r = 26.0 / 8.0;
vec2 off = vec2(sin(r*a) + 2.3, cos(r*a) + 1.0);
vec3 p = vec3(sin(a), 1, cos(a)) * off.xyx;

p.xz *= rot(time);
p.yz *= rot(0.6);
p.xz *= rot(time);
p.yz *= rot(0.6);

v_color = vec4(1.0 / abs(p.z + 1.0));
v_color = vec4(1.0 / abs(p.z + 1.0));

p.z += 5;
p.x *= resolution.w;
p.z += 5;
p.x *= resolution.w;

gl_Position = vec4(p, p.z);
gl_PointSize = 1.0;
gl_Position = vec4(p, p.z);
}
4 changes: 2 additions & 2 deletions src/jockey/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Config {
let reader = std::fs::File::open(file_path)?;
let object: Value = serde_yaml::from_reader(reader)?;

let mut midi_devices = vec![];
let mut midi_devices = Vec::new();

match object.get("midi_devices") {
Some(Value::Sequence(xs)) => {
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Config {
}
};

let mut ndi_sources = vec![];
let mut ndi_sources = Vec::new();
match object.get("ndi_sources") {
Some(Value::Sequence(xs)) => {
for val in xs {
Expand Down
2 changes: 1 addition & 1 deletion src/jockey/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Jockey {
midi,
audio,
ndi,
pipeline_files: vec![],
pipeline_files: Vec::new(),
pipeline,
pipeline_index: 0,
pipeline_partial: None,
Expand Down
4 changes: 2 additions & 2 deletions src/jockey/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ impl Ndi {

let locals = match find_local.current_sources(1000) {
Ok(s) => s,
Err(FindSourcesTimeout) => vec![],
Err(FindSourcesTimeout) => Vec::new(),
};

let remotes = match find_remote.current_sources(1000) {
Ok(s) => s,
Err(FindSourcesTimeout) => vec![],
Err(FindSourcesTimeout) => Vec::new(),
};

let mut sources = sources.lock().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/jockey/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Pipeline {
// parse images section
let images = match object.get("images") {
Some(Value::Sequence(s)) => s.clone(),
None => vec![],
None => Vec::new(),
s => return Err(format!("Expected \"images\" to be an array, got {:?}", s)),
};

Expand Down Expand Up @@ -350,7 +350,7 @@ impl Pipeline {
//parse ndi section
let ndi_sources = match object.get("ndi") {
Some(Value::Sequence(s)) => s.clone(),
None => vec![],
None => Vec::new(),
Some(s) => {
return Err(format!(
"Expected \"ndi\" to be an array, got {:?} instead.",
Expand Down
6 changes: 5 additions & 1 deletion src/jockey/shaders/pass.frag
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#version 140

in vec4 v_color;
out vec4 color;
void main(){color=v_color;}

void main() {
color = v_color;
}
6 changes: 5 additions & 1 deletion src/jockey/shaders/pass.vert
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#version 140

in vec2 position;
void main(){gl_Position=vec4(position,0,1);}

void main() {
gl_Position = vec4(position, 0, 1);
}

0 comments on commit 6904549

Please sign in to comment.