diff options
| author | 0undefined <oscar@nelin.dk> | 2026-03-11 06:46:39 +0000 |
|---|---|---|
| committer | 0undefined <oscar@nelin.dk> | 2026-03-11 06:46:39 +0000 |
| commit | a0e862d97f78d581e5ee1ee84289236e805e8c0f (patch) | |
| tree | 8c427823786bacaae42546d7528ac402808185ae | |
| parent | 1155bc8d5fee33b3728916255a9c8ac411b24b57 (diff) | |
Fix normals being inverted
| -rw-r--r-- | include/crate.h | 8 | ||||
| -rw-r--r-- | resources/quad.vert | 6 | ||||
| -rw-r--r-- | resources/shader.frag | 4 | ||||
| -rw-r--r-- | state_mainstate/src/mainstate.c | 2 |
4 files changed, 11 insertions, 9 deletions
diff --git a/include/crate.h b/include/crate.h index a6cfc31..a66f108 100644 --- a/include/crate.h +++ b/include/crate.h @@ -8,10 +8,10 @@ static f32 quad_fullscreen[8] = { -1.f, 1.f, }; static f32 quad[8] = { - -1.f, -1.f, - 1.f, -1.f, - 1.f, 1.f, - -1.f, 1.f, + -85.f, -85.f, + 85.f, -85.f, + 85.f, 85.f, + -85.f, 85.f, }; static u16 quad_ibo[6] = { diff --git a/resources/quad.vert b/resources/quad.vert index acf00b2..bc9cb36 100644 --- a/resources/quad.vert +++ b/resources/quad.vert @@ -6,14 +6,16 @@ layout(location = 1) in vec2 uv; out vec2 UV; uniform mat4 MVP; +uniform mat4 modelPosition; void main() { gl_Position = MVP * - vec4( pos.x, pos.y, 0, 1); - UV = uv; + //modelPosition * + vec4(pos.x, pos.y, 0, 1); //vec4(pos.x, 1.0, pos.y, 1.0); + UV = uv; //fragColor.x = gl_Position.x; //fragColor.y = gl_Position.y; diff --git a/resources/shader.frag b/resources/shader.frag index 1532caa..b4f60c9 100644 --- a/resources/shader.frag +++ b/resources/shader.frag @@ -12,12 +12,12 @@ void main() { vec3 light_color_ambient = vec3(0.55, 0.55, 1.0); vec3 light_color_diffuse = vec3(1.0, 0.98, 0.84); - vec3 lightpos = vec3(7, 17, 10); + vec3 lightpos = vec3(7, 65, 10); float ambient_strength = 0.45; vec3 ambient = ambient_strength * light_color_ambient; - vec3 norm = normalize(Normal); + vec3 norm = -normalize(Normal); vec3 light_dir = normalize(lightpos - FragmentPos); float diff = max(dot(norm, light_dir), 0.0); diff --git a/state_mainstate/src/mainstate.c b/state_mainstate/src/mainstate.c index 8dbbaa3..285d8ee 100644 --- a/state_mainstate/src/mainstate.c +++ b/state_mainstate/src/mainstate.c @@ -300,7 +300,7 @@ void mainstate_init(Window *restrict w, mainstate_state *state, void* arg) { glm_vec3_sub(A,B,B); glm_vec3_sub(A,C,C); - glm_vec3_cross(B,C,A); + glm_vec3_cross(C,B,A); glm_vec3_normalize(A); glm_vec3_copy(A, &crate_normals[i * 3]); |
