Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
41d738ad
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,发现更多精彩内容 >>
提交
41d738ad
编写于
8月 20, 2019
作者:
S
sunag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ibl normals in reflectnode using StandardNode
上级
5be26401
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
60 addition
and
10 deletion
+60
-10
examples/jsm/nodes/accessors/NormalNode.js
examples/jsm/nodes/accessors/NormalNode.js
+1
-1
examples/jsm/nodes/accessors/ReflectNode.js
examples/jsm/nodes/accessors/ReflectNode.js
+48
-8
examples/jsm/nodes/materials/nodes/StandardNode.js
examples/jsm/nodes/materials/nodes/StandardNode.js
+11
-1
未找到文件。
examples/jsm/nodes/accessors/NormalNode.js
浏览文件 @
41d738ad
...
...
@@ -87,7 +87,7 @@ NormalNode.prototype.toJSON = function ( meta ) {
};
NodeLib
.
addKeyword
(
'
n
ormal
'
,
function
()
{
NodeLib
.
addKeyword
(
'
viewN
ormal
'
,
function
()
{
return
new
NormalNode
();
...
...
examples/jsm/nodes/accessors/ReflectNode.js
浏览文件 @
41d738ad
...
...
@@ -8,7 +8,7 @@ import { NormalNode } from './NormalNode.js';
function
ReflectNode
(
scope
)
{
TempNode
.
call
(
this
,
'
v3
'
,
{
unique
:
true
}
);
TempNode
.
call
(
this
,
'
v3
'
);
this
.
scope
=
scope
||
ReflectNode
.
CUBE
;
...
...
@@ -22,6 +22,12 @@ ReflectNode.prototype = Object.create( TempNode.prototype );
ReflectNode
.
prototype
.
constructor
=
ReflectNode
;
ReflectNode
.
prototype
.
nodeType
=
"
Reflect
"
;
ReflectNode
.
prototype
.
getUnique
=
function
(
builder
)
{
return
!
builder
.
context
.
viewNormal
;
};
ReflectNode
.
prototype
.
getType
=
function
(
/* builder */
)
{
switch
(
this
.
scope
)
{
...
...
@@ -38,6 +44,8 @@ ReflectNode.prototype.getType = function ( /* builder */ ) {
ReflectNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
isUnique
=
this
.
getUnique
(
builder
);
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
var
result
;
...
...
@@ -46,33 +54,65 @@ ReflectNode.prototype.generate = function ( builder, output ) {
case
ReflectNode
.
VECTOR
:
var
viewNormal
=
new
NormalNode
().
build
(
builder
,
'
v3
'
);
var
viewNormalNode
=
builder
.
context
.
viewNormal
||
new
NormalNode
();
var
viewNormal
=
viewNormalNode
.
build
(
builder
,
'
v3
'
);
var
viewPosition
=
new
PositionNode
(
PositionNode
.
VIEW
).
build
(
builder
,
'
v3
'
);
builder
.
addNodeCode
(
'
vec3 reflectVec = inverseTransformDirection( reflect( -normalize(
'
+
viewPosition
+
'
),
'
+
viewNormal
+
'
), viewMatrix );
'
);
var
code
=
`inverseTransformDirection( reflect( -normalize(
${
viewPosition
}
),
${
viewNormal
}
), viewMatrix )`
;
if
(
isUnique
)
{
builder
.
addNodeCode
(
`vec3 reflectVec =
${
result
}
;`
);
result
=
'
reflectVec
'
;
}
else
{
result
=
code
;
}
break
;
case
ReflectNode
.
CUBE
:
var
reflectVec
=
new
ReflectNode
(
ReflectNode
.
VECTOR
).
build
(
builder
,
'
v3
'
);
builder
.
addNodeCode
(
'
vec3 reflectCubeVec = vec3( -1.0 *
'
+
reflectVec
+
'
.x,
'
+
reflectVec
+
'
.yz );
'
);
var
code
=
'
vec3( -
'
+
reflectVec
+
'
.x,
'
+
reflectVec
+
'
.yz )
'
;
if
(
isUnique
)
{
builder
.
addNodeCode
(
`vec3 reflectCubeVec =
${
result
}
;`
);
result
=
'
reflectCubeVec
'
;
}
else
{
result
=
code
;
}
break
;
case
ReflectNode
.
SPHERE
:
var
reflectVec
=
new
ReflectNode
(
ReflectNode
.
VECTOR
).
build
(
builder
,
'
v3
'
);
builder
.
addNodeCode
(
'
vec2 reflectSphereVec = normalize( ( viewMatrix * vec4(
'
+
reflectVec
+
'
, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5;
'
);
var
code
=
'
normalize( ( viewMatrix * vec4(
'
+
reflectVec
+
'
, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5
'
;
if
(
isUnique
)
{
builder
.
addNodeCode
(
`vec2 reflectSphereVec =
${
result
}
;`
);
result
=
'
reflectSphereVec
'
;
}
else
{
result
=
code
;
}
break
;
}
...
...
examples/jsm/nodes/materials/nodes/StandardNode.js
浏览文件 @
41d738ad
...
...
@@ -8,6 +8,7 @@ import {
}
from
'
../../../../../build/three.module.js
'
;
import
{
Node
}
from
'
../../core/Node.js
'
;
import
{
ExpressionNode
}
from
'
../../core/ExpressionNode.js
'
;
import
{
ColorNode
}
from
'
../../inputs/ColorNode.js
'
;
import
{
FloatNode
}
from
'
../../inputs/FloatNode.js
'
;
import
{
RoughnessToBlinnExponentNode
}
from
'
../../bsdfs/RoughnessToBlinnExponentNode.js
'
;
...
...
@@ -122,6 +123,7 @@ StandardNode.prototype.build = function ( builder ) {
var
contextEnvironment
=
{
bias
:
RoughnessToBlinnExponentNode
,
viewNormal
:
new
ExpressionNode
(
'
normal
'
,
'
v3
'
),
gamma
:
true
};
...
...
@@ -129,6 +131,12 @@ StandardNode.prototype.build = function ( builder ) {
gamma
:
true
};
var
contextClearCoatEnvironment
=
{
bias
:
RoughnessToBlinnExponentNode
,
viewNormal
:
new
ExpressionNode
(
'
clearCoatNormal
'
,
'
v3
'
),
gamma
:
true
};
var
useClearCoat
=
!
builder
.
isDefined
(
'
STANDARD
'
);
// analyze all nodes to reuse generate codes
...
...
@@ -212,7 +220,7 @@ StandardNode.prototype.build = function ( builder ) {
}
var
clearCoatEnv
=
useClearCoat
&&
environment
?
this
.
environment
.
flow
(
builder
,
'
c
'
,
{
cache
:
'
clearCoat
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
)
:
undefined
;
var
clearCoatEnv
=
useClearCoat
&&
environment
?
this
.
environment
.
flow
(
builder
,
'
c
'
,
{
cache
:
'
clearCoat
'
,
context
:
context
ClearCoat
Environment
,
slot
:
'
environment
'
}
)
:
undefined
;
builder
.
requires
.
transparent
=
alpha
!==
undefined
;
...
...
@@ -493,6 +501,7 @@ StandardNode.prototype.copy = function ( source ) {
if
(
source
.
clearCoat
)
this
.
clearCoat
=
source
.
clearCoat
;
if
(
source
.
clearCoatRoughness
)
this
.
clearCoatRoughness
=
source
.
clearCoatRoughness
;
if
(
source
.
clearCoatNormal
)
this
.
clearCoatNormal
=
source
.
clearCoatNormal
;
if
(
source
.
reflectivity
)
this
.
reflectivity
=
source
.
reflectivity
;
...
...
@@ -536,6 +545,7 @@ StandardNode.prototype.toJSON = function ( meta ) {
if
(
this
.
clearCoat
)
data
.
clearCoat
=
this
.
clearCoat
.
toJSON
(
meta
).
uuid
;
if
(
this
.
clearCoatRoughness
)
data
.
clearCoatRoughness
=
this
.
clearCoatRoughness
.
toJSON
(
meta
).
uuid
;
if
(
this
.
clearCoatNormal
)
data
.
clearCoatNormal
=
this
.
clearCoatNormal
.
toJSON
(
meta
).
uuid
;
if
(
this
.
reflectivity
)
data
.
reflectivity
=
this
.
reflectivity
.
toJSON
(
meta
).
uuid
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录