Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
a1f0a5cd
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a1f0a5cd
编写于
10月 27, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated builds.
上级
21464f0d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
6 deletion
+6
-6
build/three.js
build/three.js
+2
-2
build/three.min.js
build/three.min.js
+2
-2
build/three.modules.js
build/three.modules.js
+2
-2
未找到文件。
build/three.js
浏览文件 @
a1f0a5cd
...
...
@@ -5004,7 +5004,7 @@
var beginnormal_vertex = "\nvec3 objectNormal = vec3( normal );\n";
var bsdfs = "
bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\n
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
...
...
@@ -5060,7 +5060,7 @@
var 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\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
var lights_pars = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\t
if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) )
) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include <normal_flip>\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include <normal_flip>\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 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\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\t
directLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos
) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include <normal_flip>\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include <normal_flip>\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 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\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";
...
...
build/three.min.js
浏览文件 @
a1f0a5cd
...
...
@@ -338,7 +338,7 @@ Xa.prototype.constructor=Xa;Xa.prototype.isCubeTexture=!0;Object.defineProperty(
void
0
!==
d
&&
d
.
setValue
(
a
,
b
[
c
],
this
.
renderer
)};
Ya
.
prototype
.
setOptional
=
function
(
a
,
b
,
c
){
b
=
b
[
c
];
void
0
!==
b
&&
this
.
setValue
(
a
,
c
,
b
)};
Ya
.
upload
=
function
(
a
,
b
,
c
,
d
){
for
(
var
e
=
0
,
f
=
b
.
length
;
e
!==
f
;
++
e
){
var
g
=
b
[
e
],
h
=
c
[
g
.
id
];
!
1
!==
h
.
needsUpdate
&&
g
.
setValue
(
a
,
h
.
value
,
d
)}};
Ya
.
seqWithValue
=
function
(
a
,
b
){
for
(
var
c
=
[],
d
=
0
,
e
=
a
.
length
;
d
!==
e
;
++
d
){
var
f
=
a
[
d
];
f
.
id
in
b
&&
c
.
push
(
f
)}
return
c
};
var
La
=
{
merge
:
function
(
a
){
for
(
var
b
=
{},
c
=
0
;
c
<
a
.
length
;
c
++
){
var
d
=
this
.
clone
(
a
[
c
]),
e
;
for
(
e
in
d
)
b
[
e
]
=
d
[
e
]}
return
b
},
clone
:
function
(
a
){
var
b
=
{},
c
;
for
(
c
in
a
){
b
[
c
]
=
{};
for
(
var
d
in
a
[
c
]){
var
e
=
a
[
c
][
d
];
e
&&
(
e
.
isColor
||
e
.
isMatrix3
||
e
.
isMatrix4
||
e
.
isVector2
||
e
.
isVector3
||
e
.
isVector4
||
e
.
isTexture
)?
b
[
c
][
d
]
=
e
.
clone
():
Array
.
isArray
(
e
)?
b
[
c
][
d
]
=
e
.
slice
():
b
[
c
][
d
]
=
e
}}
return
b
}},
X
=
{
alphamap_fragment
:
"
#ifdef USE_ALPHAMAP
\n\t
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
\n
#endif
\n
"
,
alphamap_pars_fragment
:
"
#ifdef USE_ALPHAMAP
\n\t
uniform sampler2D alphaMap;
\n
#endif
\n
"
,
alphatest_fragment
:
"
#ifdef ALPHATEST
\n\t
if ( diffuseColor.a < ALPHATEST ) discard;
\n
#endif
\n
"
,
aomap_fragment
:
"
#ifdef USE_AOMAP
\n\t
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
\n\t
reflectedLight.indirectDiffuse *= ambientOcclusion;
\n\t
#if defined( USE_ENVMAP ) && defined( PHYSICAL )
\n\t\t
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
\n\t\t
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
\n\t
#endif
\n
#endif
\n
"
,
aomap_pars_fragment
:
"
#ifdef USE_AOMAP
\n\t
uniform sampler2D aoMap;
\n\t
uniform float aoMapIntensity;
\n
#endif
"
,
begin_vertex
:
"
\n
vec3 transformed = vec3( position );
\n
"
,
beginnormal_vertex
:
"
\n
vec3 objectNormal = vec3( normal );
\n
"
,
bsdfs
:
"
bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {
\n\t
return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );
\n
}
\n
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
\n\t\t
if( decayExponent > 0.0 ) {
\n
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
\n\t\t\t
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
\n\t\t\t
float maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
\n\t\t\t
return distanceFalloff * maxDistanceCutoffFactor;
\n
#else
\n\t\t\t
return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
\n
#endif
\n\t\t
}
\n\t\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 = pow2( alpha );
\n\t
float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
\n\t
float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
\n\t
return 1.0 / ( gl * gv );
\n
}
\n
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
\n\t
float a2 = pow2( alpha );
\n\t
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
\n\t
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
\n\t
return 0.5 / max( gv + gl, EPSILON );
\n
}
\n
float D_GGX( const in float alpha, const in float dotNH ) {
\n\t
float a2 = pow2( alpha );
\n\t
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
\n\t
return RECIPROCAL_PI * a2 / pow2( 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 = pow2( 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_SmithCorrelated( 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 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
\n
}
\n
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
\n\t
return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
\n
}
\n
"
,
begin_vertex
:
"
\n
vec3 transformed = vec3( position );
\n
"
,
beginnormal_vertex
:
"
\n
vec3 objectNormal = vec3( normal );
\n
"
,
bsdfs
:
"
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
\n\t\t
if( decayExponent > 0.0 ) {
\n
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
\n\t\t\t
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
\n\t\t\t
float maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
\n\t\t\t
return distanceFalloff * maxDistanceCutoffFactor;
\n
#else
\n\t\t\t
return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
\n
#endif
\n\t\t
}
\n\t\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 = pow2( alpha );
\n\t
float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
\n\t
float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
\n\t
return 1.0 / ( gl * gv );
\n
}
\n
float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
\n\t
float a2 = pow2( alpha );
\n\t
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
\n\t
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
\n\t
return 0.5 / max( gv + gl, EPSILON );
\n
}
\n
float D_GGX( const in float alpha, const in float dotNH ) {
\n\t
float a2 = pow2( alpha );
\n\t
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
\n\t
return RECIPROCAL_PI * a2 / pow2( 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 = pow2( 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_SmithCorrelated( 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 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
\n
}
\n
float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
\n\t
return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
\n
}
\n
"
,
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
"
,
clipping_planes_fragment
:
"
#if NUM_CLIPPING_PLANES > 0
\n\t
for ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {
\n\t\t
vec4 plane = clippingPlanes[ i ];
\n\t\t
if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;
\n\t
}
\n\t\t\n\t
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
\n\t\t
bool clipped = true;
\n\t\t
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {
\n\t\t\t
vec4 plane = clippingPlanes[ i ];
\n\t\t\t
clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;
\n\t\t
}
\n\t\t
if ( clipped ) discard;
\n\t\n\t
#endif
\n
#endif
\n
"
,
clipping_planes_pars_fragment
:
"
#if NUM_CLIPPING_PLANES > 0
\n\t
#if ! defined( PHYSICAL ) && ! defined( PHONG )
\n\t\t
varying vec3 vViewPosition;
\n\t
#endif
\n\t
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
\n
#endif
\n
"
,
clipping_planes_pars_vertex
:
"
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )
\n\t
varying vec3 vViewPosition;
\n
#endif
\n
"
,
clipping_planes_vertex
:
"
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )
\n\t
vViewPosition = - mvPosition.xyz;
\n
#endif
\n
"
,
...
...
@@ -351,7 +351,7 @@ envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tunifor
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
"
,
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
"
,
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
"
,
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
"
,
lightmap_fragment
:
"
#ifdef USE_LIGHTMAP
\n\t
reflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
\n
#endif
\n
"
,
lightmap_pars_fragment
:
"
#ifdef USE_LIGHTMAP
\n\t
uniform sampler2D lightMap;
\n\t
uniform float lightMapIntensity;
\n
#endif
"
,
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
"
,
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( PHYSICAL )
\n\t
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
\n\t\t
#include <normal_flip>
\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
#include <normal_flip>
\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
"
,
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
directLight.color = pointLight.color;
\n\t\t
directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
\n\t\t
directLight.visible = ( directLight.color != vec3( 0.0 ) );
\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 ( angleCos > spotLight.coneCos
) {
\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( PHYSICAL )
\n\t
vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {
\n\t\t
#include <normal_flip>
\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
#include <normal_flip>
\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
"
,
lights_phong_fragment
:
"
BlinnPhongMaterial material;
\n
material.diffuseColor = diffuseColor.rgb;
\n
material.specularColor = specular;
\n
material.specularShininess = shininess;
\n
material.specularStrength = specularStrength;
\n
"
,
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
"
,
lights_physical_fragment
:
"
PhysicalMaterial material;
\n
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
\n
material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
\n
#ifdef STANDARD
\n\t
material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
\n
#else
\n\t
material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
\n\t
material.clearCoat = saturate( clearCoat );
\t
material.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );
\n
#endif
\n
"
,
lights_physical_pars_fragment
:
"
struct PhysicalMaterial {
\n\t
vec3
\t
diffuseColor;
\n\t
float
\t
specularRoughness;
\n\t
vec3
\t
specularColor;
\n\t
#ifndef STANDARD
\n\t\t
float clearCoat;
\n\t\t
float clearCoatRoughness;
\n\t
#endif
\n
};
\n
#define MAXIMUM_SPECULAR_COEFFICIENT 0.16
\n
#define DEFAULT_SPECULAR_COEFFICIENT 0.04
\n
float clearCoatDHRApprox( const in float roughness, const in float dotNL ) {
\n\t
return DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );
\n
}
\n
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial 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
#ifndef STANDARD
\n\t\t
float clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );
\n\t
#else
\n\t\t
float clearCoatDHR = 0.0;
\n\t
#endif
\n\t
reflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );
\n\t
reflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n\t
#ifndef STANDARD
\n\t\t
reflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );
\n\t
#endif
\n
}
\n
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
\n
}
\n
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
\n\t
#ifndef STANDARD
\n\t\t
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
\n\t\t
float dotNL = dotNV;
\n\t\t
float clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );
\n\t
#else
\n\t\t
float clearCoatDHR = 0.0;
\n\t
#endif
\n\t
reflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );
\n\t
#ifndef STANDARD
\n\t\t
reflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );
\n\t
#endif
\n
}
\n
#define RE_Direct
\t\t\t\t
RE_Direct_Physical
\n
#define RE_IndirectDiffuse
\t\t
RE_IndirectDiffuse_Physical
\n
#define RE_IndirectSpecular
\t\t
RE_IndirectSpecular_Physical
\n
#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )
\n
#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )
\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
"
,
...
...
build/three.modules.js
浏览文件 @
a1f0a5cd
...
...
@@ -4998,7 +4998,7 @@ var begin_vertex = "\nvec3 transformed = vec3( position );\n";
var beginnormal_vertex = "\nvec3 objectNormal = vec3( normal );\n";
var bsdfs = "
bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\n
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bsdfs = "float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
...
...
@@ -5054,7 +5054,7 @@ var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;
var 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\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
var lights_pars = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\t
if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) )
) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include <normal_flip>\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include <normal_flip>\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 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\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_pars = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\t
directLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos
) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include <normal_flip>\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include <normal_flip>\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 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\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录