fix up shaders and stuff like that
parent
893e01895f
commit
f720ddcd23
BIN
crate.png
BIN
crate.png
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
@ -15,7 +15,7 @@ varying lowp vec3 vary_object_space_sky;
|
||||||
void main (void) {
|
void main (void) {
|
||||||
lowp vec3 normal = normalize (vary_normal);
|
lowp vec3 normal = normalize (vary_normal);
|
||||||
|
|
||||||
lowp vec3 albedo = vary_color * max (uni_min_albedo, texture2D (uni_texture, vary_uv).rgb);
|
lowp vec3 albedo = max (uni_min_albedo, texture2D (uni_texture, vary_uv).rgb);
|
||||||
|
|
||||||
lowp vec3 sky_color = pow (vec3 (89.0, 125.0, 206.0) / vec3 (255.0), vec3 (2.0));
|
lowp vec3 sky_color = pow (vec3 (89.0, 125.0, 206.0) / vec3 (255.0), vec3 (2.0));
|
||||||
|
|
||||||
|
@ -26,5 +26,5 @@ void main (void) {
|
||||||
lowp vec3 sky = (sky_factor * 0.5 + 0.5) * sky_color;
|
lowp vec3 sky = (sky_factor * 0.5 + 0.5) * sky_color;
|
||||||
lowp vec3 diffuse_color = max (uni_min_bright, (sun + sky));
|
lowp vec3 diffuse_color = max (uni_min_bright, (sun + sky));
|
||||||
|
|
||||||
gl_FragColor = vec4 (albedo * sqrt (diffuse_color), 1.0);
|
gl_FragColor = vec4 (albedo * sqrt (vary_color * diffuse_color), 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub struct Graphics {
|
||||||
texture_crate: Texture,
|
texture_crate: Texture,
|
||||||
texture_earth: Texture,
|
texture_earth: Texture,
|
||||||
texture_sky: Texture,
|
texture_sky: Texture,
|
||||||
|
texture_white: Texture,
|
||||||
|
|
||||||
pub frames: u64,
|
pub frames: u64,
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,7 @@ impl Graphics {
|
||||||
texture_crate: Texture::from_file ("crate.png"),
|
texture_crate: Texture::from_file ("crate.png"),
|
||||||
texture_earth: Texture::from_file ("earth.png"),
|
texture_earth: Texture::from_file ("earth.png"),
|
||||||
texture_sky: Texture::from_file ("sky.png"),
|
texture_sky: Texture::from_file ("sky.png"),
|
||||||
|
texture_white: Texture::from_file ("white.png"),
|
||||||
frames: 0,
|
frames: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +173,7 @@ impl Graphics {
|
||||||
|
|
||||||
let white = color_from_255 ((255.0, 255.0, 255.0));
|
let white = color_from_255 ((255.0, 255.0, 255.0));
|
||||||
let black = color_from_255 ((0.0, 0.0, 0.0));
|
let black = color_from_255 ((0.0, 0.0, 0.0));
|
||||||
let shadow_blue = color_from_255 ((0.0, 0.0, 0.25));
|
let shadow_blue = color_from_255 ((68.0, 36.0, 52.0));
|
||||||
|
|
||||||
let screen_size = (320.0, 240.0);
|
let screen_size = (320.0, 240.0);
|
||||||
|
|
||||||
|
@ -211,24 +213,6 @@ impl Graphics {
|
||||||
self.texture_crate.bind ();
|
self.texture_crate.bind ();
|
||||||
glezz::uniform_3fv (unis [&u::ALBEDO], &white);
|
glezz::uniform_3fv (unis [&u::ALBEDO], &white);
|
||||||
|
|
||||||
if false {
|
|
||||||
for aabb in &state.aabbs {
|
|
||||||
let min = aabb.min;
|
|
||||||
let max = aabb.max;
|
|
||||||
let center = (min + max) / 2.0;
|
|
||||||
let scale = (max - min) / 2.0;
|
|
||||||
|
|
||||||
let mvp = view_mat *
|
|
||||||
Mat4::from_translation (center) *
|
|
||||||
Mat4::from_scale (scale);
|
|
||||||
glezz::uniform_matrix_4fv (unis [&u::MVP], &mvp);
|
|
||||||
|
|
||||||
self.mesh_cube.draw_all (attrs, |_| {
|
|
||||||
true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
use opengl_rust::renderable_model::attributes as a;
|
use opengl_rust::renderable_model::attributes as a;
|
||||||
|
|
||||||
|
@ -318,6 +302,8 @@ impl Graphics {
|
||||||
0.0
|
0.0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.texture_white.bind ();
|
||||||
|
|
||||||
if coll.t <= 1.0 {
|
if coll.t <= 1.0 {
|
||||||
let mvp = view_mat *
|
let mvp = view_mat *
|
||||||
Mat4::from_translation (coll.p_impact + Vec3::new (0.0, 0.0, 0.0625)) *
|
Mat4::from_translation (coll.p_impact + Vec3::new (0.0, 0.0, 0.0625)) *
|
||||||
|
@ -328,32 +314,6 @@ impl Graphics {
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for aabb in &state.aabbs {
|
|
||||||
// Raycast for box shadows
|
|
||||||
let min = aabb.min;
|
|
||||||
let max = aabb.max;
|
|
||||||
let center = (min + max) / 2.0;
|
|
||||||
let scale = (max - min) / 2.0;
|
|
||||||
|
|
||||||
let coll = opengl_rust::physics::get_candidate (
|
|
||||||
&[], &state.aabbs,
|
|
||||||
center,
|
|
||||||
center + Vec3::new (0.0, 0.0, -100.0),
|
|
||||||
0.0
|
|
||||||
);
|
|
||||||
|
|
||||||
if coll.t <= 1.0 {
|
|
||||||
let mvp = view_mat *
|
|
||||||
Mat4::from_translation (coll.p_impact + Vec3::new (0.0, 0.0, 0.0625)) *
|
|
||||||
Mat4::from_scale ((scale.x, scale.y, 0.0).into ());
|
|
||||||
glezz::uniform_matrix_4fv (unis [&u::MVP], &mvp);
|
|
||||||
|
|
||||||
self.mesh_cube.draw_all (attrs, |_| {
|
|
||||||
true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if false {
|
if false {
|
||||||
|
|
|
@ -260,7 +260,7 @@ async fn main () -> Result <()> {
|
||||||
game_state.player.vel = new_vel_2;
|
game_state.player.vel = new_vel_2;
|
||||||
game_state.player.vel.z = old_vel.z;
|
game_state.player.vel.z = old_vel.z;
|
||||||
|
|
||||||
dbg! (game_state.player.vel);
|
// dbg! (game_state.player.vel);
|
||||||
|
|
||||||
if player_wants_to_jump {
|
if player_wants_to_jump {
|
||||||
if let Some (normal) = player_jump_vec.clone () {
|
if let Some (normal) = player_jump_vec.clone () {
|
||||||
|
@ -292,7 +292,7 @@ async fn main () -> Result <()> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// dbg! (player_jump_vec);
|
dbg! (game_state.player.pos);
|
||||||
|
|
||||||
window.gl_make_current (&gl_ctx).unwrap ();
|
window.gl_make_current (&gl_ctx).unwrap ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue