summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/teleia/src/assets/shaders/uber/frag.glsl5
-rw-r--r--crates/teleia/src/context.rs3
-rw-r--r--crates/teleia/src/renderer.rs31
3 files changed, 28 insertions, 11 deletions
diff --git a/crates/teleia/src/assets/shaders/uber/frag.glsl b/crates/teleia/src/assets/shaders/uber/frag.glsl
index 6778156..31efd0d 100644
--- a/crates/teleia/src/assets/shaders/uber/frag.glsl
+++ b/crates/teleia/src/assets/shaders/uber/frag.glsl
@@ -22,6 +22,8 @@ uniform float effect_flash;
uniform float effect_hueshift;
uniform float effect_huescale;
+uniform float opacity;
+
in vec2 vertex_texcoord;
in vec3 vertex_color;
in vec3 vertex_normal;
@@ -190,4 +192,7 @@ void main() {
if (flag(VERTEX_COLOR)) {
frag_color.rgb = vertex_color;
}
+ if (flag(OPACITY)) {
+ frag_color.a *= opacity;
+ }
}
diff --git a/crates/teleia/src/context.rs b/crates/teleia/src/context.rs
index bc0272c..82ce27f 100644
--- a/crates/teleia/src/context.rs
+++ b/crates/teleia/src/context.rs
@@ -111,7 +111,8 @@ impl Context {
self.gl.depth_func(glow::LEQUAL);
self.gl.enable(glow::BLEND);
- self.gl.blend_func(glow::SRC_ALPHA, glow::ONE_MINUS_SRC_ALPHA);
+ self.gl.blend_equation_separate(glow::FUNC_ADD, glow::MAX);
+ self.gl.blend_func_separate(glow::SRC_ALPHA, glow::ONE_MINUS_SRC_ALPHA, glow::ONE, glow::ZERO);
self.gl.enable(glow::STENCIL_TEST);
diff --git a/crates/teleia/src/renderer.rs b/crates/teleia/src/renderer.rs
index 32ce016..faad4f7 100644
--- a/crates/teleia/src/renderer.rs
+++ b/crates/teleia/src/renderer.rs
@@ -5,16 +5,17 @@ use bitflags::bitflags;
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct UberFlags: u32 {
- const TEXTURE_COLOR = 0b0000000001;
- const TEXTURE_NORMAL = 0b0000000010;
- const FLIP_TEXTURE = 0b0000000100;
- const LIGHT_AMBIENT = 0b0000001000;
- const LIGHT_DIR = 0b0000010000;
- const LIGHT_POINT = 0b0000100000;
- const SPRITE = 0b0001000000;
- const EFFECTS = 0b0010000000;
- const YSKEW = 0b0100000000;
- const VERTEX_COLOR = 0b1000000000;
+ const TEXTURE_COLOR = 0b00000000001;
+ const TEXTURE_NORMAL = 0b00000000010;
+ const FLIP_TEXTURE = 0b00000000100;
+ const LIGHT_AMBIENT = 0b00000001000;
+ const LIGHT_DIR = 0b00000010000;
+ const LIGHT_POINT = 0b00000100000;
+ const SPRITE = 0b00001000000;
+ const EFFECTS = 0b00010000000;
+ const YSKEW = 0b00100000000;
+ const VERTEX_COLOR = 0b01000000000;
+ const OPACITY = 0b10000000000;
}
}
impl UberFlags {
@@ -223,6 +224,16 @@ impl<A: Assets> Renderer<A> {
);
}
+ pub fn clear(&mut self,
+ ctx: &context::Context, _st: &mut state::State,
+ color: glam::Vec4
+ ) {
+ self.texture = BoundTexture::None;
+ self.shader = BoundShader::None;
+ ctx.clear_color(color);
+ ctx.clear();
+ }
+
/// Common case: draw the given textured mesh in the world (units are world tiles)
pub fn textured_mesh_world(&mut self,
ctx: &context::Context, st: &mut state::State,