From d8158c63c17c8f83d19f5b1f82744d426da8c0e8 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sun, 25 Jun 2023 15:50:44 -0700 Subject: [PATCH] Alpha clipping, grass, stubbed out dbg3dline, made camera mat4s global --- art/art.blend | 4 ++-- art/gigatexture.png | 4 ++-- main.c | 12 ++++++++++-- threedee.glsl | 10 +++++++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/art/art.blend b/art/art.blend index 8d00a76..035b722 100644 --- a/art/art.blend +++ b/art/art.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a59e4241eaf2a973e026c2e271b9112d3ba7a50c191c26d540256e16754c995 -size 1069020 +oid sha256:4d49a8f5eaa0b3e55ac76e78f0005d8784285d72876c969f3d770d15beec33d0 +size 1105992 diff --git a/art/gigatexture.png b/art/gigatexture.png index 56f700b..7a5f6b8 100644 --- a/art/gigatexture.png +++ b/art/gigatexture.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:144900eab8da94f5a7b343d1a7ecfbcd3d5ba329da82c6f09f68250f6d129845 -size 1801687 +oid sha256:57b5443c0da618ff23428972546a61daf18af448dc2f189e7db445a573ee028f +size 3373206 diff --git a/main.c b/main.c index 4e0a5b1..359fd32 100644 --- a/main.c +++ b/main.c @@ -1055,6 +1055,8 @@ Vec3 flycam_pos = {0}; float flycam_horizontal_rotation = 0.0; float flycam_vertical_rotation = 0.0; float flycam_speed = 1.0f; +Mat4 view = {0}; +Mat4 projection = {0}; Vec4 IsPoint(Vec3 point) { @@ -3347,6 +3349,7 @@ void dbgbigsquare(Vec2 at) #endif } + void dbgline(Vec2 from, Vec2 to) { #ifdef DEVTOOLS @@ -3388,6 +3391,11 @@ void dbgrect(AABB rect) #endif } +void dbg3dline(Vec3 from, Vec2 to) +{ + // need 2d poins for each of these. +} + typedef struct TextParams { bool world_space; @@ -4380,7 +4388,7 @@ void frame(void) sg_apply_pipeline(state.threedee_pip); state.threedee_bind.fs_images[SLOT_threedee_tex] = image_gigatexture; - Mat4 view = Translate(V3(0.0, 1.0, -5.0f)); + view = Translate(V3(0.0, 1.0, -5.0f)); //view = LookAt_RH(V3(0,1,-5 if(flycam) { @@ -4392,7 +4400,7 @@ void frame(void) { view = LookAt_RH(cam_pos, player_pos, V3(0, 1, 0)); } - Mat4 projection = Perspective_RH_NO(PI32/4.0f, screen_size().x / screen_size().y, 0.01f, 1000.0f); + projection = Perspective_RH_NO(PI32/4.0f, screen_size().x / screen_size().y, 0.01f, 1000.0f); for(PlacedMesh *cur = level_threedee.placed_mesh_list; cur; cur = cur->next) { diff --git a/threedee.glsl b/threedee.glsl index d70c0f9..995888e 100644 --- a/threedee.glsl +++ b/threedee.glsl @@ -26,7 +26,15 @@ in vec2 uv; out vec4 frag_color; void main() { - frag_color = texture(tex, uv); + vec4 col = texture(tex, uv); + if(col.a < 0.5) + { + discard; + } + else + { + frag_color = vec4(col.rgb, 1.0); + } } @end