@@ -21,7 +21,7 @@ out vec4 outColor; | |||||
void main() { | void main() { | ||||
float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); | 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)); | vec4 tex = texture(uTexture[textureId], 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); | ||||
outColor = tex * tex.a + glow * (1.0 - tex.a); | outColor = tex * tex.a + glow * (1.0 - tex.a); | ||||
@@ -1,13 +1,14 @@ | |||||
struct FragmentData { | struct FragmentData { | ||||
vec2 texCoords; | vec2 texCoords; | ||||
vec4 color; | |||||
vec3 color; | |||||
}; | }; | ||||
struct VertexData { | struct VertexData { | ||||
vec2 pos; | vec2 pos; | ||||
float size; | float size; | ||||
vec4 color; | |||||
vec3 color; | |||||
int texture; | 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; |
@@ -5,7 +5,7 @@ | |||||
layout (location = 0) in vec2 inPosition; | layout (location = 0) in vec2 inPosition; | ||||
layout (location = 1) in float inSize; | layout (location = 1) in float inSize; | ||||
layout (location = 2) in vec4 inColor; | |||||
layout (location = 2) in vec3 inColor; | |||||
layout (location = 3) in int inTexture; | layout (location = 3) in int inTexture; | ||||
out VertexData vertexData; | out VertexData vertexData; | ||||
@@ -20,7 +20,7 @@ out vec4 outColor; | |||||
void main() { | void main() { | ||||
float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); | 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)); | vec4 tex = texture(uTexture, 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); | ||||
outColor = tex * tex.a + glow * (1.0 - tex.a); | outColor = tex * tex.a + glow * (1.0 - tex.a); | ||||
@@ -1,12 +1,13 @@ | |||||
struct FragmentData { | struct FragmentData { | ||||
vec2 texCoords; | vec2 texCoords; | ||||
vec4 color; | |||||
vec3 color; | |||||
}; | }; | ||||
struct VertexData { | struct VertexData { | ||||
vec2 pos; | vec2 pos; | ||||
float size; | 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; |
@@ -5,12 +5,12 @@ | |||||
layout (location = 0) in vec2 inPosition; | layout (location = 0) in vec2 inPosition; | ||||
layout (location = 1) in float inSize; | layout (location = 1) in float inSize; | ||||
layout (location = 2) in vec4 inColor; | |||||
layout (location = 2) in vec3 inColor; | |||||
out VertexData vertexData; | out VertexData vertexData; | ||||
void main() { | void main() { | ||||
vertexData.pos = inPosition; | |||||
vertexData.size = inSize; | |||||
vertexData.color = inColor; | |||||
vertexData.pos = inPosition; | |||||
vertexData.size = inSize; | |||||
vertexData.color = inColor; | |||||
} | } |
@@ -21,7 +21,7 @@ out vec4 outColor; | |||||
void main() { | void main() { | ||||
float alpha = glow(GLOW_ARGS, fragmentData.texCoords, uGlobal.time); | 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)); | vec4 tex = texture(uTexture[textureId], 0.5 * GLOW_SIZE * fragmentData.texCoords + vec2(0.5)); | ||||
outColor = tex * tex.a + glow * (1.0 - tex.a); | outColor = tex * tex.a + glow * (1.0 - tex.a); | ||||
@@ -1,15 +1,15 @@ | |||||
struct FragmentData { | struct FragmentData { | ||||
vec2 texCoords; | vec2 texCoords; | ||||
vec4 color; | |||||
vec3 color; | |||||
}; | }; | ||||
struct VertexData { | struct VertexData { | ||||
vec2 pos; | vec2 pos; | ||||
vec2 dir; | vec2 dir; | ||||
vec4 color; | |||||
vec3 color; | |||||
int texture; | int texture; | ||||
}; | }; | ||||
const float SHIP_SIZE = 25.0; // absolute ship size | const float SHIP_SIZE = 25.0; // absolute ship size | ||||
const float GLOW_SIZE = 4.0; // relative to ship size | const float GLOW_SIZE = 4.0; // relative to ship size | ||||
const float GLOW_ALPHA = 0.5; | |||||
const float GLOW_ALPHA = 0.1; |
@@ -4,7 +4,7 @@ | |||||
layout (location = 0) in vec2 inPosition; | layout (location = 0) in vec2 inPosition; | ||||
layout (location = 1) in vec2 inDirection; | layout (location = 1) in vec2 inDirection; | ||||
layout (location = 2) in vec4 inColor; | |||||
layout (location = 2) in vec3 inColor; | |||||
layout (location = 3) in int inTexture; | layout (location = 3) in int inTexture; | ||||
out VertexData vertexData; | out VertexData vertexData; | ||||
@@ -1,6 +1,6 @@ | |||||
use std::time::Duration; | 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_CAMERA: gl::GLuint = 0; | ||||
pub const UNIFORM_BUFFER_INDEX_UNIFORM: gl::GLuint = 1; | 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_ANIMATION_TIME: f32 = 0.400; | ||||
pub const FLEET_SELECT_TEXT_SIZE: f32 = 24.0; | 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); |
@@ -1,4 +1,4 @@ | |||||
use glc::vector::Vector4f; | |||||
use glc::vector::Vector3f; | |||||
use log::{error, info}; | use log::{error, info}; | ||||
use rand::random; | use rand::random; | ||||
use space_crush_app::{App, Error}; | use space_crush_app::{App, Error}; | ||||
@@ -38,7 +38,7 @@ fn run(vfs: Vfs) -> Result<(), Error> { | |||||
let mut common = Dispatcher::new(&mut world)?; | let mut common = Dispatcher::new(&mut world)?; | ||||
let player1 = world | let player1 = world | ||||
.create_entity() | .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(); | .build(); | ||||
let mut app = App::new(&mut world, player1)?; | let mut app = App::new(&mut world, player1)?; | ||||
@@ -5,7 +5,7 @@ use glc::{ | |||||
misc::{BindGuard, Bindable}, | misc::{BindGuard, Bindable}, | ||||
shader::{Program, Type, Uniform}, | shader::{Program, Type, Uniform}, | ||||
texture::Texture, | texture::Texture, | ||||
vector::{Vector2f, Vector4f}, | |||||
vector::{Vector2f, Vector3f}, | |||||
vertex_array::{DataType, VertexArray}, | vertex_array::{DataType, VertexArray}, | ||||
}; | }; | ||||
use space_crush_common::{ | use space_crush_common::{ | ||||
@@ -36,7 +36,7 @@ pub struct Asteroids { | |||||
struct VertexData { | struct VertexData { | ||||
pos: Vector2f, | pos: Vector2f, | ||||
size: gl::GLfloat, | size: gl::GLfloat, | ||||
color: Vector4f, | |||||
color: Vector3f, | |||||
texture: gl::GLint, | texture: gl::GLint, | ||||
} | } | ||||
@@ -65,13 +65,13 @@ impl Asteroids { | |||||
const OFFSET_POS: gl::GLsizei = 0; | const OFFSET_POS: gl::GLsizei = 0; | ||||
const OFFSET_SIZ: gl::GLsizei = OFFSET_POS + size_of::<Vector2f>() as gl::GLsizei; | const OFFSET_SIZ: gl::GLsizei = OFFSET_POS + size_of::<Vector2f>() as gl::GLsizei; | ||||
const OFFSET_CLR: gl::GLsizei = OFFSET_SIZ + size_of::<gl::GLfloat>() as gl::GLsizei; | const OFFSET_CLR: gl::GLsizei = OFFSET_SIZ + size_of::<gl::GLfloat>() as gl::GLsizei; | ||||
const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::<Vector4f>() as gl::GLsizei; | |||||
const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::<Vector3f>() as gl::GLsizei; | |||||
let vertex_array = VertexArray::builder() | let vertex_array = VertexArray::builder() | ||||
.bind_buffer(Buffer::new()?) | .bind_buffer(Buffer::new()?) | ||||
.vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? | .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(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)? | .vertex_attrib_pointer(3, 1, DataType::Int, false, STRIDE, OFFSET_TEX)? | ||||
.build()?; | .build()?; | ||||
@@ -5,7 +5,7 @@ use glc::{ | |||||
misc::{BindGuard, Bindable}, | misc::{BindGuard, Bindable}, | ||||
shader::{Program, Type, Uniform}, | shader::{Program, Type, Uniform}, | ||||
texture::Texture, | texture::Texture, | ||||
vector::{Vector2f, Vector4f}, | |||||
vector::{Vector2f, Vector3f}, | |||||
vertex_array::{DataType, VertexArray}, | vertex_array::{DataType, VertexArray}, | ||||
}; | }; | ||||
use space_crush_common::{ | use space_crush_common::{ | ||||
@@ -35,7 +35,7 @@ pub struct Planets { | |||||
struct VertexData { | struct VertexData { | ||||
pos: Vector2f, | pos: Vector2f, | ||||
size: gl::GLfloat, | size: gl::GLfloat, | ||||
color: Vector4f, | |||||
color: Vector3f, | |||||
} | } | ||||
impl Planets { | impl Planets { | ||||
@@ -67,7 +67,7 @@ impl Planets { | |||||
.bind_buffer(Buffer::new()?) | .bind_buffer(Buffer::new()?) | ||||
.vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? | .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(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()?; | .build()?; | ||||
let reader_id = world | let reader_id = world | ||||
@@ -5,7 +5,7 @@ use glc::{ | |||||
misc::{BindGuard, Bindable}, | misc::{BindGuard, Bindable}, | ||||
shader::{Program, Type, Uniform}, | shader::{Program, Type, Uniform}, | ||||
texture::Texture, | texture::Texture, | ||||
vector::{Vector2f, Vector4f}, | |||||
vector::{Vector2f, Vector3f}, | |||||
vertex_array::{DataType, VertexArray}, | vertex_array::{DataType, VertexArray}, | ||||
}; | }; | ||||
use space_crush_common::{ | use space_crush_common::{ | ||||
@@ -34,7 +34,7 @@ pub struct Ships { | |||||
struct VertexData { | struct VertexData { | ||||
pos: Vector2f, | pos: Vector2f, | ||||
dir: Vector2f, | dir: Vector2f, | ||||
color: Vector4f, | |||||
color: Vector3f, | |||||
texture: gl::GLint, | texture: gl::GLint, | ||||
} | } | ||||
@@ -58,13 +58,13 @@ impl Ships { | |||||
const OFFSET_POS: gl::GLsizei = 0; | const OFFSET_POS: gl::GLsizei = 0; | ||||
const OFFSET_DIR: gl::GLsizei = OFFSET_POS + size_of::<Vector2f>() as gl::GLsizei; | const OFFSET_DIR: gl::GLsizei = OFFSET_POS + size_of::<Vector2f>() as gl::GLsizei; | ||||
const OFFSET_CLR: gl::GLsizei = OFFSET_DIR + size_of::<Vector2f>() as gl::GLsizei; | const OFFSET_CLR: gl::GLsizei = OFFSET_DIR + size_of::<Vector2f>() as gl::GLsizei; | ||||
const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::<Vector4f>() as gl::GLsizei; | |||||
const OFFSET_TEX: gl::GLsizei = OFFSET_CLR + size_of::<Vector3f>() as gl::GLsizei; | |||||
let vertex_array = VertexArray::builder() | let vertex_array = VertexArray::builder() | ||||
.bind_buffer(Buffer::new()?) | .bind_buffer(Buffer::new()?) | ||||
.vertex_attrib_pointer(0, 2, DataType::Float, false, STRIDE, OFFSET_POS)? | .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(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)? | .vertex_attrib_pointer(3, 1, DataType::Int, false, STRIDE, OFFSET_TEX)? | ||||
.build()?; | .build()?; | ||||
@@ -1,4 +1,4 @@ | |||||
use glc::vector::Vector4f; | |||||
use glc::vector::Vector3f; | |||||
use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||
use specs::{ | use specs::{ | ||||
error::NoError, | error::NoError, | ||||
@@ -9,7 +9,7 @@ use specs::{ | |||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)] | #[derive(Clone, Debug, Default, Serialize, Deserialize)] | ||||
pub struct Player { | pub struct Player { | ||||
index: usize, | index: usize, | ||||
color: Vector4f, | |||||
color: Vector3f, | |||||
} | } | ||||
#[derive(Copy, Clone, Debug)] | #[derive(Copy, Clone, Debug)] | ||||
@@ -24,7 +24,7 @@ pub struct OwnedData<M> { | |||||
impl Player { | impl Player { | ||||
#[inline] | #[inline] | ||||
pub fn new(color: Vector4f) -> Self { | |||||
pub fn new(color: Vector3f) -> Self { | |||||
Self { | Self { | ||||
index: next_index(), | index: next_index(), | ||||
color, | color, | ||||
@@ -37,7 +37,7 @@ impl Player { | |||||
} | } | ||||
#[inline] | #[inline] | ||||
pub fn color(&self) -> &Vector4f { | |||||
pub fn color(&self) -> &Vector3f { | |||||
&self.color | &self.color | ||||
} | } | ||||
} | } | ||||