Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
ba2ed44d
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba2ed44d
编写于
4月 11, 2019
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for light probes
上级
c14c769d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
0 deletion
+59
-0
src/Three.js
src/Three.js
+2
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+2
-0
src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
...nderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
+2
-0
src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
+38
-0
src/renderers/shaders/UniformsLib.js
src/renderers/shaders/UniformsLib.js
+2
-0
src/renderers/webgl/WebGLLights.js
src/renderers/webgl/WebGLLights.js
+13
-0
未找到文件。
src/Three.js
浏览文件 @
ba2ed44d
...
...
@@ -60,6 +60,7 @@ export { DirectionalLight } from './lights/DirectionalLight.js';
export
{
AmbientLight
}
from
'
./lights/AmbientLight.js
'
;
export
{
LightShadow
}
from
'
./lights/LightShadow.js
'
;
export
{
Light
}
from
'
./lights/Light.js
'
;
export
{
LightProbe
}
from
'
./lights/LightProbe.js
'
;
export
{
StereoCamera
}
from
'
./cameras/StereoCamera.js
'
;
export
{
PerspectiveCamera
}
from
'
./cameras/PerspectiveCamera.js
'
;
export
{
OrthographicCamera
}
from
'
./cameras/OrthographicCamera.js
'
;
...
...
@@ -123,6 +124,7 @@ export { Vector3 } from './math/Vector3.js';
export
{
Vector2
}
from
'
./math/Vector2.js
'
;
export
{
Quaternion
}
from
'
./math/Quaternion.js
'
;
export
{
Color
}
from
'
./math/Color.js
'
;
export
{
SphericalHarmonics3
}
from
'
./math/SphericalHarmonics3.js
'
;
export
{
ImmediateRenderObject
}
from
'
./extras/objects/ImmediateRenderObject.js
'
;
export
{
VertexNormalsHelper
}
from
'
./helpers/VertexNormalsHelper.js
'
;
export
{
SpotLightHelper
}
from
'
./helpers/SpotLightHelper.js
'
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
ba2ed44d
...
...
@@ -1599,6 +1599,7 @@ function WebGLRenderer( parameters ) {
// wire up the material to this renderer's lighting state
uniforms
.
ambientLightColor
.
value
=
lights
.
state
.
ambient
;
uniforms
.
lightProbe
.
value
=
lights
.
state
.
probe
;
uniforms
.
directionalLights
.
value
=
lights
.
state
.
directional
;
uniforms
.
spotLights
.
value
=
lights
.
state
.
spot
;
uniforms
.
rectAreaLights
.
value
=
lights
.
state
.
rectArea
;
...
...
@@ -2402,6 +2403,7 @@ function WebGLRenderer( parameters ) {
function
markUniformsLightsNeedsUpdate
(
uniforms
,
value
)
{
uniforms
.
ambientLightColor
.
needsUpdate
=
value
;
uniforms
.
lightProbe
.
needsUpdate
=
value
;
uniforms
.
directionalLights
.
needsUpdate
=
value
;
uniforms
.
pointLights
.
needsUpdate
=
value
;
...
...
src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
浏览文件 @
ba2ed44d
...
...
@@ -103,6 +103,8 @@ IncidentLight directLight;
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
irradiance += getLightProbeIrradiance( lightProbe, geometry );
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop
...
...
src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
浏览文件 @
ba2ed44d
export
default
/* glsl */
`
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
// normal is assumed to have unit length
float x = normal.x, y = normal.y, z = normal.z;
// band 0
vec3 result = shCoefficients[ 0 ] * 0.886227;
// band 1
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
// band 2
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
...
...
src/renderers/shaders/UniformsLib.js
浏览文件 @
ba2ed44d
...
...
@@ -109,6 +109,8 @@ var UniformsLib = {
ambientLightColor
:
{
value
:
[]
},
lightProbe
:
{
value
:
[]
},
directionalLights
:
{
value
:
[],
properties
:
{
direction
:
{},
color
:
{},
...
...
src/renderers/webgl/WebGLLights.js
浏览文件 @
ba2ed44d
...
...
@@ -121,6 +121,7 @@ function WebGLLights() {
},
ambient
:
[
0
,
0
,
0
],
probe
:
[],
directional
:
[],
directionalShadowMap
:
[],
directionalShadowMatrix
:
[],
...
...
@@ -135,6 +136,8 @@ function WebGLLights() {
};
for
(
var
i
=
0
;
i
<
9
;
i
++
)
state
.
probe
.
push
(
new
Vector3
()
);
var
vector3
=
new
Vector3
();
var
matrix4
=
new
Matrix4
();
var
matrix42
=
new
Matrix4
();
...
...
@@ -143,6 +146,8 @@ function WebGLLights() {
var
r
=
0
,
g
=
0
,
b
=
0
;
for
(
var
i
=
0
;
i
<
9
;
i
++
)
state
.
probe
[
i
].
set
(
0
,
0
,
0
);
var
directionalLength
=
0
;
var
pointLength
=
0
;
var
spotLength
=
0
;
...
...
@@ -167,6 +172,14 @@ function WebGLLights() {
g
+=
color
.
g
*
intensity
;
b
+=
color
.
b
*
intensity
;
}
else
if
(
light
.
isLightProbe
)
{
for
(
var
j
=
0
;
j
<
9
;
j
++
)
{
state
.
probe
[
j
].
addScaledVector
(
light
.
sh
.
coefficients
[
j
],
intensity
);
}
}
else
if
(
light
.
isDirectionalLight
)
{
var
uniforms
=
cache
.
get
(
light
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录