Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
8eeaeae5
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,发现更多精彩内容 >>
提交
8eeaeae5
编写于
4月 03, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
b1b19ac2
变更
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
浏览文件 @
8eeaeae5
...
...
@@ -23793,11 +23793,11 @@ THREE.ShaderChunk[ 'lightmap_pars_fragment' ] = "#ifdef USE_LIGHTMAP\n uniform s
// File:src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl
THREE.ShaderChunk[ 'lights_lambert_vertex' ] = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n
directLight = getPointDirectLightIrradiance( pointLights[ i ], geometry );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n directLight = getSpotDirectLightIrradiance( spotLights[ i ], geometry );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directLight = getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry
);\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif\n";
THREE.ShaderChunk[ 'lights_lambert_vertex' ] = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n
getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight
);\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif\n";
// File:src/renderers/shaders/ShaderChunk/lights_pars.glsl
THREE.ShaderChunk[ 'lights_pars' ] = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#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 getDirectionalDirectLightIrradiance( 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 getPointDirectLightIrradiance( 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 *= punctualLightIntensityToIrradianceFactor( 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 coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n IncidentLight getSpotDirectLightIrradiance( 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 angleCos = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( 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 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n vec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\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( pow2( 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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n";
THREE.ShaderChunk[ 'lights_pars' ] = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#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
void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\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 void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out 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 *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\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 coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }
\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 vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n vec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\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( pow2( 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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\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 envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n #endif\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n";
// File:src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl
...
...
@@ -23817,7 +23817,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 = getPointDirectLightIrradiance( 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 = getSpotDirectLightIrradiance( 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 = getDirectionalDirectLightIrradiance( 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 vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\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 #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n irradiance += getLightProbeIndirectIrradiance( geometry, 8 );\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
getPointDirectLightIrradiance( pointLight, geometry, directLight );\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 getSpotDirectLightIrradiance( spotLight, geometry, directLight );\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 getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight
);\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 vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\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 #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n irradiance += getLightProbeIndirectIrradiance( geometry, 8 );\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/logdepthbuf_fragment.glsl
...
...
build/three.min.js
浏览文件 @
8eeaeae5
...
...
@@ -536,11 +536,11 @@ THREE.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( ST
THREE
.
ShaderChunk
.
envmap_pars_vertex
=
"
#ifdef USE_ENVMAP
\n\t
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
\n\t\t
varying vec3 vWorldPosition;
\n\t
#else
\n\t\t
varying vec3 vReflect;
\n\t\t
uniform float refractionRatio;
\n\t
#endif
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
envmap_vertex
=
"
#ifdef USE_ENVMAP
\n\t
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
\n\t\t
vWorldPosition = worldPosition.xyz;
\n\t
#else
\n\t\t
vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
\n\t\t
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
\n\t\t
#ifdef ENVMAP_MODE_REFLECTION
\n\t\t\t
vReflect = reflect( cameraToVertex, worldNormal );
\n\t\t
#else
\n\t\t\t
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
\n\t\t
#endif
\n\t
#endif
\n
#endif
\n
"
;
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
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
\n
#endif
\n
"
;
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 = getPointDirectLightIrradiance( 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 = getSpotDirectLightIrradiance( 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 = getDirectionalDirectLightIrradiance( 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
=
"
uniform vec3 ambientLightColor;
\n
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
\n\t
vec3 irradiance = ambientLightColor;
\n\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t
irradiance *= PI;
\n\t
#endif
\n\t
return irradiance;
\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 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 getDirectionalDirectLightIrradiance( 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 getPointDirectLightIrradiance( 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 *= punctualLightIntensityToIrradianceFactor( 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 coneCos;
\n\t\t
float penumbraCos;
\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 getSpotDirectLightIrradiance( 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 angleCos = dot( directLight.direction, spotLight.direction );
\n\t\t
if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
\n\t\t\t
float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
\n\t\t\t
directLight.color = spotLight.color;
\n\t\t\t
directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( 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
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
\n\t\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t\t
irradiance *= PI;
\n\t\t
#endif
\n\t\t
return irradiance;
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#elif defined( ENVMAP_TYPE_CUBE_UV )
\n\t\t\t
vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
\n\t\t\t
vec4 envMapColor = textureCubeUV( queryVec, 1.0 );
\n\t\t
#else
\n\t\t\t
vec4 envMapColor = vec4( 0.0 );
\n\t\t
#endif
\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( pow2( 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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#elif defined( ENVMAP_TYPE_CUBE_UV )
\n\t\t\t
vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
\n\t\t\t
vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#endif
\n\t\t
return envMapColor.rgb * envMapIntensity;
\n\t
}
\n
#endif
\n
"
;
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
getPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );
\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
getSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );
\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
getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight
);
\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
=
"
uniform vec3 ambientLightColor;
\n
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
\n\t
vec3 irradiance = ambientLightColor;
\n\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t
irradiance *= PI;
\n\t
#endif
\n\t
return irradiance;
\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 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
void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
\n\t\t
directLight.color = directionalLight.color;
\n\t\t
directLight.direction = directionalLight.direction;
\n\t\t
directLight.visible = true;
\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
void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out 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 *= punctualLightIntensityToIrradianceFactor( 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
}
\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 coneCos;
\n\t\t
float penumbraCos;
\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
void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out 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 angleCos = dot( directLight.direction, spotLight.direction );
\n\t\t
if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
\n\t\t\t
float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
\n\t\t\t
directLight.color = spotLight.color;
\n\t\t\t
directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( 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
}
\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
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
\n\t\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t\t
irradiance *= PI;
\n\t\t
#endif
\n\t\t
return irradiance;
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#elif defined( ENVMAP_TYPE_CUBE_UV )
\n\t\t\t
vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );
\n\t\t\t
vec4 envMapColor = textureCubeUV( queryVec, 1.0 );
\n\t\t
#else
\n\t\t\t
vec4 envMapColor = vec4( 0.0 );
\n\t\t
#endif
\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( pow2( 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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#elif defined( ENVMAP_TYPE_CUBE_UV )
\n\t\t\t
vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );
\n\t\t\t
vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\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\t
envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;
\n\t\t
#endif
\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
=
"
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 * directLight.color;
\n\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t
irradiance *= PI;
\n\t
#endif
\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_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 * directLight.color;
\n\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t
irradiance *= PI;
\n\t
#endif
\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
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
\n\t
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
\n
}
\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 = getPointDirectLightIrradiance( 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 = getSpotDirectLightIrradiance( 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 = getDirectionalDirectLightIrradiance( 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
vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n\t\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t\t
lightMapIrradiance *= PI;
\n\t\t
#endif
\n\t\t
irradiance += lightMapIrradiance;
\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
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
\n\t
\t
irradiance += getLightProbeIndirectIrradiance( geometry, 8 );
\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
getPointDirectLightIrradiance( pointLight, geometry, directLight );
\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
getSpotDirectLightIrradiance( spotLight, geometry, directLight );
\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
getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight
);
\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
vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n\t\t
#ifndef PHYSICALLY_CORRECT_LIGHTS
\n\t\t\t
lightMapIrradiance *= PI;
\n\t\t
#endif
\n\t\t
irradiance += lightMapIrradiance;
\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
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
\n\t
\t
irradiance += getLightProbeIndirectIrradiance( geometry, 8 );
\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
.
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 = mapTexelToLinear( texelColor );
\n\t
diffuseColor *= texelColor;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
map_pars_fragment
=
"
#ifdef USE_MAP
\n\t
uniform sampler2D map;
\n
#endif
\n
"
;
THREE
.
ShaderChunk
.
map_particle_fragment
=
"
#ifdef USE_MAP
\n\t
vec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );
\n\t
diffuseColor *= mapTexelToLinear( mapTexel );
\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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录