commit f31d3eda778d781d8dd7d0ed3ac431c42038e629
parent a7ecaa70f2215b1108d38c237f4ada5fea40799a
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sun, 24 Nov 2024 07:55:46 +0900
change shiness
Diffstat:
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/cmd/sample/fragment.glsl b/cmd/sample/fragment.glsl
@@ -66,7 +66,6 @@ void main() {
fcol += vec4(ambient + diffuse + specular, 0) * attenuation;
-
ambient = vec3(texture(Material.Diffuse, texPos)) * Sun.Ambient;
lightDir = normalize(-Sun.Dir);
@@ -79,6 +78,5 @@ void main() {
specular = vec3(texture(Material.Specular, texPos)) * spec * Sun.Specular;
fcol += vec4(ambient + diffuse + specular, 0);
-
}
diff --git a/cmd/sample/main.go b/cmd/sample/main.go
@@ -3,6 +3,7 @@ package main
import (
"log"
"math"
+ "math/rand/v2"
"path/filepath"
"runtime"
"time"
@@ -261,6 +262,10 @@ type App struct {
camera *tofu.Camera
termination bool
startedAt time.Time
+ cubeRotate []struct {
+ vel float32
+ axis tofu.Vec3
+ }
}
func (app *App) Update() error {
@@ -286,15 +291,17 @@ func (app *App) Update() error {
cubeUniforms.CamPos = camera.Pos
for _, p := range cubePositions {
model := tofu.Translate(p.Inverse())
+ // Mul(tofu.Rotate(now*app.cubeRotate[i].vel, app.cubeRotate[i].axis))
cubeUniforms.Trans.Model = model
- app.program.SetUniforms()
+ if err := app.program.SetUniforms(); err != nil {
+ log.Println("setuniforms:", err)
+ }
cube.Draw(app.program)
}
app.teapotProgram.Use()
teapotUniforms.Trans.View = view
teapotUniforms.Trans.Projection = projection
teapotUniforms.Trans.Model = tofu.Translate(tofu.Vec3{0, 0, 0}).
- Mul(tofu.Rotate(now, tofu.Vec3{0, 1, 0})).
Mul(tofu.Scale(0.06))
teapotUniforms.CamPos = camera.Pos
app.teapotProgram.SetUniforms()
@@ -319,6 +326,19 @@ func main() {
app := &App{}
app.cursorChan = make(chan tofu.Cursor)
app.startedAt = time.Now()
+ app.cubeRotate = make([]struct {
+ vel float32
+ axis tofu.Vec3
+ }, len(cubePositions))
+ for i := 0; i < len(app.cubeRotate); i++ {
+ app.cubeRotate[i] = struct {
+ vel float32
+ axis tofu.Vec3
+ }{
+ vel: rand.Float32(),
+ axis: tofu.Vec3{rand.Float32(), rand.Float32(), rand.Float32()}.Normalize(),
+ }
+ }
go watchCursor(app)
tofu.SetWindowSize(winW, winH)
tofu.SetWindowTitle("Sample")