- Notifications
You must be signed in to change notification settings - Fork1
Atmosphere rendering for LÖVR framework
License
jmiskovic/lovr-atmo
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Provides a decent starting environment for sunnyLÖVR projects.
Sky rendering uses a model of the light scattering through the atmosphere with exposed parameters to modify appearance of sun and the sky. For better performance the atmosphere is rendered onto skybox texture. The color of horizon is made available so it can affect the color of fog or any other scene object.
A quick way to get this up and running is:
localatmo=require('atmo')localskybox=require('skybox').new()-- or new(512) for hi-resskybox:bake(atmo.draw)-- renders atmosphere into texturefunctionlovr.draw(pass)skybox:draw(pass)-- atmo.draw(pass) -- render directly without skyboxend
The atmosphere has some parameters that can be tweaked:
atmo.gpu.haze=0.1-- controls size of sun's haloatmo.gpu.horizon_offset=1-- moves the horizon line up or downatmo.gpu.sun_intensity=40-- brightness of sun's diskatmo.gpu.sun_sharpness=0.95-- controls the halo around the sunatmo.gpu.sun_position=Vec3(1,1,-1)-- direction, or normalized position of sun in the skyatmo.gpu.gamma_correction=2.2-- gamma for contrast and brightness adjustmentatmo.gpu.hue=Vec3(0.2,0.6,1.0)-- scattering rgb parameters that affect the overall hue
The includedmain.lua
example allows playing with atmosphere options to obtain the perfect settings. It features a basic fog model and some unrealistically scaled terrain.
A good overview of the technique can be found in theSimulating the Colors of the Sky article. Credit for the sun and atmosphere shader goes toglsl-atmosphere repository (MIT license) by Rye Terrell.
Theskybox.lua
code by itself can be used for baking any scene onto the skybox. Best used for static scenes where objects are far away from camera.
About
Atmosphere rendering for LÖVR framework