Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AmbientCubemap light. Shader manage texture slot
- Loading branch information
Showing
15 changed files
with
329 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/AmbientCubemap/define(function(require) { | ||
define(function(require) { | ||
|
||
'use strict'; | ||
|
||
var Light = require('../Light'); | ||
var cubemapUtil = require('../util/cubemap'); | ||
|
||
/** | ||
* @constructor qtek.light.AmbientCubemap | ||
* @extends qtek.Light | ||
*/ | ||
var AmbientCubemapLight = Light.extend({ | ||
|
||
/** | ||
* @type {qtek.TextureCube} | ||
*/ | ||
cubemap: null, | ||
|
||
// TODO | ||
// range: 100, | ||
|
||
castShadow: false, | ||
|
||
_normalDistribution: null, | ||
_brdfLookup: null | ||
|
||
}, { | ||
|
||
type: 'AMBIENT_CUBEMAP_LIGHT', | ||
|
||
prefilter: function (renderer) { | ||
if (!this._brdfLookup) { | ||
this._normalDistribution = cubemapUtil.generateNormalDistribution(); | ||
this._brdfLookup = cubemapUtil.integrateBRDF(renderer, this._normalDistribution); | ||
} | ||
var cubemap = this.cubemap; | ||
if (cubemap.__prefiltered) { | ||
return; | ||
} | ||
|
||
var result = cubemapUtil.prefilterEnvironmentMap( | ||
renderer, cubemap, { | ||
encodeRGBM: true | ||
}, this._normalDistribution, this._brdfLookup | ||
); | ||
this.cubemap = result.environmentMap; | ||
this.cubemap.__prefiltered = true; | ||
|
||
cubemap.dispose(renderer.gl); | ||
}, | ||
|
||
uniformTemplates: { | ||
ambientCubemapLightColor: { | ||
type: '3f', | ||
value: function (instance) { | ||
var color = instance.color; | ||
var intensity = instance.intensity; | ||
return [color[0]*intensity, color[1]*intensity, color[2]*intensity]; | ||
} | ||
}, | ||
|
||
ambientCubemapLightCubemap: { | ||
type: 't', | ||
value: function (instance) { | ||
return instance.cubemap; | ||
} | ||
}, | ||
|
||
ambientCubemapLightBRDFLookup: { | ||
type: 't', | ||
value: function (instance) { | ||
return instance._brdfLookup; | ||
} | ||
} | ||
} | ||
/** | ||
* @method | ||
* @name clone | ||
* @return {qtek.light.AmbientCubemap} | ||
* @memberOf qtek.light.AmbientCubemap.prototype | ||
*/ | ||
}); | ||
|
||
return AmbientCubemapLight; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.