Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
592dd91b
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,发现更多精彩内容 >>
提交
592dd91b
编写于
1月 31, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
cb30dcc2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
4 deletion
+4
-4
build/three.js
build/three.js
+2
-2
build/three.min.js
build/three.min.js
+2
-2
未找到文件。
build/three.js
浏览文件 @
592dd91b
...
...
@@ -23409,7 +23409,7 @@ THREE.ShaderChunk[ 'color_vertex' ] = "#ifdef USE_COLOR\n vColor.xyz = color.xyz
// File:src/renderers/shaders/ShaderChunk/common.glsl
THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n
bool shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float angleCos;\n float exponent;\n bool shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n bool
shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n #ifdef GAMMA_INPUT\n return pow( a, vec3( float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\nvec3 linearToOutput( in vec3 a ) {\n #ifdef GAMMA_OUTPUT\n return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\n";
THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n
int shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float angleCos;\n float exponent;\n int shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int
shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n #ifdef GAMMA_INPUT\n return pow( a, vec3( float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\nvec3 linearToOutput( in vec3 a ) {\n #ifdef GAMMA_OUTPUT\n return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\n";
// File:src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl
...
...
@@ -23497,7 +23497,7 @@ THREE.ShaderChunk[ 'lights_standard_pars_fragment' ] = "struct StandardMaterial
// File:src/renderers/shaders/ShaderChunk/lights_template.glsl
THREE.ShaderChunk[ 'lights_template' ] = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n directLight = getPointDirectLight( pointLight, geometry );\n #ifdef USE_SHADOWMAP\n if (
pointLight.shadowEnabled ) directLight.color *= getPointShadow( pointLightsShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n directLight = getSpotDirectLight( spotLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( spotLight.shadowEnabled ) directLight.color *= getShadow( spotLightsShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n directLight = getDirectionalDirectLight( directionalLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( directionalLight.shadowEnabled
) directLight.color *= getShadow( directionalLightsShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n";
THREE.ShaderChunk[ 'lights_template' ] = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n directLight = getPointDirectLight( pointLight, geometry );\n #ifdef USE_SHADOWMAP\n if (
bool( pointLight.shadowEnabled ) ) directLight.color *= getPointShadow( pointLightsShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n directLight = getSpotDirectLight( spotLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( bool( spotLight.shadowEnabled ) ) directLight.color *= getShadow( spotLightsShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n directLight = getDirectionalDirectLight( directionalLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( bool( directionalLight.shadowEnabled )
) directLight.color *= getShadow( directionalLightsShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n";
// File:src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl
...
...
build/three.min.js
浏览文件 @
592dd91b
...
...
@@ -519,7 +519,7 @@ THREE.FogExp2=function(a,b){this.name="";this.color=new THREE.Color(a);this.dens
THREE
.
ShaderChunk
.
ambient_pars
=
"
uniform vec3 ambientLightColor;
\n
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
\n\t
return PI * ambientLightColor;
\n
}
\n
"
;
THREE
.
ShaderChunk
.
aomap_fragment
=
"
#ifdef USE_AOMAP
\n\t
reflectedLight.indirectDiffuse *= ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
aomap_pars_fragment
=
"
#ifdef USE_AOMAP
\n\t
uniform sampler2D aoMap;
\n\t
uniform float aoMapIntensity;
\n
#endif
"
;
THREE
.
ShaderChunk
.
begin_vertex
=
"
\n
vec3 transformed = vec3( position );
\n
"
;
THREE
.
ShaderChunk
.
beginnormal_vertex
=
"
\n
vec3 objectNormal = vec3( normal );
\n
"
;
THREE
.
ShaderChunk
.
bsdfs
=
"
float calcLightAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
\n\t
if ( decayExponent > 0.0 ) {
\n\t
return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
\n\t
}
\n\t
return 1.0;
\n
}
\n
vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
\n\t
return RECIPROCAL_PI * diffuseColor;
\n
}
\n
vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
\n\t
float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
\n\t
return ( 1.0 - specularColor ) * fresnel + specularColor;
\n
}
\n
float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
\n\t
float a2 = alpha * alpha;
\n\t
float gl = dotNL + pow( a2 + ( 1.0 - a2 ) * dotNL * dotNL, 0.5 );
\n\t
float gv = dotNV + pow( a2 + ( 1.0 - a2 ) * dotNV * dotNV, 0.5 );
\n\t
return 1.0 / ( gl * gv );
\n
}
\n
float D_GGX( const in float alpha, const in float dotNH ) {
\n\t
float a2 = alpha * alpha;
\n\t
float denom = dotNH * dotNH * ( a2 - 1.0 ) + 1.0;
\n\t
return RECIPROCAL_PI * a2 / ( denom * denom );
\n
}
\n
vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {
\n\t
float alpha = roughness * roughness;
\n\t
vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
\n\t
float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );
\n\t
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
\n\t
float dotNH = saturate( dot( geometry.normal, halfDir ) );
\n\t
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
\n\t
vec3 F = F_Schlick( specularColor, dotLH );
\n\t
float G = G_GGX_Smith( alpha, dotNL, dotNV );
\n\t
float D = D_GGX( alpha, dotNH );
\n\t
return F * ( G * D );
\n
}
\n
vec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {
\n\t
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
\n\t
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
\n\t
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
\n\t
vec4 r = roughness * c0 + c1;
\n\t
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
\n\t
vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;
\n\t
return specularColor * AB.x + AB.y;
\n
}
\n
float G_BlinnPhong_Implicit( ) {
\n\t
return 0.25;
\n
}
\n
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
\n\t
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
\n
}
\n
vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
\n\t
vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
\n\t
float dotNH = saturate( dot( geometry.normal, halfDir ) );
\n\t
float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
\n\t
vec3 F = F_Schlick( specularColor, dotLH );
\n\t
float G = G_BlinnPhong_Implicit( );
\n\t
float D = D_BlinnPhong( shininess, dotNH );
\n\t
return F * ( G * D );
\n
}
\n
float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
\n\t
return ( 2.0 / square( ggxRoughness + 0.0001 ) - 2.0 );
\n
}
"
;
THREE
.
ShaderChunk
.
bumpmap_pars_fragment
=
"
#ifdef USE_BUMPMAP
\n\t
uniform sampler2D bumpMap;
\n\t
uniform float bumpScale;
\n\t
vec2 dHdxy_fwd() {
\n\t\t
vec2 dSTdx = dFdx( vUv );
\n\t\t
vec2 dSTdy = dFdy( vUv );
\n\t\t
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
\n\t\t
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
\n\t\t
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
\n\t\t
return vec2( dBx, dBy );
\n\t
}
\n\t
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
\n\t\t
vec3 vSigmaX = dFdx( surf_pos );
\n\t\t
vec3 vSigmaY = dFdy( surf_pos );
\n\t\t
vec3 vN = surf_norm;
\n\t\t
vec3 R1 = cross( vSigmaY, vN );
\n\t\t
vec3 R2 = cross( vN, vSigmaX );
\n\t\t
float fDet = dot( vSigmaX, R1 );
\n\t\t
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
\n\t\t
return normalize( abs( fDet ) * surf_norm - vGrad );
\n\t
}
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
color_fragment
=
"
#ifdef USE_COLOR
\n\t
diffuseColor.rgb *= vColor;
\n
#endif
"
;
THREE
.
ShaderChunk
.
color_pars_fragment
=
"
#ifdef USE_COLOR
\n\t
varying vec3 vColor;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
color_pars_vertex
=
"
#ifdef USE_COLOR
\n\t
varying vec3 vColor;
\n
#endif
"
;
THREE
.
ShaderChunk
.
color_vertex
=
"
#ifdef USE_COLOR
\n\t
vColor.xyz = color.xyz;
\n
#endif
"
;
THREE
.
ShaderChunk
.
common
=
"
#define PI 3.14159
\n
#define PI2 6.28318
\n
#define RECIPROCAL_PI 0.31830988618
\n
#define RECIPROCAL_PI2 0.15915494
\n
#define LOG2 1.442695
\n
#define EPSILON 1e-6
\n
#define saturate(a) clamp( a, 0.0, 1.0 )
\n
#define whiteCompliment(a) ( 1.0 - saturate( a ) )
\n
float square( const in float x ) { return x*x; }
\n
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
\n
struct IncidentLight {
\n\t
vec3 color;
\n\t
vec3 direction;
\n
};
\n
struct ReflectedLight {
\n\t
vec3 directDiffuse;
\n\t
vec3 directSpecular;
\n\t
vec3 indirectDiffuse;
\n\t
vec3 indirectSpecular;
\n
};
\n
struct GeometricContext {
\n\t
vec3 position;
\n\t
vec3 normal;
\n\t
vec3 viewDir;
\n
};
\n
#if NUM_DIR_LIGHTS > 0
\n\t
struct DirectionalLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
bool shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
\n
#endif
\n
#if NUM_SPOT_LIGHTS > 0
\n\t
struct SpotLight {
\n\t\t
vec3 position;
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
float distance;
\n\t\t
float decay;
\n\t\t
float angleCos;
\n\t\t
float exponent;
\n\t\t
bool shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
\n
#endif
\n
#if NUM_POINT_LIGHTS > 0
\n\t
struct PointLight {
\n\t\t
vec3 position;
\n\t\t
vec3 color;
\n\t\t
float distance;
\n\t\t
float decay;
\n\t\t
bool
shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
\n
#endif
\n
#if NUM_HEMI_LIGHTS > 0
\n\t
struct HemisphereLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 skyColor;
\n\t\t
vec3 groundColor;
\n\t
};
\n\t
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
\n
#endif
\n
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
\n\t
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
\n
}
\n
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
\n\t
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
\n
}
\n
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
float distance = dot( planeNormal, point - pointOnPlane );
\n\t
return - distance * planeNormal + point;
\n
}
\n
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
return sign( dot( point - pointOnPlane, planeNormal ) );
\n
}
\n
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
\n
}
\n
vec3 inputToLinear( in vec3 a ) {
\n\t
#ifdef GAMMA_INPUT
\n\t\t
return pow( a, vec3( float( GAMMA_FACTOR ) ) );
\n\t
#else
\n\t\t
return a;
\n\t
#endif
\n
}
\n
vec3 linearToOutput( in vec3 a ) {
\n\t
#ifdef GAMMA_OUTPUT
\n\t\t
return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );
\n\t
#else
\n\t\t
return a;
\n\t
#endif
\n
}
\n
"
;
THREE
.
ShaderChunk
.
color_fragment
=
"
#ifdef USE_COLOR
\n\t
diffuseColor.rgb *= vColor;
\n
#endif
"
;
THREE
.
ShaderChunk
.
color_pars_fragment
=
"
#ifdef USE_COLOR
\n\t
varying vec3 vColor;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
color_pars_vertex
=
"
#ifdef USE_COLOR
\n\t
varying vec3 vColor;
\n
#endif
"
;
THREE
.
ShaderChunk
.
color_vertex
=
"
#ifdef USE_COLOR
\n\t
vColor.xyz = color.xyz;
\n
#endif
"
;
THREE
.
ShaderChunk
.
common
=
"
#define PI 3.14159
\n
#define PI2 6.28318
\n
#define RECIPROCAL_PI 0.31830988618
\n
#define RECIPROCAL_PI2 0.15915494
\n
#define LOG2 1.442695
\n
#define EPSILON 1e-6
\n
#define saturate(a) clamp( a, 0.0, 1.0 )
\n
#define whiteCompliment(a) ( 1.0 - saturate( a ) )
\n
float square( const in float x ) { return x*x; }
\n
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
\n
struct IncidentLight {
\n\t
vec3 color;
\n\t
vec3 direction;
\n
};
\n
struct ReflectedLight {
\n\t
vec3 directDiffuse;
\n\t
vec3 directSpecular;
\n\t
vec3 indirectDiffuse;
\n\t
vec3 indirectSpecular;
\n
};
\n
struct GeometricContext {
\n\t
vec3 position;
\n\t
vec3 normal;
\n\t
vec3 viewDir;
\n
};
\n
#if NUM_DIR_LIGHTS > 0
\n\t
struct DirectionalLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
int shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
\n
#endif
\n
#if NUM_SPOT_LIGHTS > 0
\n\t
struct SpotLight {
\n\t\t
vec3 position;
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
float distance;
\n\t\t
float decay;
\n\t\t
float angleCos;
\n\t\t
float exponent;
\n\t\t
int shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
\n
#endif
\n
#if NUM_POINT_LIGHTS > 0
\n\t
struct PointLight {
\n\t\t
vec3 position;
\n\t\t
vec3 color;
\n\t\t
float distance;
\n\t\t
float decay;
\n\t\t
int
shadowEnabled;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t\t
mat4 shadowMatrix;
\n\t
};
\n\t
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
\n
#endif
\n
#if NUM_HEMI_LIGHTS > 0
\n\t
struct HemisphereLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 skyColor;
\n\t\t
vec3 groundColor;
\n\t
};
\n\t
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
\n
#endif
\n
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
\n\t
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
\n
}
\n
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
\n\t
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
\n
}
\n
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
float distance = dot( planeNormal, point - pointOnPlane );
\n\t
return - distance * planeNormal + point;
\n
}
\n
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
return sign( dot( point - pointOnPlane, planeNormal ) );
\n
}
\n
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
\n\t
return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
\n
}
\n
vec3 inputToLinear( in vec3 a ) {
\n\t
#ifdef GAMMA_INPUT
\n\t\t
return pow( a, vec3( float( GAMMA_FACTOR ) ) );
\n\t
#else
\n\t\t
return a;
\n\t
#endif
\n
}
\n
vec3 linearToOutput( in vec3 a ) {
\n\t
#ifdef GAMMA_OUTPUT
\n\t\t
return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );
\n\t
#else
\n\t\t
return a;
\n\t
#endif
\n
}
\n
"
;
THREE
.
ShaderChunk
.
defaultnormal_vertex
=
"
#ifdef FLIP_SIDED
\n\t
objectNormal = -objectNormal;
\n
#endif
\n
vec3 transformedNormal = normalMatrix * objectNormal;
\n
"
;
THREE
.
ShaderChunk
.
displacementmap_vertex
=
"
#ifdef USE_DISPLACEMENTMAP
\n\t
transformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
displacementmap_pars_vertex
=
"
#ifdef USE_DISPLACEMENTMAP
\n\t
uniform sampler2D displacementMap;
\n\t
uniform float displacementScale;
\n\t
uniform float displacementBias;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
emissivemap_fragment
=
"
#ifdef USE_EMISSIVEMAP
\n\t
vec4 emissiveColor = texture2D( emissiveMap, vUv );
\n\t
emissiveColor.rgb = inputToLinear( emissiveColor.rgb );
\n\t
totalEmissiveLight *= emissiveColor.rgb;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
emissivemap_pars_fragment
=
"
#ifdef USE_EMISSIVEMAP
\n\t
uniform sampler2D emissiveMap;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
envmap_fragment
=
"
#ifdef USE_ENVMAP
\n\t
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
\n\t\t
vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
\n\t\t
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
\n\t\t
#ifdef ENVMAP_MODE_REFLECTION
\n\t\t\t
vec3 reflectVec = reflect( cameraToVertex, worldNormal );
\n\t\t
#else
\n\t\t\t
vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );
\n\t\t
#endif
\n\t
#else
\n\t\t
vec3 reflectVec = vReflect;
\n\t
#endif
\n\t
#ifdef DOUBLE_SIDED
\n\t\t
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
\n\t
#else
\n\t\t
float flipNormal = 1.0;
\n\t
#endif
\n\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t
vec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
\n\t
#elif defined( ENVMAP_TYPE_EQUIREC )
\n\t\t
vec2 sampleUV;
\n\t\t
sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );
\n\t\t
sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
\n\t\t
vec4 envColor = texture2D( envMap, sampleUV );
\n\t
#elif defined( ENVMAP_TYPE_SPHERE )
\n\t\t
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
\n\t\t
vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );
\n\t
#endif
\n\t
envColor.xyz = inputToLinear( envColor.xyz );
\n\t
#ifdef ENVMAP_BLENDING_MULTIPLY
\n\t\t
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
\n\t
#elif defined( ENVMAP_BLENDING_MIX )
\n\t\t
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
\n\t
#elif defined( ENVMAP_BLENDING_ADD )
\n\t\t
outgoingLight += envColor.xyz * specularStrength * reflectivity;
\n\t
#endif
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
envmap_pars_fragment
=
"
#if defined( USE_ENVMAP ) || defined( STANDARD )
\n\t
uniform float reflectivity;
\n\t
uniform float envMapIntenstiy;
\n
#endif
\n
#ifdef USE_ENVMAP
\n\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t
uniform samplerCube envMap;
\n\t
#else
\n\t\t
uniform sampler2D envMap;
\n\t
#endif
\n\t
uniform float flipEnvMap;
\n\t
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( STANDARD )
\n\t\t
uniform float refractionRatio;
\n\t
#else
\n\t\t
varying vec3 vReflect;
\n\t
#endif
\n
#endif
\n
"
;
...
...
@@ -531,7 +531,7 @@ THREE.ShaderChunk.lights_pars="#if NUM_DIR_LIGHTS > 0\n\tIncidentLight getDirect
THREE
.
ShaderChunk
.
lights_phong_fragment
=
"
BlinnPhongMaterial material;
\n
material.diffuseColor = diffuseColor.rgb;
\n
material.specularColor = specular;
\n
material.specularShininess = shininess;
\n
material.specularStrength = specularStrength;
\n
"
;
THREE
.
ShaderChunk
.
lights_phong_pars_fragment
=
"
#ifdef USE_ENVMAP
\n\t
varying vec3 vWorldPosition;
\n
#endif
\n
varying vec3 vViewPosition;
\n
#ifndef FLAT_SHADED
\n\t
varying vec3 vNormal;
\n
#endif
\n
struct BlinnPhongMaterial {
\n\t
vec3
\t
diffuseColor;
\n\t
vec3
\t
specularColor;
\n\t
float
\t
specularShininess;
\n\t
float
\t
specularStrength;
\n
};
\n
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
\n\t
vec3 irradiance = dotNL * PI * directLight.color;
\n\t
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n\t
reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;
\n
}
\n
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n
}
\n
#define RE_Direct
\t\t\t\t
RE_Direct_BlinnPhong
\n
#define RE_IndirectDiffuse
\t\t
RE_IndirectDiffuse_BlinnPhong
\n
#define Material_LightProbeLOD( material )
\t
(0)
\n
"
;
THREE
.
ShaderChunk
.
lights_phong_pars_vertex
=
"
#ifdef USE_ENVMAP
\n\t
varying vec3 vWorldPosition;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lights_phong_vertex
=
"
#ifdef USE_ENVMAP
\n\t
vWorldPosition = worldPosition.xyz;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lights_standard_fragment
=
"
StandardMaterial material;
\n
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
\n
material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
\n
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
\n
"
;
THREE
.
ShaderChunk
.
lights_standard_pars_fragment
=
"
struct StandardMaterial {
\n\t
vec3
\t
diffuseColor;
\n\t
float
\t
specularRoughness;
\n\t
vec3
\t
specularColor;
\n
};
\n
void RE_Direct_Standard( const in IncidentLight directLight, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
\n\t
vec3 irradiance = dotNL * PI * directLight.color;
\n\t
reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n\t
reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );
\n
}
\n
void RE_IndirectDiffuse_Standard( const in vec3 irradiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n
}
\n
void RE_IndirectSpecular_Standard( const in vec3 radiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
reflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );
\n
}
\n
#define RE_Direct
\t\t\t\t
RE_Direct_Standard
\n
#define RE_IndirectDiffuse
\t\t
RE_IndirectDiffuse_Standard
\n
#define RE_IndirectSpecular
\t\t
RE_IndirectSpecular_Standard
\n
#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )
\n
"
;
THREE
.
ShaderChunk
.
lights_template
=
"
\n
GeometricContext geometry;
\n
geometry.position = - vViewPosition;
\n
geometry.normal = normal;
\n
geometry.viewDir = normalize( vViewPosition );
\n
IncidentLight directLight;
\n
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
PointLight pointLight;
\n\t
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
\n\t\t
pointLight = pointLights[ i ];
\n\t\t
directLight = getPointDirectLight( pointLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if (
pointLight.shadowEnabled ) directLight.color *= getPointShadow( pointLightsShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
SpotLight spotLight;
\n\t
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
\n\t\t
spotLight = spotLights[ i ];
\n\t\t
directLight = getSpotDirectLight( spotLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if ( spotLight.shadowEnabled ) directLight.color *= getShadow( spotLightsShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
DirectionalLight directionalLight;
\n\t
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
\n\t\t
directionalLight = directionalLights[ i ];
\n\t\t
directLight = getDirectionalDirectLight( directionalLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if ( directionalLight.shadowEnabled
) directLight.color *= getShadow( directionalLightsShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if defined( RE_IndirectDiffuse )
\n\t
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
\n\t
#ifdef USE_LIGHTMAP
\n\t\t
irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n\t
#endif
\n\t
#if ( NUM_HEMI_LIGHTS > 0 )
\n\t\t
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
\n\t\t\t
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
\n\t\t
}
\n\t
#endif
\n\t
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
\n
#endif
\n
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
\n\t
vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );
\n\t
RE_IndirectSpecular( radiance, geometry, material, reflectedLight );
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lights_template
=
"
\n
GeometricContext geometry;
\n
geometry.position = - vViewPosition;
\n
geometry.normal = normal;
\n
geometry.viewDir = normalize( vViewPosition );
\n
IncidentLight directLight;
\n
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
PointLight pointLight;
\n\t
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
\n\t\t
pointLight = pointLights[ i ];
\n\t\t
directLight = getPointDirectLight( pointLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if (
bool( pointLight.shadowEnabled ) ) directLight.color *= getPointShadow( pointLightsShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
SpotLight spotLight;
\n\t
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
\n\t\t
spotLight = spotLights[ i ];
\n\t\t
directLight = getSpotDirectLight( spotLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if ( bool( spotLight.shadowEnabled ) ) directLight.color *= getShadow( spotLightsShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
\n\t
DirectionalLight directionalLight;
\n\t
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
\n\t\t
directionalLight = directionalLights[ i ];
\n\t\t
directLight = getDirectionalDirectLight( directionalLight, geometry );
\n\t\t
#ifdef USE_SHADOWMAP
\n\t\t
if ( bool( directionalLight.shadowEnabled )
) directLight.color *= getShadow( directionalLightsShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] );
\n\t\t
#endif
\n\t\t
RE_Direct( directLight, geometry, material, reflectedLight );
\n\t
}
\n
#endif
\n
#if defined( RE_IndirectDiffuse )
\n\t
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
\n\t
#ifdef USE_LIGHTMAP
\n\t\t
irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n\t
#endif
\n\t
#if ( NUM_HEMI_LIGHTS > 0 )
\n\t\t
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
\n\t\t\t
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
\n\t\t
}
\n\t
#endif
\n\t
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
\n
#endif
\n
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
\n\t
vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );
\n\t
RE_IndirectSpecular( radiance, geometry, material, reflectedLight );
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
linear_to_gamma_fragment
=
"
\n\t
outgoingLight = linearToOutput( outgoingLight );
\n
"
;
THREE
.
ShaderChunk
.
logdepthbuf_fragment
=
"
#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)
\n\t
gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;
\n
#endif
"
;
THREE
.
ShaderChunk
.
logdepthbuf_pars_fragment
=
"
#ifdef USE_LOGDEPTHBUF
\n\t
uniform float logDepthBufFC;
\n\t
#ifdef USE_LOGDEPTHBUF_EXT
\n\t\t
varying float vFragDepth;
\n\t
#endif
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
logdepthbuf_pars_vertex
=
"
#ifdef USE_LOGDEPTHBUF
\n\t
#ifdef USE_LOGDEPTHBUF_EXT
\n\t\t
varying float vFragDepth;
\n\t
#endif
\n\t
uniform float logDepthBufFC;
\n
#endif
"
;
THREE
.
ShaderChunk
.
logdepthbuf_vertex
=
"
#ifdef USE_LOGDEPTHBUF
\n\t
gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;
\n\t
#ifdef USE_LOGDEPTHBUF_EXT
\n\t\t
vFragDepth = 1.0 + gl_Position.w;
\n\t
#else
\n\t\t
gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;
\n\t
#endif
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
map_fragment
=
"
#ifdef USE_MAP
\n\t
vec4 texelColor = texture2D( map, vUv );
\n\t
texelColor.xyz = inputToLinear( texelColor.xyz );
\n\t
diffuseColor *= texelColor;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
map_pars_fragment
=
"
#ifdef USE_MAP
\n\t
uniform sampler2D map;
\n
#endif
"
;
THREE
.
ShaderChunk
.
map_particle_fragment
=
"
#ifdef USE_MAP
\n\t
diffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
map_particle_pars_fragment
=
"
#ifdef USE_MAP
\n\t
uniform vec4 offsetRepeat;
\n\t
uniform sampler2D map;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
metalnessmap_fragment
=
"
float metalnessFactor = metalness;
\n
#ifdef USE_METALNESSMAP
\n\t
vec4 texelMetalness = texture2D( metalnessMap, vUv );
\n\t
metalnessFactor *= texelMetalness.r;
\n
#endif
\n
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录