Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
1dcc2d75
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
1dcc2d75
编写于
8月 29, 2012
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
差异文件
Merged and fixed @crobi's normalmaps via derivatives.
See #2358
上级
eea8d110
fbd22e76
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
168 addition
and
96 deletion
+168
-96
build/three.min.js
build/three.min.js
+86
-84
src/materials/MeshPhongMaterial.js
src/materials/MeshPhongMaterial.js
+10
-1
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+18
-3
src/renderers/WebGLShaders.js
src/renderers/WebGLShaders.js
+54
-8
未找到文件。
build/three.min.js
浏览文件 @
1dcc2d75
此差异已折叠。
点击以展开。
src/materials/MeshPhongMaterial.js
浏览文件 @
1dcc2d75
...
...
@@ -17,6 +17,9 @@
* bumpMap: new THREE.Texture( <Image> ),
* bumpScale: <float>,
*
* normalMap: new THREE.Texture( <Image> ),
* normalScale: <float>,
*
* specularMap: new THREE.Texture( <Image> ),
*
* envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
...
...
@@ -64,6 +67,9 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this
.
bumpMap
=
null
;
this
.
bumpScale
=
1
;
this
.
normalMap
=
null
;
this
.
normalScale
=
1
;
this
.
specularMap
=
null
;
this
.
envMap
=
null
;
...
...
@@ -115,7 +121,10 @@ THREE.MeshPhongMaterial.prototype.clone = function () {
material
.
lightMap
=
this
.
lightMap
;
material
.
bumpMap
=
this
.
bumpMap
;
material
.
bumpScale
=
this
.
bumpScale
;
material
.
bumpScale
=
this
.
bumpScale
;
material
.
normalMap
=
this
.
normalMap
;
material
.
normalScale
=
this
.
normalScale
;
material
.
specularMap
=
this
.
specularMap
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
1dcc2d75
...
...
@@ -929,7 +929,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// material must use some texture to require uvs
if
(
material
.
map
||
material
.
lightMap
||
material
.
bumpMap
||
material
.
specularMap
||
material
instanceof
THREE
.
ShaderMaterial
)
{
if
(
material
.
map
||
material
.
lightMap
||
material
.
bumpMap
||
material
.
normalMap
||
material
.
specularMap
||
material
instanceof
THREE
.
ShaderMaterial
)
{
return
true
;
...
...
@@ -4593,6 +4593,7 @@ THREE.WebGLRenderer = function ( parameters ) {
envMap
:
!!
material
.
envMap
,
lightMap
:
!!
material
.
lightMap
,
bumpMap
:
!!
material
.
bumpMap
,
normalMap
:
!!
material
.
normalMap
,
specularMap
:
!!
material
.
specularMap
,
vertexColors
:
material
.
vertexColors
,
...
...
@@ -4945,10 +4946,18 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
material
.
normalMap
)
{
uniforms
.
normalMap
.
value
=
material
.
normalMap
;
uniforms
.
normalScale
.
value
=
material
.
normalScale
;
}
// uv repeat and offset setting priorities
// 1. color map
// 2. specular map
// 3. bump map
// 3. normal map
// 4. bump map
var
uvScaleMap
;
...
...
@@ -4960,6 +4969,10 @@ THREE.WebGLRenderer = function ( parameters ) {
uvScaleMap
=
material
.
specularMap
;
}
else
if
(
material
.
normalMap
)
{
uvScaleMap
=
material
.
normalMap
;
}
else
if
(
material
.
bumpMap
)
{
uvScaleMap
=
material
.
bumpMap
;
...
...
@@ -5889,6 +5902,7 @@ THREE.WebGLRenderer = function ( parameters ) {
parameters
.
envMap
?
"
#define USE_ENVMAP
"
:
""
,
parameters
.
lightMap
?
"
#define USE_LIGHTMAP
"
:
""
,
parameters
.
bumpMap
?
"
#define USE_BUMPMAP
"
:
""
,
parameters
.
normalMap
?
"
#define USE_NORMALMAP
"
:
""
,
parameters
.
specularMap
?
"
#define USE_SPECULARMAP
"
:
""
,
parameters
.
vertexColors
?
"
#define USE_COLOR
"
:
""
,
...
...
@@ -5969,7 +5983,7 @@ THREE.WebGLRenderer = function ( parameters ) {
"
precision
"
+
_precision
+
"
float;
"
,
parameters
.
bumpMap
?
"
#extension GL_OES_standard_derivatives : enable
"
:
""
,
(
parameters
.
bumpMap
||
parameters
.
normalMap
)
?
"
#extension GL_OES_standard_derivatives : enable
"
:
""
,
"
#define MAX_DIR_LIGHTS
"
+
parameters
.
maxDirLights
,
"
#define MAX_POINT_LIGHTS
"
+
parameters
.
maxPointLights
,
...
...
@@ -5991,6 +6005,7 @@ THREE.WebGLRenderer = function ( parameters ) {
parameters
.
envMap
?
"
#define USE_ENVMAP
"
:
""
,
parameters
.
lightMap
?
"
#define USE_LIGHTMAP
"
:
""
,
parameters
.
bumpMap
?
"
#define USE_BUMPMAP
"
:
""
,
parameters
.
normalMap
?
"
#define USE_NORMALMAP
"
:
""
,
parameters
.
specularMap
?
"
#define USE_SPECULARMAP
"
:
""
,
parameters
.
vertexColors
?
"
#define USE_COLOR
"
:
""
,
...
...
src/renderers/WebGLShaders.js
浏览文件 @
1dcc2d75
...
...
@@ -64,7 +64,7 @@ THREE.ShaderChunk = {
"
uniform float flipEnvMap;
"
,
"
uniform int combine;
"
,
"
#if
def USE_BUMPMAP
"
,
"
#if
defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
"
,
"
uniform bool useRefract;
"
,
"
uniform float refractionRatio;
"
,
...
...
@@ -85,7 +85,7 @@ THREE.ShaderChunk = {
"
vec3 reflectVec;
"
,
"
#if
def USE_BUMPMAP
"
,
"
#if
defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
"
,
"
vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
"
,
...
...
@@ -138,7 +138,7 @@ THREE.ShaderChunk = {
envmap_pars_vertex
:
[
"
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP )
"
,
"
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP )
&& ! defined( USE_NORMALMAP )
"
,
"
varying vec3 vReflect;
"
,
...
...
@@ -177,7 +177,7 @@ THREE.ShaderChunk = {
envmap_vertex
:
[
"
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP )
"
,
"
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP )
&& ! defined( USE_NORMALMAP )
"
,
"
vec3 nWorld = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;
"
,
...
...
@@ -222,7 +222,7 @@ THREE.ShaderChunk = {
map_pars_vertex
:
[
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_SPECULARMAP )
"
,
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_
NORMALMAP ) || defined( USE_
SPECULARMAP )
"
,
"
varying vec2 vUv;
"
,
"
uniform vec4 offsetRepeat;
"
,
...
...
@@ -233,7 +233,7 @@ THREE.ShaderChunk = {
map_pars_fragment
:
[
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_SPECULARMAP )
"
,
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_
NORMALMAP ) || defined( USE_
SPECULARMAP )
"
,
"
varying vec2 vUv;
"
,
...
...
@@ -249,7 +249,7 @@ THREE.ShaderChunk = {
map_vertex
:
[
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_SPECULARMAP )
"
,
"
#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_
NORMALMAP ) || defined( USE_
SPECULARMAP )
"
,
"
vUv = uv * offsetRepeat.zw + offsetRepeat.xy;
"
,
...
...
@@ -368,6 +368,40 @@ THREE.ShaderChunk = {
].
join
(
"
\n
"
),
// NORMAL MAP
normalmap_pars_fragment
:
[
"
#ifdef USE_NORMALMAP
"
,
"
uniform sampler2D normalMap;
"
,
"
uniform float normalScale;
"
,
// Per-Pixel Tangent Space Normal Mapping
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
"
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {
"
,
"
vec3 q0 = dFdx( eye_pos.xyz );
"
,
"
vec3 q1 = dFdy( eye_pos.xyz );
"
,
"
vec2 st0 = dFdx( vUv.st );
"
,
"
vec2 st1 = dFdy( vUv.st );
"
,
"
vec3 S = normalize( q0 * st1.t - q1 * st0.t );
"
,
"
vec3 T = normalize( -q0 * st1.s + q1 * st0.s );
"
,
"
vec3 N = normalize( surf_norm );
"
,
"
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
"
,
"
mapN.xy = normalScale * mapN.xy;
"
,
"
mat3 tsn = mat3( S, T, N );
"
,
"
return normalize( tsn * mapN );
"
,
"
}
"
,
"
#endif
"
].
join
(
"
\n
"
),
// SPECULAR MAP
specularmap_pars_fragment
:
[
...
...
@@ -825,7 +859,11 @@ THREE.ShaderChunk = {
"
#endif
"
,
"
#ifdef USE_BUMPMAP
"
,
"
#ifdef USE_NORMALMAP
"
,
"
normal = perturbNormal2Arb( -viewPosition, normal );
"
,
"
#elif defined( USE_BUMPMAP )
"
,
"
normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
"
,
...
...
@@ -1769,6 +1807,12 @@ THREE.UniformsLib = {
},
normalmap
:
{
"
normalMap
"
:
{
type
:
"
t
"
,
value
:
null
},
"
normalScale
"
:
{
type
:
"
f
"
,
value
:
1
}
},
fog
:
{
"
fogDensity
"
:
{
type
:
"
f
"
,
value
:
0.00025
},
...
...
@@ -2118,6 +2162,7 @@ THREE.ShaderLib = {
THREE
.
UniformsLib
[
"
common
"
],
THREE
.
UniformsLib
[
"
bump
"
],
THREE
.
UniformsLib
[
"
normalmap
"
],
THREE
.
UniformsLib
[
"
fog
"
],
THREE
.
UniformsLib
[
"
lights
"
],
THREE
.
UniformsLib
[
"
shadowmap
"
],
...
...
@@ -2194,6 +2239,7 @@ THREE.ShaderLib = {
THREE
.
ShaderChunk
[
"
lights_phong_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
shadowmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
bumpmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
normalmap_pars_fragment
"
],
THREE
.
ShaderChunk
[
"
specularmap_pars_fragment
"
],
"
void main() {
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录