Phong lighting, flat shader

This commit is contained in:
Dane Johnson
2021-01-21 18:03:50 -06:00
parent 96f1e23a54
commit 7ebf34c3e0
4 changed files with 37 additions and 20 deletions

View File

@@ -27,10 +27,11 @@ function init()
camera.transform:Translate(0.0, 0.0, 10.0)
light = couch.DirectionalLight.new()
light.direction = couch.Vector3(0.0, 0.0, -1.0)
light.direction = couch.Vector3(0.0, -1.0, 0.0)
light.color = couch.Vector3(1.0, 1.0, 1.0)
light.ambient = 0.4
light.ambient = 0.2
light.diffuse = 1.0
light.specular = 0.0001
couch.Node.GetRoot().children:Append(light)
ball = couch.Mesh.FromFile("cube.glb")
@@ -112,9 +113,10 @@ function onkey(key, code, action, mod)
end
if key == couch.KEY_DOWN and action == couch.ACTION_PRESS then
light.ambient = light.ambient - 0.1
light.ambient = max(light.ambient - 0.1, 0.0)
elseif key == couch.KEY_UP and action == couch.ACTION_PRESS then
light.ambient = light.ambient + 0.1
print(light.ambient)
end
end

Binary file not shown.