-
Notifications
You must be signed in to change notification settings - Fork 0
/
LightWorld.lua
36 lines (27 loc) · 1.06 KB
/
LightWorld.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local class = require 'middleclass'
local Texture = require 'core/graphics/Texture'
local LightWorld = require 'core/graphics/LightWorld'
local DirectionalLight = require(here('DirectionalLight'))
local SphereLight = require(here('SphereLight'))
local AmbientBrdfLut = Texture:load{fileName=here('AmbientBrdfLut.png')}
local PbrLightWorld = class(here('LightWorld'), LightWorld)
PbrLightWorld.static.lightTypes =
{
directional = DirectionalLight,
sphere = SphereLight
}
function PbrLightWorld:initialize()
LightWorld.initialize(self, 'LightCount', 'LightPositionWS')
self:setMaxActiveLightCount(4)
self.shaderVariables:set('AmbientBrdfLutSampler', AmbientBrdfLut)
self:setAmbientLightValue(0)
end
function PbrLightWorld:setAmbientLightValue( value )
self.shaderVariables:set('AmbientLightValue', value)
end
function PbrLightWorld:createLight( typeName, ... )
local klass = self.class.lightTypes[typeName]
assert(klass, 'No implementation for this light type available.')
return self:_createLight(klass, ...)
end
return PbrLightWorld