From 7ebf34c3e0c75f33ff642da27d75834934170646 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Thu, 21 Jan 2021 18:03:50 -0600 Subject: [PATCH] Phong lighting, flat shader --- demo/main.lua | 8 +++++--- demo/trough.glb | Bin 75748 -> 75748 bytes shaders/flat.frag | 18 ++---------------- shaders/flat.vert | 31 ++++++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/demo/main.lua b/demo/main.lua index cf8ecfb..9154ec3 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -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 diff --git a/demo/trough.glb b/demo/trough.glb index 9ad428addbb957b28ac3c1dbfb675d5c39319731..aa416a0ef71a71953b454fd6921283225b6a75f3 100644 GIT binary patch delta 1157 zcmb7BOK1~O6g}06Y17nSO`0_QtLfj=MDT;YOKAkLxKI$(idsSXLEID?wa^g-E!39c z1g%o*Mhuco5lyp6A_%T3T?n-ZF2pX1_=(V6vGu;_#IZPti+Aq1@11wfo4Iq-%G|Uv zv0znamHt#i>(V{|S9syV*toEC_M{}|Es|iOk!SKaqmj(yF8#${zpLs2Sy6mw?^B~` zXly*GboNl!y~qxIe@5x2#@3~TOqapS%W6vJy56WU@l4Gq>OYNG^jpI`WenECRy^(x zjm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