Skip to content

Commit

Permalink
Adds colour uniform examples, as per popular demand.
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Gentz <[email protected]>
  • Loading branch information
goddessfreya committed Jul 17, 2018
1 parent 3129d5c commit 58b7c0d
Show file tree
Hide file tree
Showing 5 changed files with 1,686 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ dx12 = ["gfx-backend-dx12"]
vulkan = ["gfx-backend-vulkan"]
unstable = []

[[bin]]
name = "colour-uniform"
path = "colour-uniform/main.rs"

[[bin]]
name = "quad"
path = "quad/main.rs"
Expand All @@ -27,6 +31,7 @@ log = "0.4"
winit = "0.16"
glsl-to-spirv = "0.1.4"
gfx-hal = { path = "../src/hal", version = "0.1" }
takeable-option = "0.3.0"

[dependencies.gfx-backend-gl]
path = "../src/backend/gl"
Expand Down
Binary file added examples/colour-uniform/data/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions examples/colour-uniform/data/quad.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable

layout(location = 0) in vec2 v_uv;
layout(location = 0) out vec4 target0;

layout(set = 0, binding = 0) uniform texture2D u_texture;
layout(set = 0, binding = 1) uniform sampler u_sampler;

layout(set = 1, binding = 0) uniform UBOCol {
vec4 color;
} color_dat;

void main() {
target0 = texture(sampler2D(u_texture, u_sampler), v_uv) * color_dat.color;
}
17 changes: 17 additions & 0 deletions examples/colour-uniform/data/quad.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable

layout(constant_id = 0) const float scale = 1.2f;

layout(location = 0) in vec2 a_pos;
layout(location = 1) in vec2 a_uv;
layout(location = 0) out vec2 v_uv;

out gl_PerVertex {
vec4 gl_Position;
};

void main() {
v_uv = a_uv;
gl_Position = vec4(scale * a_pos, 0.0, 1.0);
}
Loading

0 comments on commit 58b7c0d

Please sign in to comment.