commit cc4ec82bcd04aba22d13aacdb03bec8cfcad2a68
parent 54571622e3dd606740170097d39887400c3efad5
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sat, 9 Nov 2024 18:04:01 +0900
diffuse lighting
Diffstat:
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/cmd/sample/fragment.glsl b/cmd/sample/fragment.glsl
@@ -12,6 +12,5 @@ void main() {
float diff = max(dot(fnormal, dir), 0.0);
vec3 diffuse = diff * lightCol;
fcol = vec4(objCol * (ambient + diffuse), 1.0);
- fcol = vec4(1.0, 0.0, 0.0, 1.0);
}
diff --git a/cmd/sample/main.go b/cmd/sample/main.go
@@ -132,18 +132,18 @@ var object = tofu.Object{
tofu.Vec2{0.0, 1.0},
},
Faces: []tofu.Face{
- {V: [3]int{0, 1, 2}, N: {0, 0, 0}},
- {V: [3]int{0, 2, 3}, N: {1, 1, 1}},
- {V: [3]int{0, 1, 5}, N: {1, 1, 1}},
- {V: [3]int{0, 5, 4}, N: {2, 2, 2}},
- {V: [3]int{1, 2, 6}, N: {2, 2, 2}},
- {V: [3]int{1, 6, 5}, N: {3, 3, 3}},
- {V: [3]int{2, 3, 7}, N: {3, 3, 3}},
- {V: [3]int{2, 7, 6}, N: {4, 4, 4}},
- {V: [3]int{3, 0, 4}, N: {4, 4, 4}},
- {V: [3]int{3, 4, 7}, N: {5, 5, 5}},
- {V: [3]int{4, 5, 6}, N: {5, 5, 5}},
- {V: [3]int{4, 6, 7}, N: {6, 6, 6}},
+ {V: [3]int{0, 1, 2}, N: [3]int{0, 0, 0}},
+ {V: [3]int{0, 2, 3}, N: [3]int{0, 0, 0}},
+ {V: [3]int{0, 1, 5}, N: [3]int{1, 1, 1}},
+ {V: [3]int{0, 5, 4}, N: [3]int{1, 1, 1}},
+ {V: [3]int{1, 2, 6}, N: [3]int{2, 2, 2}},
+ {V: [3]int{1, 6, 5}, N: [3]int{2, 2, 2}},
+ {V: [3]int{2, 3, 7}, N: [3]int{3, 3, 3}},
+ {V: [3]int{2, 7, 6}, N: [3]int{3, 3, 3}},
+ {V: [3]int{3, 0, 4}, N: [3]int{4, 4, 4}},
+ {V: [3]int{3, 4, 7}, N: [3]int{4, 4, 4}},
+ {V: [3]int{4, 5, 6}, N: [3]int{5, 5, 5}},
+ {V: [3]int{4, 6, 7}, N: [3]int{5, 5, 5}},
},
}
@@ -211,7 +211,7 @@ func main() {
projection := tofu.Perspective(80*math.Pi/180, 800/600, 0.1, 100)
program.Use()
- program.SetVec3("lightPos", tofu.Vec3{3, 3, 0})
+ program.SetVec3("lightPos", tofu.Vec3{3, 3, 3})
program.SetMat4("view", view)
program.SetMat4("projection", projection)
model := tofu.Translate(tofu.Vec3{0, 0, 0})
@@ -225,7 +225,7 @@ func main() {
lightProgram.Use()
lightProgram.SetMat4("view", view)
lightProgram.SetMat4("projection", projection)
- model = tofu.Translate(tofu.Vec3{3, 3, 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)