Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9e757a3e
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 搜索 >>
提交
9e757a3e
编写于
2月 10, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
cdfdd5a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
6 deletion
+6
-6
build/three.js
build/three.js
+3
-3
build/three.min.js
build/three.min.js
+3
-3
未找到文件。
build/three.js
浏览文件 @
9e757a3e
...
...
@@ -23411,7 +23411,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};\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
bool visible;\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};\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
...
...
@@ -23471,7 +23471,7 @@ THREE.ShaderChunk[ 'lights_lambert_vertex' ] = "vec3 diffuse = vec3( 1.0 );\nGeo
// File:src/renderers/shaders/ShaderChunk/lights_pars.glsl
THREE.ShaderChunk[ 'lights_pars' ] = "#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n IncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n
return directLight;\n }\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 shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n IncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n directLight.color = pointLight.color;\n directLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n } else {\n directLight.color = vec3( 0.0 );\n }\n return directLight;\n }\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 penumbra;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n IncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float spotEffect = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = dot( spotLight.direction, directLight.direction );\n spotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );\n directLight.color = spotLight.color;\n directLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );\n } else {\n directLight.color = vec3( 0.0 )
;\n }\n return directLight;\n }\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 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n return PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n }\n#endif\n#if defined( USE_ENVMAP ) && defined( STANDARD )\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n #else\n vec3 envMapColor = vec3( 0.0 );\n #endif\n envMapColor.rgb = inputToLinear( envMapColor.rgb );\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n #else\n vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n #endif\n envMapColor.rgb = inputToLinear( envMapColor.rgb );\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n";
THREE.ShaderChunk[ 'lights_pars' ] = "#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n IncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n
directLight.visible = true;\n return directLight;\n }\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 shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n IncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n directLight.color = pointLight.color;\n directLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n return directLight;\n }\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 penumbra;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n IncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float spotEffect = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = dot( spotLight.direction, directLight.direction );\n spotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );\n directLight.color = spotLight.color;\n directLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false
;\n }\n return directLight;\n }\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 vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n return PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n }\n#endif\n#if defined( USE_ENVMAP ) && defined( STANDARD )\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n #else\n vec3 envMapColor = vec3( 0.0 );\n #endif\n envMapColor.rgb = inputToLinear( envMapColor.rgb );\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n #else\n vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n #endif\n envMapColor.rgb = inputToLinear( envMapColor.rgb );\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n";
// File:src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
...
...
@@ -23499,7 +23499,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 directLight.color *= all( bvec2( pointLight.shadow,
length( directLight.color ) > 0.0 ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\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 directLight.color *= all( bvec2( spotLight.shadow, length( directLight.color ) > 0.0 ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\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 directLight.color *= all( bvec2( directionalLight.shadow, length( directLight.color ) > 0.0
) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\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 directLight.color *= all( bvec2( pointLight.shadow,
directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\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 directLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\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 directLight.color *= all( bvec2( directionalLight.shadow, directLight.visible
) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\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
浏览文件 @
9e757a3e
...
...
@@ -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
=
"
bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {
\n\t
return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );
\n
}
\n
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
}
\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
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
\t
bool visible;
\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
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
"
;
...
...
@@ -527,11 +527,11 @@ THREE.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( US
THREE
.
ShaderChunk
.
fog_fragment
=
"
#ifdef USE_FOG
\n\t
#ifdef USE_LOGDEPTHBUF_EXT
\n\t\t
float depth = gl_FragDepthEXT / gl_FragCoord.w;
\n\t
#else
\n\t\t
float depth = gl_FragCoord.z / gl_FragCoord.w;
\n\t
#endif
\n\t
#ifdef FOG_EXP2
\n\t\t
float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );
\n\t
#else
\n\t\t
float fogFactor = smoothstep( fogNear, fogFar, depth );
\n\t
#endif
\n\t\n\t
outgoingLight = mix( outgoingLight, fogColor, fogFactor );
\n
#endif
"
;
THREE
.
ShaderChunk
.
fog_pars_fragment
=
"
#ifdef USE_FOG
\n\t
uniform vec3 fogColor;
\n\t
#ifdef FOG_EXP2
\n\t\t
uniform float fogDensity;
\n\t
#else
\n\t\t
uniform float fogNear;
\n\t\t
uniform float fogFar;
\n\t
#endif
\n
#endif
"
;
THREE
.
ShaderChunk
.
lightmap_fragment
=
"
#ifdef USE_LIGHTMAP
\n\t
reflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lightmap_pars_fragment
=
"
#ifdef USE_LIGHTMAP
\n\t
uniform sampler2D lightMap;
\n\t
uniform float lightMapIntensity;
\n
#endif
"
;
THREE
.
ShaderChunk
.
lights_lambert_vertex
=
"
vec3 diffuse = vec3( 1.0 );
\n
GeometricContext geometry;
\n
geometry.position = mvPosition.xyz;
\n
geometry.normal = normalize( transformedNormal );
\n
geometry.viewDir = normalize( -mvPosition.xyz );
\n
GeometricContext backGeometry;
\n
backGeometry.position = geometry.position;
\n
backGeometry.normal = -geometry.normal;
\n
backGeometry.viewDir = geometry.viewDir;
\n
vLightFront = vec3( 0.0 );
\n
#ifdef DOUBLE_SIDED
\n\t
vLightBack = vec3( 0.0 );
\n
#endif
\n
IncidentLight directLight;
\n
float dotNL;
\n
vec3 directLightColor_Diffuse;
\n
#if NUM_POINT_LIGHTS > 0
\n\t
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
\n\t\t
directLight = getPointDirectLight( pointLights[ i ], geometry );
\n\t\t
dotNL = dot( geometry.normal, directLight.direction );
\n\t\t
directLightColor_Diffuse = PI * directLight.color;
\n\t\t
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
\n\t\t
#endif
\n\t
}
\n
#endif
\n
#if NUM_SPOT_LIGHTS > 0
\n\t
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
\n\t\t
directLight = getSpotDirectLight( spotLights[ i ], geometry );
\n\t\t
dotNL = dot( geometry.normal, directLight.direction );
\n\t\t
directLightColor_Diffuse = PI * directLight.color;
\n\t\t
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
\n\t\t
#endif
\n\t
}
\n
#endif
\n
#if NUM_DIR_LIGHTS > 0
\n\t
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
\n\t\t
directLight = getDirectionalDirectLight( directionalLights[ i ], geometry );
\n\t\t
dotNL = dot( geometry.normal, directLight.direction );
\n\t\t
directLightColor_Diffuse = PI * directLight.color;
\n\t\t
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
\n\t\t
#endif
\n\t
}
\n
#endif
\n
#if NUM_HEMI_LIGHTS > 0
\n\t
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
\n\t\t
vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
\n\t\t
#endif
\n\t
}
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lights_pars
=
"
#if NUM_DIR_LIGHTS > 0
\n\t
struct DirectionalLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
int shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
\n\t
IncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
directLight.color = directionalLight.color;
\n\t\t
directLight.direction = directionalLight.direction;
\n\t\t
return directLight;
\n\t
}
\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 shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
\n\t
IncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
vec3 lVector = pointLight.position - geometry.position;
\n\t\t
directLight.direction = normalize( lVector );
\n\t\t
float lightDistance = length( lVector );
\n\t\t
if ( testLightInRange( lightDistance, pointLight.distance ) ) {
\n\t\t\t
directLight.color = pointLight.color;
\n\t\t\t
directLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );
\n\t\t
} else {
\n\t\t\t
directLight.color = vec3( 0.0 );
\n\t\t
}
\n\t\t
return directLight;
\n\t
}
\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 penumbra;
\n\t\t
int shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
\n\t
IncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
vec3 lVector = spotLight.position - geometry.position;
\n\t\t
directLight.direction = normalize( lVector );
\n\t\t
float lightDistance = length( lVector );
\n\t\t
float spotEffect = dot( directLight.direction, spotLight.direction );
\n\t\t
if ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
\n\t\t\t
float spotEffect = dot( spotLight.direction, directLight.direction );
\n\t\t\t
spotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );
\n\t\t\t
directLight.color = spotLight.color;
\n\t\t\t
directLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );
\n\t\t
} else {
\n\t\t\t
directLight.color = vec3( 0.0 )
;
\n\t\t
}
\n\t\t
return directLight;
\n\t
}
\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\t
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
\n\t\t
float dotNL = dot( geometry.normal, hemiLight.direction );
\n\t\t
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
\n\t\t
return PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
\n\t
}
\n
#endif
\n
#if defined( USE_ENVMAP ) && defined( STANDARD )
\n\t
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
\n\t\t
#else
\n\t\t\t
float flipNormal = 1.0;
\n\t\t
#endif
\n\t\t
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
\n\t\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t\t
vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
\n\t\t\t
#endif
\n\t\t
#else
\n\t\t\t
vec3 envMapColor = vec3( 0.0 );
\n\t\t
#endif
\n\t\t
envMapColor.rgb = inputToLinear( envMapColor.rgb );
\n\t\t
return PI * envMapColor.rgb * envMapIntensity;
\n\t
}
\n\t
float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {
\n\t\t
float maxMIPLevelScalar = float( maxMIPLevel );
\n\t\t
float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );
\n\t\t
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
\n\t
}
\n\t
vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {
\n\t\t
#ifdef ENVMAP_MODE_REFLECTION
\n\t\t\t
vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );
\n\t\t
#else
\n\t\t\t
vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );
\n\t\t
#endif
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
\n\t\t
#else
\n\t\t\t
float flipNormal = 1.0;
\n\t\t
#endif
\n\t\t
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
\n\t\t
float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );
\n\t\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t\t
vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#elif defined( ENVMAP_TYPE_EQUIREC )
\n\t\t\t
vec2 sampleUV;
\n\t\t\t
sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );
\n\t\t\t
sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#elif defined( ENVMAP_TYPE_SPHERE )
\n\t\t\t
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#endif
\n\t\t
envMapColor.rgb = inputToLinear( envMapColor.rgb );
\n\t\t
return envMapColor.rgb * envMapIntensity;
\n\t
}
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
lights_pars
=
"
#if NUM_DIR_LIGHTS > 0
\n\t
struct DirectionalLight {
\n\t\t
vec3 direction;
\n\t\t
vec3 color;
\n\t\t
int shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
\n\t
IncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
directLight.color = directionalLight.color;
\n\t\t
directLight.direction = directionalLight.direction;
\n\t\t
directLight.visible = true;
\n\t\t
return directLight;
\n\t
}
\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 shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
\n\t
IncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
vec3 lVector = pointLight.position - geometry.position;
\n\t\t
directLight.direction = normalize( lVector );
\n\t\t
float lightDistance = length( lVector );
\n\t\t
if ( testLightInRange( lightDistance, pointLight.distance ) ) {
\n\t\t\t
directLight.color = pointLight.color;
\n\t\t\t
directLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );
\n\t\t\t
directLight.visible = true;
\n\t\t
} else {
\n\t\t\t
directLight.color = vec3( 0.0 );
\n\t\t\t
directLight.visible = false;
\n\t\t
}
\n\t\t
return directLight;
\n\t
}
\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 penumbra;
\n\t\t
int shadow;
\n\t\t
float shadowBias;
\n\t\t
float shadowRadius;
\n\t\t
vec2 shadowMapSize;
\n\t
};
\n\t
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
\n\t
IncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {
\n\t\t
IncidentLight directLight;
\n\t\t
vec3 lVector = spotLight.position - geometry.position;
\n\t\t
directLight.direction = normalize( lVector );
\n\t\t
float lightDistance = length( lVector );
\n\t\t
float spotEffect = dot( directLight.direction, spotLight.direction );
\n\t\t
if ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
\n\t\t\t
float spotEffect = dot( spotLight.direction, directLight.direction );
\n\t\t\t
spotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );
\n\t\t\t
directLight.color = spotLight.color;
\n\t\t\t
directLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );
\n\t\t\t
directLight.visible = true;
\n\t\t
} else {
\n\t\t\t
directLight.color = vec3( 0.0 );
\n\t\t\t
directLight.visible = false
;
\n\t\t
}
\n\t\t
return directLight;
\n\t
}
\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\t
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
\n\t\t
float dotNL = dot( geometry.normal, hemiLight.direction );
\n\t\t
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
\n\t\t
return PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
\n\t
}
\n
#endif
\n
#if defined( USE_ENVMAP ) && defined( STANDARD )
\n\t
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
\n\t\t
#else
\n\t\t\t
float flipNormal = 1.0;
\n\t\t
#endif
\n\t\t
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
\n\t\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t\t
vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );
\n\t\t\t
#endif
\n\t\t
#else
\n\t\t\t
vec3 envMapColor = vec3( 0.0 );
\n\t\t
#endif
\n\t\t
envMapColor.rgb = inputToLinear( envMapColor.rgb );
\n\t\t
return PI * envMapColor.rgb * envMapIntensity;
\n\t
}
\n\t
float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {
\n\t\t
float maxMIPLevelScalar = float( maxMIPLevel );
\n\t\t
float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );
\n\t\t
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
\n\t
}
\n\t
vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {
\n\t\t
#ifdef ENVMAP_MODE_REFLECTION
\n\t\t\t
vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );
\n\t\t
#else
\n\t\t\t
vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );
\n\t\t
#endif
\n\t\t
#ifdef DOUBLE_SIDED
\n\t\t\t
float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );
\n\t\t
#else
\n\t\t\t
float flipNormal = 1.0;
\n\t\t
#endif
\n\t\t
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
\n\t\t
float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );
\n\t\t
#ifdef ENVMAP_TYPE_CUBE
\n\t\t\t
vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#elif defined( ENVMAP_TYPE_EQUIREC )
\n\t\t\t
vec2 sampleUV;
\n\t\t\t
sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );
\n\t\t\t
sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#elif defined( ENVMAP_TYPE_SPHERE )
\n\t\t\t
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
\n\t\t\t
#ifdef TEXTURE_LOD_EXT
\n\t\t\t\t
vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
\n\t\t\t
#else
\n\t\t\t\t
vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );
\n\t\t\t
#endif
\n\t\t
#endif
\n\t\t
envMapColor.rgb = inputToLinear( envMapColor.rgb );
\n\t\t
return envMapColor.rgb * envMapIntensity;
\n\t
}
\n
#endif
\n
"
;
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
directLight.color *= all( bvec2( pointLight.shadow,
length( directLight.color ) > 0.0 ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;
\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
directLight.color *= all( bvec2( spotLight.shadow, length( directLight.color ) > 0.0 ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
\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
directLight.color *= all( bvec2( directionalLight.shadow, length( directLight.color ) > 0.0
) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
\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
directLight.color *= all( bvec2( pointLight.shadow,
directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;
\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
directLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
\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
directLight.color *= all( bvec2( directionalLight.shadow, directLight.visible
) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
\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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录