Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
6ae79e97
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,体验更适合开发者的 AI 搜索 >>
提交
6ae79e97
编写于
2月 12, 2016
作者:
B
Ben Houston
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mostly working.
上级
837cd593
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
166 addition
and
4 deletion
+166
-4
examples/js/pmrem/PMREM_CubeUVPacker.js
examples/js/pmrem/PMREM_CubeUVPacker.js
+1
-0
src/Three.js
src/Three.js
+2
-0
src/renderers/shaders/ShaderChunk/bsdfs.glsl
src/renderers/shaders/ShaderChunk/bsdfs.glsl
+4
-0
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
...rers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
+136
-0
src/renderers/shaders/ShaderChunk/lights_pars.glsl
src/renderers/shaders/ShaderChunk/lights_pars.glsl
+10
-0
src/renderers/shaders/ShaderChunk/lights_template.glsl
src/renderers/shaders/ShaderChunk/lights_template.glsl
+3
-3
src/renderers/shaders/ShaderLib.js
src/renderers/shaders/ShaderLib.js
+1
-0
src/renderers/webgl/WebGLProgram.js
src/renderers/webgl/WebGLProgram.js
+6
-1
src/renderers/webgl/WebGLPrograms.js
src/renderers/webgl/WebGLPrograms.js
+2
-0
utils/build/includes/common.json
utils/build/includes/common.json
+1
-0
未找到文件。
examples/js/pmrem/PMREM_CubeUVPacker.js
浏览文件 @
6ae79e97
/**
* @author Prashant Sharma / spidersharma03
* @author Ben Houston / bhouston, https://clara.io
*/
...
...
src/Three.js
浏览文件 @
6ae79e97
...
...
@@ -219,6 +219,8 @@ THREE.EquirectangularReflectionMapping = 303;
THREE
.
EquirectangularRefractionMapping
=
304
;
THREE
.
SphericalReflectionMapping
=
305
;
THREE
.
CubeUVReflectionMapping
=
306
;
THREE
.
CubeUVRefractionMapping
=
307
;
// Wrapping modes
...
...
src/renderers/shaders/ShaderChunk/bsdfs.glsl
浏览文件 @
6ae79e97
...
...
@@ -148,3 +148,7 @@ vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in Ge
float
GGXRoughnessToBlinnExponent
(
const
in
float
ggxRoughness
)
{
return
(
2
.
0
/
square
(
ggxRoughness
+
0
.
0001
)
-
2
.
0
);
}
float
BlinnExponentToGGXRoughness
(
const
in
float
blinnExponent
)
{
return
sqrt
(
2
.
0
/
(
blinnExponent
+
2
.
0
)
);
}
src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
0 → 100644
浏览文件 @
6ae79e97
#ifdef ENVMAP_TYPE_CUBE_UV
int
getFaceFromDirection
(
vec3
direction
)
{
vec3
absDirection
=
abs
(
direction
);
int
face
=
-
1
;
if
(
absDirection
.
x
>
absDirection
.
z
)
{
if
(
absDirection
.
x
>
absDirection
.
y
)
face
=
direction
.
x
>
0
.
0
?
0
:
3
;
else
face
=
direction
.
y
>
0
.
0
?
1
:
4
;
}
else
{
if
(
absDirection
.
z
>
absDirection
.
y
)
face
=
direction
.
z
>
0
.
0
?
2
:
5
;
else
face
=
direction
.
y
>
0
.
0
?
1
:
4
;
}
return
face
;
}
vec2
MipLevelInfo
(
vec3
vec
,
float
textureSize
)
{
float
s
=
log2
(
textureSize
*
0
.
25
)
-
1
.
0
;
float
scale
=
pow
(
2
.
0
,
s
);
vec3
dx
=
dFdx
(
vec
*
scale
);
vec3
dy
=
dFdy
(
vec
*
scale
);
float
d
=
max
(
dot
(
dx
,
dx
),
dot
(
dy
,
dy
)
);
// Clamp the value to the max mip level counts. hard coded to 6 mips
float
rangeClamp
=
pow
(
2
.
0
,
(
6
.
0
-
1
.
0
)
*
2
.
0
);
d
=
clamp
(
d
,
1
.
0
,
rangeClamp
);
float
mipLevel
=
0
.
5
*
log2
(
d
);
return
vec2
(
floor
(
mipLevel
),
fract
(
mipLevel
));
}
vec2
getCubeUV
(
vec3
direction
,
float
roughnessLevel
,
float
mipLevel
,
float
textureSize
)
{
float
maxLods
=
log2
(
textureSize
*
0
.
25
)
-
2
.
0
;
mipLevel
=
roughnessLevel
>
maxLods
-
3
.
0
?
0
.
0
:
mipLevel
;
float
a
=
16
.
0
/
textureSize
;
float
powScale
=
pow
(
2
.
0
,
roughnessLevel
+
mipLevel
);
float
scale
=
1
.
0
/
pow
(
2
.
0
,
roughnessLevel
+
2
.
0
+
mipLevel
);
float
mipOffset
=
0
.
75
*
(
1
.
0
-
1
.
0
/
pow
(
2
.
0
,
mipLevel
))
/
pow
(
2
.
0
,
roughnessLevel
);
bool
bRes
=
mipLevel
==
0
.
0
;
scale
=
bRes
&&
(
scale
<
a
)
?
a
:
scale
;
vec3
r
;
vec2
offset
;
int
face
=
getFaceFromDirection
(
direction
);
if
(
face
==
0
)
{
r
=
vec3
(
direction
.
x
,
-
direction
.
z
,
direction
.
y
);
offset
=
vec2
(
0
.
0
+
mipOffset
,
0
.
75
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
1
)
{
r
=
vec3
(
direction
.
y
,
direction
.
x
,
direction
.
z
);
offset
=
vec2
(
scale
+
mipOffset
,
0
.
75
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
2
)
{
r
=
vec3
(
direction
.
z
,
direction
.
x
,
direction
.
y
);
offset
=
vec2
(
2
.
0
*
scale
+
mipOffset
,
0
.
75
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
a
:
offset
.
y
;
}
else
if
(
face
==
3
)
{
r
=
vec3
(
direction
.
x
,
direction
.
z
,
direction
.
y
);
offset
=
vec2
(
0
.
0
+
mipOffset
,
0
.
5
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
else
if
(
face
==
4
)
{
r
=
vec3
(
direction
.
y
,
direction
.
x
,
-
direction
.
z
);
offset
=
vec2
(
scale
+
mipOffset
,
0
.
5
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
else
{
r
=
vec3
(
direction
.
z
,
-
direction
.
x
,
direction
.
y
);
offset
=
vec2
(
2
.
0
*
scale
+
mipOffset
,
0
.
5
/
powScale
);
offset
.
y
=
bRes
&&
(
offset
.
y
<
2
.
0
*
a
)
?
0
.
0
:
offset
.
y
;
}
r
=
normalize
(
r
);
float
texelOffset
=
0
.
5
/
textureSize
;
float
s1
=
(
r
.
y
/
abs
(
r
.
x
)
+
1
.
0
)
*
0
.
5
;
float
s2
=
(
r
.
z
/
abs
(
r
.
x
)
+
1
.
0
)
*
0
.
5
;
vec2
uv
=
offset
+
vec2
(
s1
*
scale
,
s2
*
scale
);
float
min_x
=
offset
.
x
+
texelOffset
;
float
max_x
=
offset
.
x
+
scale
-
texelOffset
;
float
min_y
=
offset
.
y
+
texelOffset
;
float
max_y
=
offset
.
y
+
scale
-
texelOffset
;
float
delx
=
max_x
-
min_x
;
float
dely
=
max_y
-
min_y
;
uv
.
x
=
min_x
+
s1
*
delx
;
uv
.
y
=
min_y
+
s2
*
dely
;
return
uv
;
}
vec3
convertRGBEToRGB
(
vec4
rgbe
)
{
float
d
=
pow
(
2
.
0
,
rgbe
.
w
*
256
.
0
-
128
.
0
);
return
vec3
(
rgbe
)
*
d
;
}
vec3
tonemap
(
vec3
RGB
)
{
float
LogAvgLum
=
0
.
08
;
//0.08
float
key
=
1
.
0
;
float
Ywhite
=
1e3
;
Ywhite
*=
Ywhite
;
float
sat
=
1
.
0
;
float
Ylum
=
dot
(
RGB
,
vec3
(
0
.
2126
,
0
.
7152
,
0
.
0722
));
float
Y
=
key
/
LogAvgLum
*
Ylum
;
float
Yd
=
Y
*
(
1
.
0
+
Y
/
Ywhite
)
/
(
1
.
0
+
Y
)
;
return
Yd
*
pow
(
RGB
/
Ylum
,
vec3
(
sat
,
sat
,
sat
));
}
vec4
textureCubeUV
(
vec3
reflectedDirection
,
float
roughness
,
float
textureSize
)
{
float
maxLods
=
log2
(
textureSize
*
0
.
25
)
-
3
.
0
;
float
roughnessVal
=
roughness
*
maxLods
;
float
r1
=
floor
(
roughnessVal
);
float
r2
=
r1
+
1
.
0
;
float
t
=
fract
(
roughnessVal
);
vec2
mipInfo
=
MipLevelInfo
(
reflectedDirection
,
textureSize
);
float
s
=
mipInfo
.
y
;
float
level0
=
mipInfo
.
x
;
float
level1
=
level0
+
1
.
0
;
level1
=
level1
>
5
.
0
?
5
.
0
:
level1
;
// Tri linear interpolation.
vec2
uv_10
=
getCubeUV
(
reflectedDirection
,
r1
,
level0
,
textureSize
);
vec2
uv_11
=
getCubeUV
(
reflectedDirection
,
r1
,
level1
,
textureSize
);
vec2
uv_20
=
getCubeUV
(
reflectedDirection
,
r2
,
level0
,
textureSize
);
vec2
uv_21
=
getCubeUV
(
reflectedDirection
,
r2
,
level1
,
textureSize
);
vec4
color10
=
texelDecode
(
texture2D
(
envMap
,
uv_10
),
envMapEncoding
);
vec4
color11
=
texelDecode
(
texture2D
(
envMap
,
uv_11
),
envMapEncoding
);
vec4
color20
=
texelDecode
(
texture2D
(
envMap
,
uv_20
),
envMapEncoding
);
vec4
color21
=
texelDecode
(
texture2D
(
envMap
,
uv_21
),
envMapEncoding
);
vec4
c1
=
mix
(
color10
,
color11
,
s
);
vec4
c2
=
mix
(
color20
,
color21
,
s
);
vec4
c3
=
mix
(
c1
,
c2
,
t
);
return
vec4
((
c3
.
rgb
)
/
(
c3
.
rgb
+
1
.
0
),
1
.
0
);
}
#endif
\ No newline at end of file
src/renderers/shaders/ShaderChunk/lights_pars.glsl
浏览文件 @
6ae79e97
...
...
@@ -180,6 +180,11 @@
#endif
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec3
queryVec
=
flipNormal
*
vec3
(
flipEnvMap
*
worldNormal
.
x
,
worldNormal
.
yz
);
vec4
envMapColor
=
textureCubeUV
(
queryVec
,
1
.
0
,
1024
.
0
);
#else
vec3
envMapColor
=
vec3
(
0
.
0
);
...
...
@@ -246,6 +251,11 @@
#endif
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec3
queryReflectVec
=
flipNormal
*
vec3
(
flipEnvMap
*
reflectVec
.
x
,
reflectVec
.
yz
);
vec4
envMapColor
=
textureCubeUV
(
queryReflectVec
,
BlinnExponentToGGXRoughness
(
blinnShininessExponent
),
1024
.
0
);
#elif defined( ENVMAP_TYPE_EQUIREC )
vec2
sampleUV
;
...
...
src/renderers/shaders/ShaderChunk/lights_template.glsl
浏览文件 @
6ae79e97
...
...
@@ -101,12 +101,12 @@ IncidentLight directLight;
#endif
// #if defined( USE_ENVMAP ) && defined( STANDARD
)
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV
)
// TODO, replace 8 with the real maxMIPLevel
// irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, 8 ); // comment out until seams are fixed
irradiance
+=
getLightProbeIndirectIrradiance
(
/*lightProbe,*/
geometry
,
8
);
//
#endif
#endif
RE_IndirectDiffuse
(
irradiance
,
geometry
,
material
,
reflectedLight
);
...
...
src/renderers/shaders/ShaderLib.js
浏览文件 @
6ae79e97
...
...
@@ -546,6 +546,7 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
bsdfs
"
],
THREE
.
ShaderChunk
[
"
encodings
"
],
THREE
.
ShaderChunk
[
"
ambient_pars
"
],
THREE
.
ShaderChunk
[
"
cube_uv_reflection_fragment
"
],
THREE
.
ShaderChunk
[
"
lights_pars
"
],
THREE
.
ShaderChunk
[
"
lights_standard_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_pars_fragment
"
],
...
...
src/renderers/webgl/WebGLProgram.js
浏览文件 @
6ae79e97
...
...
@@ -12,7 +12,7 @@ THREE.WebGLProgram = ( function () {
extensions
=
extensions
||
{};
var
chunks
=
[
(
extensions
.
derivatives
||
parameters
.
bumpMap
||
parameters
.
normalMap
||
parameters
.
flatShading
)
?
'
#extension GL_OES_standard_derivatives : enable
'
:
''
,
(
extensions
.
derivatives
||
parameters
.
envMapCubeUV
||
parameters
.
bumpMap
||
parameters
.
normalMap
||
parameters
.
flatShading
)
?
'
#extension GL_OES_standard_derivatives : enable
'
:
''
,
(
extensions
.
fragDepth
||
parameters
.
logarithmicDepthBuffer
)
&&
rendererExtensions
.
get
(
'
EXT_frag_depth
'
)
?
'
#extension GL_EXT_frag_depth : enable
'
:
''
,
(
extensions
.
drawBuffers
)
&&
rendererExtensions
.
get
(
'
WEBGL_draw_buffers
'
)
?
'
#extension GL_EXT_draw_buffers : require
'
:
''
,
(
extensions
.
shaderTextureLOD
||
parameters
.
envMap
)
&&
rendererExtensions
.
get
(
'
EXT_shader_texture_lod
'
)
?
'
#extension GL_EXT_shader_texture_lod : enable
'
:
''
,
...
...
@@ -218,6 +218,11 @@ THREE.WebGLProgram = ( function () {
envMapTypeDefine
=
'
ENVMAP_TYPE_CUBE
'
;
break
;
case
THREE
.
CubeUVReflectionMapping
:
case
THREE
.
CubeUVRefractionMapping
:
envMapTypeDefine
=
'
ENVMAP_TYPE_CUBE_UV
'
;
break
;
case
THREE
.
EquirectangularReflectionMapping
:
case
THREE
.
EquirectangularRefractionMapping
:
envMapTypeDefine
=
'
ENVMAP_TYPE_EQUIREC
'
;
...
...
src/renderers/webgl/WebGLPrograms.js
浏览文件 @
6ae79e97
...
...
@@ -98,6 +98,8 @@ THREE.WebGLPrograms = function ( renderer, capabilities ) {
map
:
!!
material
.
map
,
envMap
:
!!
material
.
envMap
,
envMapMode
:
material
.
envMap
&&
material
.
envMap
.
mapping
,
envMapCubeUV
:
(
!!
material
.
envMap
)
&&
((
material
.
envMap
.
mapping
===
THREE
.
CubeUVReflectionMapping
)
||
(
material
.
envMap
.
mapping
===
THREE
.
CubeUVRefractionMapping
)),
lightMap
:
!!
material
.
lightMap
,
aoMap
:
!!
material
.
aoMap
,
emissiveMap
:
!!
material
.
emissiveMap
,
...
...
utils/build/includes/common.json
浏览文件 @
6ae79e97
...
...
@@ -132,6 +132,7 @@
"src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/color_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/common.glsl"
,
"src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl"
,
"src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl"
,
"src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录