Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
a5584f2a
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
a5584f2a
编写于
10月 28, 2019
作者:
M
Mr.doob
提交者:
GitHub
10月 28, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17767 from sciecode/dev-ortho-light
ShaderChunks: Fix orthographic view direction
上级
3230bfae
c804a1b5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
6 deletion
+38
-6
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+10
-0
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
+13
-3
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
+11
-1
src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
...nderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
+1
-1
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js
...nderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js
+1
-1
src/renderers/webgl/WebGLProgram.js
src/renderers/webgl/WebGLProgram.js
+2
-0
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
a5584f2a
...
...
@@ -1781,6 +1781,16 @@ function WebGLRenderer( parameters ) {
}
if
(
material
.
isMeshPhongMaterial
||
material
.
isMeshLambertMaterial
||
material
.
isMeshBasicMaterial
||
material
.
isMeshStandardMaterial
||
material
.
isShaderMaterial
)
{
p_uniforms
.
setValue
(
_gl
,
'
isOrthographic
'
,
camera
.
isOrthographicCamera
===
true
);
}
if
(
material
.
isMeshPhongMaterial
||
material
.
isMeshLambertMaterial
||
material
.
isMeshBasicMaterial
||
...
...
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
浏览文件 @
a5584f2a
...
...
@@ -3,18 +3,28 @@ export default /* glsl */`
#ifdef ENV_WORLDPOS
vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
// Transforming Normal Vectors with the Inverse Transformation
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraTo
Vertex
, worldNormal );
vec3 reflectVec = reflect( cameraTo
Frag
, worldNormal );
#else
vec3 reflectVec = refract( cameraTo
Vertex
, worldNormal, refractionRatio );
vec3 reflectVec = refract( cameraTo
Frag
, worldNormal, refractionRatio );
#endif
...
...
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
浏览文件 @
a5584f2a
...
...
@@ -7,7 +7,17 @@ export default /* glsl */`
#else
vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
...
...
src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
浏览文件 @
a5584f2a
...
...
@@ -18,7 +18,7 @@ GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = normalize( vViewPosition );
geometry.viewDir =
( isOrthographic ) ? vec3( 0, 0, 1 ) :
normalize( vViewPosition );
#ifdef CLEARCOAT
...
...
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js
浏览文件 @
a5584f2a
...
...
@@ -4,7 +4,7 @@ vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = normalize( -mvPosition.xyz );
geometry.viewDir =
( isOrthographic ) ? vec3( 0, 0, 1 ) :
normalize( -mvPosition.xyz );
GeometricContext backGeometry;
backGeometry.position = geometry.position;
...
...
src/renderers/webgl/WebGLProgram.js
浏览文件 @
a5584f2a
...
...
@@ -496,6 +496,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet
'
uniform mat4 viewMatrix;
'
,
'
uniform mat3 normalMatrix;
'
,
'
uniform vec3 cameraPosition;
'
,
'
uniform bool isOrthographic;
'
,
'
#ifdef USE_INSTANCING
'
,
...
...
@@ -619,6 +620,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet
'
uniform mat4 viewMatrix;
'
,
'
uniform vec3 cameraPosition;
'
,
'
uniform bool isOrthographic;
'
,
(
parameters
.
toneMapping
!==
NoToneMapping
)
?
'
#define TONE_MAPPING
'
:
''
,
(
parameters
.
toneMapping
!==
NoToneMapping
)
?
ShaderChunk
[
'
tonemapping_pars_fragment
'
]
:
''
,
// this code is required here because it is used by the toneMapping() function defined below
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录