singe/testScripts/scene30.singe

91 lines
2.9 KiB
Text

-- Sky, environment light and fog: the dragon on its logo plate and a row of metal and glossy
-- spheres on a plain under an equirectangular sky (testScripts/sky.png from util/makeSky.py) that
-- lights the scene (the sky's harmonics for the diffuse, its reflections on the metals) beside a
-- low sun, with fog to the horizon. The stops walk round the plate and toward the horizon.
local font = fontLoad("Singe/FreeSansBold.ttf", 28)
local frames = 0
fontSelect(font)
sceneEnable(true)
sceneSetSky("testScripts/sky.png")
sceneSetSkyIntensity(1.0)
sceneSetFog(190, 200, 215, 25, 90)
sceneSetShadowSize(2048)
local ground = materialNew()
materialSetColor(ground, 120, 115, 95)
materialSetRoughness(ground, 0.95)
local plain = nodeNew()
nodeSetMesh(plain, meshPlane(200, 200), ground)
local group = nodeNew()
local logo = modelInstance(modelLoad("testScripts/Models/SingeText.glb"))
nodeSetParent(logo, group)
local dragon = modelInstance(modelLoad("testScripts/Models/DragonModel.glb"))
nodeSetParent(dragon, group)
nodeSetPosition(dragon, 0, 4.85, 0)
nodeSetScale(dragon, 0.9)
nodeSetScale(group, 0.5)
-- Spheres from mirror chrome to rough gold, plus a glossy red one, all reflecting the sky.
local steps = 5
for i = 0, steps - 1 do
local m = materialNew()
materialSetColor(m, 230, 210, 150)
materialSetMetallic(m, 1)
materialSetRoughness(m, i / (steps - 1))
local s = nodeNew()
nodeSetMesh(s, meshSphere(0.8, 32), m)
nodeSetPosition(s, -6 + i * 2.2, 0.8, 5)
end
local red = materialNew()
materialSetColor(red, 170, 30, 30)
materialSetRoughness(red, 0.15)
local ball = nodeNew()
nodeSetMesh(ball, meshSphere(0.8, 32), red)
nodeSetPosition(ball, 6, 0.8, 5)
-- Posts marching into the fog.
local post = materialNew()
materialSetColor(post, 90, 70, 50)
for i = 1, 12 do
local p = nodeNew()
nodeSetMesh(p, meshCylinder(0.25, 3, 8), post)
nodeSetPosition(p, -10, 1.5, -i * 7)
local q = nodeNew()
nodeSetMesh(q, meshCylinder(0.25, 3, 8), post)
nodeSetPosition(q, 10, 1.5, -i * 7)
end
local sun = lightNew(LIGHT_DIRECTIONAL)
nodeSetPosition(sun, 11, 13, -10)
nodeLookAt(sun, 0, 0, 0)
lightSetIntensity(sun, 2.5)
lightSetColor(sun, 255, 245, 225)
lightSetShadow(sun, true)
local camera = nodeNew()
cameraSet(camera)
cameraSetPerspective(55, 0.1, 200)
local stops = {
{ 0, 3, 14, 0, 2.5, 0 }, -- The plate and the spheres
{ -9, 2, 9, 0, 3, 0 }, -- Round to the side, the sun behind the dragon
{ 3, 1.2, 9, -6, 0.8, 5 }, -- Low along the sphere row
{ 0, 4, 12, 0, 2, -80 }, -- Down the avenue of posts into the fog
}
function onOverlayUpdate()
local stop = stops[math.min(#stops, math.floor(frames / 45) + 1)]
frames = frames + 1
nodeSetPosition(camera, stop[1], stop[2], stop[3])
nodeLookAt(camera, stop[4], stop[5], stop[6])
overlayClear()
fontPrint(20, 20, "Sky and fog, frame " .. frames)
if frames == 40 or frames == 85 or frames == 130 or frames == 175 then
singeScreenshot()
end
if frames == 180 then
singeQuit()
end
end