commit d03896801b04be5ebe14f96bb21683fa705f5c9d
parent cc4ec82bcd04aba22d13aacdb03bec8cfcad2a68
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 9 Nov 2024 18:05:38 +0900
diffuse lighting
Diffstat:
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmd/sample/main.go b/cmd/sample/main.go
@@ -214,9 +214,9 @@ func main() {
program.SetVec3("lightPos", tofu.Vec3{3, 3, 3})
program.SetMat4("view", view)
program.SetMat4("projection", projection)
- model := tofu.Translate(tofu.Vec3{0, 0, 0})
-// Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 0, 1})).
-// Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 1, 0}))
+ model := tofu.Translate(tofu.Vec3{0, 0, 0}).
+ Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 0, 1})).
+ Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 1, 0}))
program.SetMat4("model", model)
program.SetVec3("lightCol", lightCol)
program.SetVec3("objCol", objCol)
@@ -225,9 +225,9 @@ func main() {
lightProgram.Use()
lightProgram.SetMat4("view", view)
lightProgram.SetMat4("projection", projection)
- model = tofu.Translate(tofu.Vec3{3, 3, 3})
-// Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 0, 1})).
-// Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 1, 0}))
+ model = tofu.Translate(tofu.Vec3{3, 3, 3}).
+ Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 0, 1})).
+ Mul(tofu.Rotate(float32(glfw.GetTime()), tofu.Vec3{0, 1, 0}))
lightProgram.SetMat4("model", model)
lightProgram.SetVec3("lightCol", lightCol)
gl.DrawElements(gl.TRIANGLES, 36, gl.UNSIGNED_INT, nil)
diff --git a/cmd/sample/vertex.glsl b/cmd/sample/vertex.glsl
@@ -8,7 +8,7 @@ out vec3 fnormal;
out vec3 fpos;
void main() {
gl_Position = projection * view * model * vec4(pos, 1.0);
- fnormal = normal;
+ fnormal = vec3(model * vec4(normal, 1.0));
fpos = vec3(model * vec4(pos, 1.0));
}