tofu

Making something with OpenGL in Go
Log | Files | Refs

commit a3c25be3ed443829edb81e32c125b8ce4403cfea
parent c69546899afc84662eb6c4d57579c30033cf4b3e
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed, 20 Nov 2024 16:58:06 +0900

normalize fnorm

Diffstat:
Mcmd/sample/teapot.glsl | 4++--
Mcmd/sample/vertex.glsl | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/sample/teapot.glsl b/cmd/sample/teapot.glsl @@ -54,12 +54,12 @@ void main() { diffuse = diff * material.diffuse * light.diffuse * intensity; viewDir = normalize(camPos - fpos); - reflectDir = reflect(-lightDir, normalize(fnormal)); + reflectDir = reflect(-lightDir, fnormal); spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shiness); specular = material.specular * spec * light.specular * intensity; fcol += vec4((ambient+diffuse+specular) * attenuation, 0); - return; + ambient = material.diffuse * sun.ambient; diff --git a/cmd/sample/vertex.glsl b/cmd/sample/vertex.glsl @@ -9,7 +9,7 @@ out vec3 fpos; out vec2 texPos; void main() { gl_Position = projection * view * model * vec4(pos, 1.0); - fnormal = mat3(transpose(inverse(model))) * normal; + fnormal = normalize(mat3(transpose(inverse(model))) * normal); fpos = vec3(model * vec4(pos, 1.0)); texPos = vTexPos; }