diff options
author | iurii <[email protected]> | 2024-09-07 21:42:15 +0200 |
---|---|---|
committer | iurii <[email protected]> | 2024-09-07 21:42:15 +0200 |
commit | 56393dd58592d129708a737db31484d7bf25e5be (patch) | |
tree | 64b21efcebac34aff1d97afdc2c9d2459a2f87bf | |
parent | b1e4ae8347be86d2bd67e261f00c72cc1dedf8d2 (diff) | |
download | funhalla-56393dd58592d129708a737db31484d7bf25e5be.tar.gz |
upd
-rw-r--r-- | res/shaders/colors.fs | 2 | ||||
-rw-r--r-- | src/main.odin | 33 |
2 files changed, 15 insertions, 20 deletions
diff --git a/res/shaders/colors.fs b/res/shaders/colors.fs index 030fdac..f2e6bd9 100644 --- a/res/shaders/colors.fs +++ b/res/shaders/colors.fs @@ -11,7 +11,7 @@ struct Material { struct Light { vec3 position; - vec3 direction; + vec3 ambient; vec3 diffuse; vec3 specular; diff --git a/src/main.odin b/src/main.odin index d3d5cac..a55ce7e 100644 --- a/src/main.odin +++ b/src/main.odin @@ -187,18 +187,11 @@ main :: proc() { shader_use(lighting_shader) - material_ambient := Vec3{1.0, 0.5, 0.31} - material_specular := Vec3{0.5, 0.5, 0.5} - shader_set_vec3(lighting_shader, cstring("material.ambient"), &material_ambient) - shader_set_vec3(lighting_shader, cstring("material.specular"), &material_specular) - shader_set_f32(lighting_shader, cstring("material.shininess"), 32.0) - light_diffuse := Vec3{0.5, 0.5, 0.05} light_ambient := Vec3{0.2, 0.2, 0.2} + light_diffuse := Vec3{0.5, 0.5, 0.05} light_specular := Vec3{1.0, 1.0, 1.0} - light_direction := Vec3{-0.2, -1.0, -0.3} - shader_set_vec3(lighting_shader, "light.direction", &light_direction) shader_set_vec3(lighting_shader, cstring("light.ambient"), &light_ambient) shader_set_vec3(lighting_shader, cstring("light.diffuse"), &light_diffuse) shader_set_vec3(lighting_shader, cstring("light.specular"), &light_specular) @@ -210,6 +203,8 @@ main :: proc() { shader_set_f32(lighting_shader, "light.linear", 0.09) shader_set_f32(lighting_shader, "light.qudratic", 0.032) + shader_set_f32(lighting_shader, cstring("material.shininess"), 32.0) + aspect: f32 = 800.0 / 600.0 projection := linalg.matrix4_perspective_f32( linalg.to_radians(camera.zoom), @@ -247,17 +242,17 @@ main :: proc() { gl.DrawArrays(gl.TRIANGLES, 0, 36) } - //// lamp cube object drawing - //shader_use(light_cube_shader) - //shader_set_mat4(light_cube_shader, cstring("projection"), &projection) - //shader_set_mat4(light_cube_shader, cstring("view"), &view) - // - //model = linalg.matrix4_translate_f32(light_pos) - //model *= linalg.matrix4_scale_f32(Vec3{0.2, 0.2, 0.2}) - //shader_set_mat4(light_cube_shader, cstring("model"), &model) - // - //gl.BindVertexArray(light_cube_vao) - //gl.DrawArrays(gl.TRIANGLES, 0, 36) + // lamp cube object drawing + shader_use(light_cube_shader) + shader_set_mat4(light_cube_shader, cstring("projection"), &projection) + shader_set_mat4(light_cube_shader, cstring("view"), &view) + + model = linalg.matrix4_translate_f32(light_pos) + model *= linalg.matrix4_scale_f32(Vec3{0.2, 0.2, 0.2}) + shader_set_mat4(light_cube_shader, cstring("model"), &model) + + gl.BindVertexArray(light_cube_vao) + gl.DrawArrays(gl.TRIANGLES, 0, 36) glfw.SwapBuffers(window) glfw.PollEvents() |