2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2020-01-15 12:07:09 +00:00
|
|
|
* @copyright 2020 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-26 23:17:11 +00:00
|
|
|
var Class = require('../../../utils/Class');
|
2020-08-21 15:01:39 +00:00
|
|
|
var GetFastValue = require('../../../utils/object/GetFastValue');
|
2020-10-13 17:17:30 +00:00
|
|
|
var PointLightShaderSourceFS = require('../shaders/PointLight-frag.js');
|
|
|
|
var PointLightShaderSourceVS = require('../shaders/PointLight-vert.js');
|
2020-11-30 09:46:13 +00:00
|
|
|
var PostFXPipeline = require('./PostFXPipeline');
|
2020-10-28 17:39:31 +00:00
|
|
|
var WEBGL_CONST = require('../const');
|
2018-02-09 19:19:21 +00:00
|
|
|
|
2020-08-21 15:01:39 +00:00
|
|
|
var LightPipeline = new Class({
|
2018-01-26 23:17:11 +00:00
|
|
|
|
2020-11-30 09:46:13 +00:00
|
|
|
Extends: PostFXPipeline,
|
2020-10-13 17:17:30 +00:00
|
|
|
|
2018-01-26 23:17:11 +00:00
|
|
|
initialize:
|
|
|
|
|
2020-08-21 15:01:39 +00:00
|
|
|
function LightPipeline (config)
|
2018-01-26 23:17:11 +00:00
|
|
|
{
|
2020-11-23 10:19:31 +00:00
|
|
|
config.shaders = GetFastValue(config, 'shaders', [
|
|
|
|
{
|
|
|
|
name: 'PointLight',
|
|
|
|
fragShader: PointLightShaderSourceFS,
|
|
|
|
vertShader: PointLightShaderSourceVS,
|
2020-11-30 09:46:13 +00:00
|
|
|
attributes: [
|
|
|
|
{
|
|
|
|
name: 'inPosition',
|
|
|
|
size: 2,
|
|
|
|
type: WEBGL_CONST.FLOAT
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'inLightPosition',
|
|
|
|
size: 2,
|
|
|
|
type: WEBGL_CONST.FLOAT
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'inLightRadius',
|
|
|
|
size: 1,
|
|
|
|
type: WEBGL_CONST.FLOAT
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'inLightColor',
|
|
|
|
size: 4,
|
|
|
|
type: WEBGL_CONST.FLOAT
|
|
|
|
}
|
|
|
|
],
|
2020-11-23 10:19:31 +00:00
|
|
|
uniforms: [
|
|
|
|
'uProjectionMatrix',
|
|
|
|
'uResolution'
|
|
|
|
]
|
2020-10-13 17:17:30 +00:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
2020-11-30 09:46:13 +00:00
|
|
|
PostFXPipeline.call(this, config);
|
2018-01-26 23:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-08-21 15:01:39 +00:00
|
|
|
module.exports = LightPipeline;
|