fix up shaders and stuff like that

main
_ 2021-12-22 02:32:52 +00:00
parent 893e01895f
commit f720ddcd23
5 changed files with 9 additions and 49 deletions

BIN
crate.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -15,7 +15,7 @@ varying lowp vec3 vary_object_space_sky;
void main (void) {
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));
@ -26,5 +26,5 @@ void main (void) {
lowp vec3 sky = (sky_factor * 0.5 + 0.5) * sky_color;
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);
}

View File

@ -51,6 +51,7 @@ pub struct Graphics {
texture_crate: Texture,
texture_earth: Texture,
texture_sky: Texture,
texture_white: Texture,
pub frames: u64,
}
@ -156,6 +157,7 @@ impl Graphics {
texture_crate: Texture::from_file ("crate.png"),
texture_earth: Texture::from_file ("earth.png"),
texture_sky: Texture::from_file ("sky.png"),
texture_white: Texture::from_file ("white.png"),
frames: 0,
}
}
@ -171,7 +173,7 @@ impl Graphics {
let white = color_from_255 ((255.0, 255.0, 255.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);
@ -211,24 +213,6 @@ impl Graphics {
self.texture_crate.bind ();
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 {
use opengl_rust::renderable_model::attributes as a;
@ -318,6 +302,8 @@ impl Graphics {
0.0
);
self.texture_white.bind ();
if coll.t <= 1.0 {
let mvp = view_mat *
Mat4::from_translation (coll.p_impact + Vec3::new (0.0, 0.0, 0.0625)) *
@ -328,32 +314,6 @@ impl Graphics {
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 {

View File

@ -260,7 +260,7 @@ async fn main () -> Result <()> {
game_state.player.vel = new_vel_2;
game_state.player.vel.z = old_vel.z;
dbg! (game_state.player.vel);
// dbg! (game_state.player.vel);
if player_wants_to_jump {
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 ();

BIN
white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B