diff --git a/space-crush-app/resources/shader/asteroid/frag.glsl b/space-crush-app/resources/shader/asteroid/frag.glsl index 2937740..598258a 100644 --- a/space-crush-app/resources/shader/asteroid/frag.glsl +++ b/space-crush-app/resources/shader/asteroid/frag.glsl @@ -21,7 +21,7 @@ out vec4 outColor; void main() { float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); - vec4 glow = vec4(fragmentData.color.rgb, fragmentData.color.a * alpha); + vec4 glow = vec4(fragmentData.color, GLOW_ALPHA * alpha); vec4 tex = texture(uTexture[textureId], 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); outColor = tex * tex.a + glow * (1.0 - tex.a); diff --git a/space-crush-app/resources/shader/asteroid/shared.glsl b/space-crush-app/resources/shader/asteroid/shared.glsl index eb621fd..0cf261d 100644 --- a/space-crush-app/resources/shader/asteroid/shared.glsl +++ b/space-crush-app/resources/shader/asteroid/shared.glsl @@ -1,13 +1,14 @@ struct FragmentData { vec2 texCoords; - vec4 color; + vec3 color; }; struct VertexData { vec2 pos; float size; - vec4 color; + vec3 color; int texture; }; -const float GLOW_SIZE = 2.0; // relative to planet size +const float GLOW_SIZE = 2.0; // relative to planet size +const float GLOW_ALPHA = 0.2; diff --git a/space-crush-app/resources/shader/asteroid/vert.glsl b/space-crush-app/resources/shader/asteroid/vert.glsl index 0b71478..716f7fa 100644 --- a/space-crush-app/resources/shader/asteroid/vert.glsl +++ b/space-crush-app/resources/shader/asteroid/vert.glsl @@ -5,7 +5,7 @@ layout (location = 0) in vec2 inPosition; layout (location = 1) in float inSize; -layout (location = 2) in vec4 inColor; +layout (location = 2) in vec3 inColor; layout (location = 3) in int inTexture; out VertexData vertexData; diff --git a/space-crush-app/resources/shader/planet/frag.glsl b/space-crush-app/resources/shader/planet/frag.glsl index bfb8f6b..87a8cc6 100644 --- a/space-crush-app/resources/shader/planet/frag.glsl +++ b/space-crush-app/resources/shader/planet/frag.glsl @@ -20,7 +20,7 @@ out vec4 outColor; void main() { float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); - vec4 glow = vec4(fragmentData.color.rgb, fragmentData.color.a * alpha); + vec4 glow = vec4(fragmentData.color, GLOW_ALPHA * alpha); vec4 tex = texture(uTexture, 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); outColor = tex * tex.a + glow * (1.0 - tex.a); diff --git a/space-crush-app/resources/shader/planet/shared.glsl b/space-crush-app/resources/shader/planet/shared.glsl index 8269fe3..2997a81 100644 --- a/space-crush-app/resources/shader/planet/shared.glsl +++ b/space-crush-app/resources/shader/planet/shared.glsl @@ -1,12 +1,13 @@ struct FragmentData { vec2 texCoords; - vec4 color; + vec3 color; }; struct VertexData { vec2 pos; float size; - vec4 color; + vec3 color; }; -const float GLOW_SIZE = 2.0; // relative to planet size +const float GLOW_SIZE = 2.0; // relative to planet size +const float GLOW_ALPHA = 0.2; diff --git a/space-crush-app/resources/shader/planet/vert.glsl b/space-crush-app/resources/shader/planet/vert.glsl index 692841e..02ad67a 100644 --- a/space-crush-app/resources/shader/planet/vert.glsl +++ b/space-crush-app/resources/shader/planet/vert.glsl @@ -5,12 +5,12 @@ layout (location = 0) in vec2 inPosition; layout (location = 1) in float inSize; -layout (location = 2) in vec4 inColor; +layout (location = 2) in vec3 inColor; out VertexData vertexData; void main() { - vertexData.pos = inPosition; - vertexData.size = inSize; - vertexData.color = inColor; + vertexData.pos = inPosition; + vertexData.size = inSize; + vertexData.color = inColor; } diff --git a/space-crush-app/resources/shader/ship/frag.glsl b/space-crush-app/resources/shader/ship/frag.glsl index 43d99b8..33f3e51 100644 --- a/space-crush-app/resources/shader/ship/frag.glsl +++ b/space-crush-app/resources/shader/ship/frag.glsl @@ -21,7 +21,7 @@ out vec4 outColor; void main() { float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); - vec4 glow = vec4(fragmentData.color.rgb, fragmentData.color.a * alpha * GLOW_ALPHA); + vec4 glow = vec4(fragmentData.color, GLOW_ALPHA * alpha); vec4 tex = texture(uTexture[textureId], 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); outColor = tex * tex.a + glow * (1.0 - tex.a); diff --git a/space-crush-app/resources/shader/ship/shared.glsl b/space-crush-app/resources/shader/ship/shared.glsl index 39842f7..7c6ae68 100644 --- a/space-crush-app/resources/shader/ship/shared.glsl +++ b/space-crush-app/resources/shader/ship/shared.glsl @@ -1,15 +1,15 @@ struct FragmentData { vec2 texCoords; - vec4 color; + vec3 color; }; struct VertexData { vec2 pos; vec2 dir; - vec4 color; + vec3 color; int texture; }; const float SHIP_SIZE = 25.0; // absolute ship size const float GLOW_SIZE = 4.0; // relative to ship size -const float GLOW_ALPHA = 0.5; +const float GLOW_ALPHA = 0.1; diff --git a/space-crush-app/resources/shader/ship/vert.glsl b/space-crush-app/resources/shader/ship/vert.glsl index 7781ea3..2228081 100644 --- a/space-crush-app/resources/shader/ship/vert.glsl +++ b/space-crush-app/resources/shader/ship/vert.glsl @@ -4,7 +4,7 @@ layout (location = 0) in vec2 inPosition; layout (location = 1) in vec2 inDirection; -layout (location = 2) in vec4 inColor; +layout (location = 2) in vec3 inColor; layout (location = 3) in int inTexture; out VertexData vertexData; diff --git a/space-crush-app/src/constants.rs b/space-crush-app/src/constants.rs index 6822704..7fb82ea 100644 --- a/space-crush-app/src/constants.rs +++ b/space-crush-app/src/constants.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use glc::vector::Vector4f; +use glc::vector::Vector3f; pub const UNIFORM_BUFFER_INDEX_CAMERA: gl::GLuint = 0; pub const UNIFORM_BUFFER_INDEX_UNIFORM: gl::GLuint = 1; @@ -15,4 +15,4 @@ pub const FLEET_SELECT_TEXT_OFFSET: f32 = 40.0; pub const FLEET_SELECT_ANIMATION_TIME: f32 = 0.400; pub const FLEET_SELECT_TEXT_SIZE: f32 = 24.0; -pub const PLAYER_COLOR_DEFAULT: Vector4f = Vector4f::new(1.0, 1.0, 1.0, 0.1); +pub const PLAYER_COLOR_DEFAULT: Vector3f = Vector3f::new(1.0, 1.0, 1.0); diff --git a/space-crush-app/src/main.rs b/space-crush-app/src/main.rs index 23e164d..2871801 100644 --- a/space-crush-app/src/main.rs +++ b/space-crush-app/src/main.rs @@ -1,4 +1,4 @@ -use glc::vector::Vector4f; +use glc::vector::Vector3f; use log::{error, info}; use rand::random; use space_crush_app::{App, Error}; @@ -38,7 +38,7 @@ fn run(vfs: Vfs) -> Result<(), Error> { let mut common = Dispatcher::new(&mut world)?; let player1 = world .create_entity() - .with(Player::new(Vector4f::new(0.0, 0.5, 1.0, 0.1))) + .with(Player::new(Vector3f::new(0.0, 0.5, 1.0))) .build(); let mut app = App::new(&mut world, player1)?; diff --git a/space-crush-app/src/render/asteroids.rs b/space-crush-app/src/render/asteroids.rs index 074dd7d..c30a95d 100644 --- a/space-crush-app/src/render/asteroids.rs +++ b/space-crush-app/src/render/asteroids.rs @@ -5,7 +5,7 @@ use glc::{ misc::{BindGuard, Bindable}, shader::{Program, Type, Uniform}, texture::Texture, - vector::{Vector2f, Vector4f}, + vector::{Vector2f, Vector3f}, vertex_array::{DataType, VertexArray}, }; use space_crush_common::{ @@ -36,7 +36,7 @@ pub struct Asteroids { struct VertexData { pos: Vector2f, size: gl::GLfloat, - color: Vector4f, + color: Vector3f, texture: gl::GLint, } @@ -65,13 +65,13 @@ impl Asteroids { const OFFSET_POS: gl::GLsizei = 0; const OFFSET_SIZ: gl::GLsizei = OFFSET_POS + size_of::() as gl::GLsizei; const OFFSET_CLR: gl::GLsizei = OFFSET_SIZ + size_of::() as gl::GLsizei; - const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::() as gl::GLsizei; + const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::() as gl::GLsizei; let vertex_array = VertexArray::builder() .bind_buffer(Buffer::new()?) .vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? .vertex_attrib_pointer(1, 1, DataType::Float, false, STRIDE, OFFSET_SIZ)? - .vertex_attrib_pointer(2, 4, DataType::Float, false, STRIDE, OFFSET_CLR)? + .vertex_attrib_pointer(2, 3, DataType::Float, false, STRIDE, OFFSET_CLR)? .vertex_attrib_pointer(3, 1, DataType::Int, false, STRIDE, OFFSET_TEX)? .build()?; diff --git a/space-crush-app/src/render/planets.rs b/space-crush-app/src/render/planets.rs index a97655f..31b0cc8 100644 --- a/space-crush-app/src/render/planets.rs +++ b/space-crush-app/src/render/planets.rs @@ -5,7 +5,7 @@ use glc::{ misc::{BindGuard, Bindable}, shader::{Program, Type, Uniform}, texture::Texture, - vector::{Vector2f, Vector4f}, + vector::{Vector2f, Vector3f}, vertex_array::{DataType, VertexArray}, }; use space_crush_common::{ @@ -35,7 +35,7 @@ pub struct Planets { struct VertexData { pos: Vector2f, size: gl::GLfloat, - color: Vector4f, + color: Vector3f, } impl Planets { @@ -67,7 +67,7 @@ impl Planets { .bind_buffer(Buffer::new()?) .vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? .vertex_attrib_pointer(1, 1, DataType::Float, false, STRIDE, OFFSET_SIZ)? - .vertex_attrib_pointer(2, 4, DataType::Float, false, STRIDE, OFFSET_CLR)? + .vertex_attrib_pointer(2, 3, DataType::Float, false, STRIDE, OFFSET_CLR)? .build()?; let reader_id = world diff --git a/space-crush-app/src/render/ships.rs b/space-crush-app/src/render/ships.rs index 3bab420..9466013 100644 --- a/space-crush-app/src/render/ships.rs +++ b/space-crush-app/src/render/ships.rs @@ -5,7 +5,7 @@ use glc::{ misc::{BindGuard, Bindable}, shader::{Program, Type, Uniform}, texture::Texture, - vector::{Vector2f, Vector4f}, + vector::{Vector2f, Vector3f}, vertex_array::{DataType, VertexArray}, }; use space_crush_common::{ @@ -34,7 +34,7 @@ pub struct Ships { struct VertexData { pos: Vector2f, dir: Vector2f, - color: Vector4f, + color: Vector3f, texture: gl::GLint, } @@ -58,13 +58,13 @@ impl Ships { const OFFSET_POS: gl::GLsizei = 0; const OFFSET_DIR: gl::GLsizei = OFFSET_POS + size_of::() as gl::GLsizei; const OFFSET_CLR: gl::GLsizei = OFFSET_DIR + size_of::() as gl::GLsizei; - const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::() as gl::GLsizei; + const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::() as gl::GLsizei; let vertex_array = VertexArray::builder() .bind_buffer(Buffer::new()?) .vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? .vertex_attrib_pointer(1, 2, DataType::Float, false, STRIDE, OFFSET_DIR)? - .vertex_attrib_pointer(2, 4, DataType::Float, false, STRIDE, OFFSET_CLR)? + .vertex_attrib_pointer(2, 3, DataType::Float, false, STRIDE, OFFSET_CLR)? .vertex_attrib_pointer(3, 1, DataType::Int, false, STRIDE, OFFSET_TEX)? .build()?; diff --git a/space-crush-common/src/components/player.rs b/space-crush-common/src/components/player.rs index ece7eb6..f9c7f29 100644 --- a/space-crush-common/src/components/player.rs +++ b/space-crush-common/src/components/player.rs @@ -1,4 +1,4 @@ -use glc::vector::Vector4f; +use glc::vector::Vector3f; use serde::{Deserialize, Serialize}; use specs::{ error::NoError, @@ -9,7 +9,7 @@ use specs::{ #[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Player { index: usize, - color: Vector4f, + color: Vector3f, } #[derive(Copy, Clone, Debug)] @@ -24,7 +24,7 @@ pub struct OwnedData { impl Player { #[inline] - pub fn new(color: Vector4f) -> Self { + pub fn new(color: Vector3f) -> Self { Self { index: next_index(), color, @@ -37,7 +37,7 @@ impl Player { } #[inline] - pub fn color(&self) -> &Vector4f { + pub fn color(&self) -> &Vector3f { &self.color } }