Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
84f9c514
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,发现更多精彩内容 >>
未验证
提交
84f9c514
编写于
8月 21, 2019
作者:
M
Mr.doob
提交者:
GitHub
8月 21, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17295 from arobertson0/descriptive-defines-2
Separated the meanings of PHYSICAL
上级
76aa9087
f9918888
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
164 addition
and
129 deletion
+164
-129
docs/api/en/materials/MeshPhysicalMaterial.html
docs/api/en/materials/MeshPhysicalMaterial.html
+6
-1
docs/api/en/materials/MeshStandardMaterial.html
docs/api/en/materials/MeshStandardMaterial.html
+1
-1
docs/api/zh/materials/MeshPhysicalMaterial.html
docs/api/zh/materials/MeshPhysicalMaterial.html
+6
-1
docs/api/zh/materials/MeshStandardMaterial.html
docs/api/zh/materials/MeshStandardMaterial.html
+1
-1
examples/js/loaders/GLTFLoader.js
examples/js/loaders/GLTFLoader.js
+1
-1
examples/jsm/loaders/GLTFLoader.js
examples/jsm/loaders/GLTFLoader.js
+1
-1
examples/jsm/nodes/materials/nodes/StandardNode.js
examples/jsm/nodes/materials/nodes/StandardNode.js
+9
-3
examples/webgl_materials_envmaps_parallax.html
examples/webgl_materials_envmaps_parallax.html
+4
-47
src/materials/MeshPhysicalMaterial.js
src/materials/MeshPhysicalMaterial.js
+12
-2
src/materials/MeshStandardMaterial.js
src/materials/MeshStandardMaterial.js
+2
-2
src/renderers/shaders/ShaderChunk.d.ts
src/renderers/shaders/ShaderChunk.d.ts
+2
-0
src/renderers/shaders/ShaderChunk.js
src/renderers/shaders/ShaderChunk.js
+2
-0
src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js
...aders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js
+1
-1
src/renderers/shaders/ShaderChunk/common.glsl.js
src/renderers/shaders/ShaderChunk/common.glsl.js
+1
-1
src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js
...s/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js
+15
-0
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
+1
-1
src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js
...enderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js
+7
-14
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js
+8
-1
src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js
...shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js
+5
-1
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
+1
-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_fragment_maps.glsl.js
...enderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js
+1
-1
src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js
...rers/shaders/ShaderChunk/lights_physical_fragment.glsl.js
+15
-3
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
...shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
+9
-10
src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js
...enderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js
+17
-20
src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js
...erers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js
+5
-4
src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js
src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js
+1
-0
src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js
src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js
+1
-0
src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js
src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js
+1
-0
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js
+17
-4
src/renderers/shaders/ShaderLib/normal_frag.glsl.js
src/renderers/shaders/ShaderLib/normal_frag.glsl.js
+1
-1
src/renderers/shaders/ShaderLib/normal_vert.glsl.js
src/renderers/shaders/ShaderLib/normal_vert.glsl.js
+2
-2
src/renderers/webgl/WebGLProgram.js
src/renderers/webgl/WebGLProgram.js
+4
-1
src/renderers/webgl/WebGLPrograms.js
src/renderers/webgl/WebGLPrograms.js
+3
-2
未找到文件。
docs/api/en/materials/MeshPhysicalMaterial.html
浏览文件 @
84f9c514
...
...
@@ -73,7 +73,12 @@
<h3>
[property:Object defines]
</h3>
<p>
An object of the form:
<code>
{ 'PHYSICAL': '' };
{
'PHYSICAL': '',
'ADVANCED_PHYSICAL': ''
};
</code>
This is used by the [page:WebGLRenderer] for selecting shaders.
...
...
docs/api/en/materials/MeshStandardMaterial.html
浏览文件 @
84f9c514
...
...
@@ -122,7 +122,7 @@
<h3>
[property:Object defines]
</h3>
<p>
An object of the form:
<code>
{ '
STANDARD
': '' };
{ '
PHYSICAL
': '' };
</code>
This is used by the [page:WebGLRenderer] for selecting shaders.
...
...
docs/api/zh/materials/MeshPhysicalMaterial.html
浏览文件 @
84f9c514
...
...
@@ -67,7 +67,12 @@
<h3>
[property:Object defines]
</h3>
<p>
如下形式的对象:
<code>
{ 'PHYSICAL': '' };
{
'PHYSICAL': '',
'ADVANCED_PHYSICAL': ''
};
</code>
[page:WebGLRenderer]使用它来选择shaders。
</p>
...
...
docs/api/zh/materials/MeshStandardMaterial.html
浏览文件 @
84f9c514
...
...
@@ -97,7 +97,7 @@
<h3>
[property:Object defines]
</h3>
<p>
如下形式的对象:
<code>
{ '
STANDARD
': '' };
{ '
PHYSICAL
': '' };
</code>
[page:WebGLRenderer]使用它来选择shaders。
</p>
...
...
examples/js/loaders/GLTFLoader.js
浏览文件 @
84f9c514
...
...
@@ -726,7 +726,7 @@ THREE.GLTFLoader = ( function () {
materialParams
.
vertexShader
=
shader
.
vertexShader
;
materialParams
.
fragmentShader
=
fragmentShader
;
materialParams
.
uniforms
=
uniforms
;
materialParams
.
defines
=
{
'
STANDARD
'
:
''
};
materialParams
.
defines
=
{
'
PHYSICAL
'
:
''
}
materialParams
.
color
=
new
THREE
.
Color
(
1.0
,
1.0
,
1.0
);
materialParams
.
opacity
=
1.0
;
...
...
examples/jsm/loaders/GLTFLoader.js
浏览文件 @
84f9c514
...
...
@@ -791,7 +791,7 @@ var GLTFLoader = ( function () {
materialParams
.
vertexShader
=
shader
.
vertexShader
;
materialParams
.
fragmentShader
=
fragmentShader
;
materialParams
.
uniforms
=
uniforms
;
materialParams
.
defines
=
{
'
STANDARD
'
:
''
};
materialParams
.
defines
=
{
'
PHYSICAL
'
:
''
}
materialParams
.
color
=
new
Color
(
1.0
,
1.0
,
1.0
);
materialParams
.
opacity
=
1.0
;
...
...
examples/jsm/nodes/materials/nodes/StandardNode.js
浏览文件 @
84f9c514
...
...
@@ -33,7 +33,15 @@ StandardNode.prototype.build = function ( builder ) {
var
code
;
builder
.
define
(
this
.
clearcoat
||
this
.
clearcoatRoughness
||
this
.
clearcoatNormal
?
'
PHYSICAL
'
:
'
STANDARD
'
);
builder
.
define
(
'
PHYSICAL
'
);
var
useClearcoat
=
this
.
clearcoat
||
this
.
clearcoatRoughness
||
this
.
clearCoatNormal
;
if
(
useClearcoat
){
builder
.
define
(
'
CLEARCOAT
'
);
}
builder
.
requires
.
lights
=
true
;
...
...
@@ -137,8 +145,6 @@ StandardNode.prototype.build = function ( builder ) {
gamma
:
true
};
var
useClearcoat
=
!
builder
.
isDefined
(
'
STANDARD
'
);
// analyze all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
analyze
(
builder
);
...
...
examples/webgl_materials_envmaps_parallax.html
浏览文件 @
84f9c514
...
...
@@ -38,17 +38,10 @@
#endif
`
;
var
envmapParsReplace
=
`
#define BOX_PROJECTED_ENV_MAP
#if defined( USE_ENVMAP ) || defined( PHYSICAL )
uniform float reflectivity;
uniform float envMapIntensity;
#endif
var
envmapPhysicalParsReplace
=
`
#if defined( USE_ENVMAP )
#ifdef USE_ENV
MAP
#define BOX_PROJECTED_ENV_
MAP
#ifdef BOX_PROJECTED_ENV_MAP
...
...
@@ -75,41 +68,10 @@
#endif
#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )
varying vec3 vWorldPosition;
#endif
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform int maxMipLevel;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )
#ifdef ENVMAP_MODE_REFRACTION
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif
`
;
var
envmapPhysicalParsReplace
=
`
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
#ifdef ENVMAP_TYPE_CUBE
...
...
@@ -349,11 +311,6 @@
worldposReplace
);
shader
.
fragmentShader
=
shader
.
fragmentShader
.
replace
(
'
#include <envmap_pars_fragment>
'
,
envmapParsReplace
);
shader
.
fragmentShader
=
shader
.
fragmentShader
.
replace
(
'
#include <envmap_physical_pars_fragment>
'
,
envmapPhysicalParsReplace
...
...
src/materials/MeshPhysicalMaterial.js
浏览文件 @
84f9c514
...
...
@@ -21,7 +21,12 @@ function MeshPhysicalMaterial( parameters ) {
MeshStandardMaterial
.
call
(
this
);
this
.
defines
=
{
'
PHYSICAL
'
:
''
};
this
.
defines
=
{
'
PHYSICAL
'
:
''
,
'
ADVANCED_PHYSICAL
'
:
''
};
this
.
type
=
'
MeshPhysicalMaterial
'
;
...
...
@@ -48,7 +53,12 @@ MeshPhysicalMaterial.prototype.copy = function ( source ) {
MeshStandardMaterial
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
defines
=
{
'
PHYSICAL
'
:
''
};
this
.
defines
=
{
'
PHYSICAL
'
:
''
,
'
ADVANCED_PHYSICAL
'
:
''
};
this
.
reflectivity
=
source
.
reflectivity
;
...
...
src/materials/MeshStandardMaterial.js
浏览文件 @
84f9c514
...
...
@@ -59,7 +59,7 @@ function MeshStandardMaterial( parameters ) {
Material
.
call
(
this
);
this
.
defines
=
{
'
STANDARD
'
:
''
};
this
.
defines
=
{
'
PHYSICAL
'
:
''
};
this
.
type
=
'
MeshStandardMaterial
'
;
...
...
@@ -123,7 +123,7 @@ MeshStandardMaterial.prototype.copy = function ( source ) {
Material
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
defines
=
{
'
STANDARD
'
:
''
};
this
.
defines
=
{
'
PHYSICAL
'
:
''
};
this
.
color
.
copy
(
source
.
color
);
this
.
roughness
=
source
.
roughness
;
...
...
src/renderers/shaders/ShaderChunk.d.ts
浏览文件 @
84f9c514
...
...
@@ -35,6 +35,7 @@ export let ShaderChunk: {
encodings_pars_fragment
:
string
;
encodings_fragment
:
string
;
envmap_fragment
:
string
;
envmap_common_pars_fragment
:
string
envmap_pars_fragment
:
string
;
envmap_pars_vertex
:
string
;
envmap_vertex
:
string
;
...
...
@@ -48,6 +49,7 @@ export let ShaderChunk: {
lightmap_pars_fragment
:
string
;
lights_lambert_vertex
:
string
;
lights_pars_begin
:
string
;
envmap_physical_pars_fragment
:
string
;
lights_pars_map
:
string
;
lights_phong_fragment
:
string
;
lights_phong_pars_fragment
:
string
;
...
...
src/renderers/shaders/ShaderChunk.js
浏览文件 @
84f9c514
...
...
@@ -25,6 +25,7 @@ import emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.g
import
encodings_fragment
from
'
./ShaderChunk/encodings_fragment.glsl.js
'
;
import
encodings_pars_fragment
from
'
./ShaderChunk/encodings_pars_fragment.glsl.js
'
;
import
envmap_fragment
from
'
./ShaderChunk/envmap_fragment.glsl.js
'
;
import
envmap_common_pars_fragment
from
'
./ShaderChunk/envmap_common_pars_fragment.glsl.js
'
;
import
envmap_pars_fragment
from
'
./ShaderChunk/envmap_pars_fragment.glsl.js
'
;
import
envmap_pars_vertex
from
'
./ShaderChunk/envmap_pars_vertex.glsl.js
'
;
import
envmap_vertex
from
'
./ShaderChunk/envmap_vertex.glsl.js
'
;
...
...
@@ -150,6 +151,7 @@ export var ShaderChunk = {
encodings_fragment
:
encodings_fragment
,
encodings_pars_fragment
:
encodings_pars_fragment
,
envmap_fragment
:
envmap_fragment
,
envmap_common_pars_fragment
:
envmap_common_pars_fragment
,
envmap_pars_fragment
:
envmap_pars_fragment
,
envmap_pars_vertex
:
envmap_pars_vertex
,
envmap_physical_pars_fragment
:
envmap_physical_pars_fragment
,
...
...
src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
vec3 clearcoatNormal = geometryNormal;
...
...
src/renderers/shaders/ShaderChunk/common.glsl.js
浏览文件 @
84f9c514
...
...
@@ -39,7 +39,7 @@ struct GeometricContext {
vec3 position;
vec3 normal;
vec3 viewDir;
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
vec3 clearcoatNormal;
#endif
};
...
...
src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js
0 → 100644
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform int maxMipLevel;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif
`
;
src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef USE_ENVMAP
#if
defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )
#if
def ENV_WORLDPOS
vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
...
...
src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#if defined( USE_ENVMAP ) || defined( PHYSICAL )
#ifdef USE_ENVMAP
uniform float reflectivity;
uniform float envMapIntensity;
#endif
#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG ) )
varying vec3 vWorldPosition;
#endif
#define ENV_WORLDPOS
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform int maxMipLevel;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
...
...
src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
...
...
src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
#if defined( USE_ENVMAP )
#ifdef ENVMAP_MODE_REFRACTION
uniform float refractionRatio;
#endif
vec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {
...
...
src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef USE_ENVMAP
#if
defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )
#if
def ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
...
...
src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js
浏览文件 @
84f9c514
...
...
@@ -20,7 +20,7 @@ geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = normalize( vViewPosition );
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
geometry.clearcoatNormal = clearcoatNormal;
...
...
src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js
浏览文件 @
84f9c514
...
...
@@ -27,7 +27,7 @@ export default /* glsl */`
radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
clearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, Material_Clearcoat_BlinnShininessExponent( material ), maxMipLevel );
...
...
src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js
浏览文件 @
84f9c514
...
...
@@ -2,14 +2,26 @@ export default /* glsl */`
PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
#ifdef STANDARD
material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
#else
#ifdef REFLECTIVITY
material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
#endif
#ifdef CLEARCOAT
material.clearcoat = saturate( clearcoat ); // Burley clearcoat model
material.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );
#endif
#ifdef USE_SHEEN
material.sheenColor = sheen;
#endif
`
;
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
浏览文件 @
84f9c514
...
...
@@ -5,14 +5,13 @@ struct PhysicalMaterial {
float specularRoughness;
vec3 specularColor;
#ifdef PHYSICAL
float clearcoat;
float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
#endif
#ifdef CLEARCOAT
float clearcoat;
float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
#endif
};
...
...
@@ -80,7 +79,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
#endif
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
float ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
...
...
@@ -123,7 +122,7 @@ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricCo
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef
PHYSICAL
#ifdef
CLEARCOAT
float ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
...
...
src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#ifdef USE_NORMALMAP
#ifdef OBJECTSPACE_NORMALMAP
#ifdef OBJECTSPACE_NORMALMAP
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals
#ifdef FLIP_SIDED
#ifdef FLIP_SIDED
normal = - normal;
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
#endif
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
#ifdef DOUBLE_SIDED
#endif
normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );
normal = normalize( normalMatrix * normal );
#endif
#else // tangent-space normal map
normal = normalize( normalMatrix * normal );
#ifdef USE_TANGENT
#elif defined( TANGENTSPACE_NORMALMAP )
mat3 vTBN = mat3( tangent, bitangent, normal );
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
mapN.xy = normalScale * mapN.xy;
normal = normalize( vTBN * mapN );
#ifdef USE_TANGENT
#else
mat3 vTBN = mat3( tangent, bitangent, normal );
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
mapN.xy = normalScale * mapN.xy;
normal = normalize( vTBN * mapN );
normal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );
#else
#endif
normal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );
#endif
...
...
src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js
浏览文件 @
84f9c514
...
...
@@ -4,14 +4,15 @@ export default /* glsl */`
uniform sampler2D normalMap;
uniform vec2 normalScale;
#ifdef OBJECTSPACE_NORMALMAP
#endif
#ifdef OBJECTSPACE_NORMALMAP
uniform mat3 normalMatrix;
uniform mat3 normalMatrix;
#endif
#endif
#if
( defined ( USE_NORMALMAP ) && !defined ( OBJECTSPACE_NORMALMAP )) || defined ( USE_CLEARCOAT_NORMALMAP
)
#if
! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP )
)
// Per-Pixel Tangent Space Normal Mapping
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
...
...
src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js
浏览文件 @
84f9c514
...
...
@@ -16,6 +16,7 @@ uniform float opacity;
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
...
...
src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js
浏览文件 @
84f9c514
...
...
@@ -23,6 +23,7 @@ varying vec3 vIndirectFront;
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
...
...
src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js
浏览文件 @
84f9c514
...
...
@@ -18,6 +18,7 @@ uniform float opacity;
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
...
...
src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#define PHYSICAL
#define PHYSICAL_REFLECTION
#ifdef PHYSICAL
#define CLEARCOAT
#endif
#ifdef ADVANCED_PHYSICAL
#define REFLECTIVITY
#define CLEARCOAT
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
...
...
@@ -7,11 +18,13 @@ uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef PHYSICAL
#ifdef REFLECTIVITY
uniform float reflectivity;
#endif
#ifdef CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_SHEEN
uniform vec3 sheen;
#endif
...
...
@@ -44,7 +57,7 @@ varying vec3 vViewPosition;
#include <emissivemap_pars_fragment>
#include <bsdfs>
#include <cube_uv_reflection_fragment>
#include <envmap_pars_fragment>
#include <envmap_
common_
pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
...
...
src/renderers/shaders/ShaderLib/normal_frag.glsl.js
浏览文件 @
84f9c514
...
...
@@ -3,7 +3,7 @@ export default /* glsl */`
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT
_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
defined( TANGENTSPACE
_NORMALMAP )
varying vec3 vViewPosition;
...
...
src/renderers/shaders/ShaderLib/normal_vert.glsl.js
浏览文件 @
84f9c514
export
default
/* glsl */
`
#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT
_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
defined( TANGENTSPACE
_NORMALMAP )
varying vec3 vViewPosition;
...
...
@@ -58,7 +58,7 @@ void main() {
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT
_NORMALMAP )
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) ||
defined( TANGENTSPACE
_NORMALMAP )
vViewPosition = - mvPosition.xyz;
...
...
src/renderers/webgl/WebGLProgram.js
浏览文件 @
84f9c514
...
...
@@ -120,7 +120,7 @@ function generateExtensions( extensions, parameters, rendererExtensions ) {
extensions
=
extensions
||
{};
var
chunks
=
[
(
extensions
.
derivatives
||
parameters
.
envMapCubeUV
||
parameters
.
bumpMap
||
(
parameters
.
normalMap
&&
!
parameters
.
objectSpaceNormalMap
)
||
parameters
.
clearcoatNormalMap
||
parameters
.
flatShading
)
?
'
#extension GL_OES_standard_derivatives : enable
'
:
''
,
(
extensions
.
derivatives
||
parameters
.
envMapCubeUV
||
parameters
.
bumpMap
||
parameters
.
tangentSpaceNormalMap
||
parameters
.
clearcoatNormalMap
||
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
'
:
''
...
...
@@ -391,6 +391,8 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
parameters
.
bumpMap
?
'
#define USE_BUMPMAP
'
:
''
,
parameters
.
normalMap
?
'
#define USE_NORMALMAP
'
:
''
,
(
parameters
.
normalMap
&&
parameters
.
objectSpaceNormalMap
)
?
'
#define OBJECTSPACE_NORMALMAP
'
:
''
,
(
parameters
.
normalMap
&&
parameters
.
tangentSpaceNormalMap
)
?
'
#define TANGENTSPACE_NORMALMAP
'
:
''
,
parameters
.
clearcoatNormalMap
?
'
#define USE_CLEARCOAT_NORMALMAP
'
:
''
,
parameters
.
displacementMap
&&
parameters
.
supportsVertexTextures
?
'
#define USE_DISPLACEMENTMAP
'
:
''
,
parameters
.
specularMap
?
'
#define USE_SPECULARMAP
'
:
''
,
...
...
@@ -509,6 +511,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
parameters
.
bumpMap
?
'
#define USE_BUMPMAP
'
:
''
,
parameters
.
normalMap
?
'
#define USE_NORMALMAP
'
:
''
,
(
parameters
.
normalMap
&&
parameters
.
objectSpaceNormalMap
)
?
'
#define OBJECTSPACE_NORMALMAP
'
:
''
,
(
parameters
.
normalMap
&&
parameters
.
tangentSpaceNormalMap
)
?
'
#define TANGENTSPACE_NORMALMAP
'
:
''
,
parameters
.
clearcoatNormalMap
?
'
#define USE_CLEARCOAT_NORMALMAP
'
:
''
,
parameters
.
specularMap
?
'
#define USE_SPECULARMAP
'
:
''
,
parameters
.
roughnessMap
?
'
#define USE_ROUGHNESSMAP
'
:
''
,
...
...
src/renderers/webgl/WebGLPrograms.js
浏览文件 @
84f9c514
...
...
@@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/
import
{
BackSide
,
DoubleSide
,
CubeUVRefractionMapping
,
CubeUVReflectionMapping
,
GammaEncoding
,
LinearEncoding
,
ObjectSpaceNormalMap
}
from
'
../../constants.js
'
;
import
{
BackSide
,
DoubleSide
,
CubeUVRefractionMapping
,
CubeUVReflectionMapping
,
GammaEncoding
,
LinearEncoding
,
ObjectSpaceNormalMap
,
TangentSpaceNormalMap
}
from
'
../../constants.js
'
;
import
{
WebGLProgram
}
from
'
./WebGLProgram.js
'
;
function
WebGLPrograms
(
renderer
,
extensions
,
capabilities
)
{
...
...
@@ -29,7 +29,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
var
parameterNames
=
[
"
precision
"
,
"
supportsVertexTextures
"
,
"
map
"
,
"
mapEncoding
"
,
"
matcap
"
,
"
matcapEncoding
"
,
"
envMap
"
,
"
envMapMode
"
,
"
envMapEncoding
"
,
"
lightMap
"
,
"
aoMap
"
,
"
emissiveMap
"
,
"
emissiveMapEncoding
"
,
"
bumpMap
"
,
"
normalMap
"
,
"
objectSpaceNormalMap
"
,
"
clearcoatNormalMap
"
,
"
displacementMap
"
,
"
specularMap
"
,
"
lightMap
"
,
"
aoMap
"
,
"
emissiveMap
"
,
"
emissiveMapEncoding
"
,
"
bumpMap
"
,
"
normalMap
"
,
"
objectSpaceNormalMap
"
,
"
tangentSpaceNormalMap
"
,
"
clearcoatNormalMap
"
,
"
displacementMap
"
,
"
specularMap
"
,
"
roughnessMap
"
,
"
metalnessMap
"
,
"
gradientMap
"
,
"
alphaMap
"
,
"
combine
"
,
"
vertexColors
"
,
"
vertexTangents
"
,
"
fog
"
,
"
useFog
"
,
"
fogExp2
"
,
"
flatShading
"
,
"
sizeAttenuation
"
,
"
logarithmicDepthBuffer
"
,
"
skinning
"
,
...
...
@@ -154,6 +154,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) {
bumpMap
:
!!
material
.
bumpMap
,
normalMap
:
!!
material
.
normalMap
,
objectSpaceNormalMap
:
material
.
normalMapType
===
ObjectSpaceNormalMap
,
tangentSpaceNormalMap
:
material
.
normalMapType
===
TangentSpaceNormalMap
,
clearcoatNormalMap
:
!!
material
.
clearcoatNormalMap
,
displacementMap
:
!!
material
.
displacementMap
,
roughnessMap
:
!!
material
.
roughnessMap
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录