@@ -245,8 +245,6 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
245
245
246
246
public NORMAL = false ;
247
247
public TANGENT = false ;
248
- public BUMP = false ;
249
- public BUMPDIRECTUV = 0 ;
250
248
public OBJECTSPACE_NORMALMAP = false ;
251
249
public PARALLAX = false ;
252
250
public PARALLAX_RHS = false ;
@@ -564,6 +562,15 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
564
562
// eslint-disable-next-line @typescript-eslint/no-unused-vars
565
563
private _baseMetalRoughTexture : Sampler = new Sampler ( "base_metalness_specular_roughness" , "baseMetalRough" , "METALLIC_ROUGHNESS" ) ;
566
564
565
+ /**
566
+ * Defines the normal of the material's geometry.
567
+ * See OpenPBR's specs for geometry_normal
568
+ */
569
+ public geometryNormalTexture : BaseTexture ;
570
+ @addAccessorsForMaterialProperty ( "_markAllSubMeshesAsTexturesDirty" , "geometryNormalTexture" )
571
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
572
+ private _geometryNormalTexture : Sampler = new Sampler ( "geometry_normal" , "geometryNormal" , "GEOMETRY_NORMAL" ) ;
573
+
567
574
/**
568
575
* Defines the opacity of the material's geometry.
569
576
* See OpenPBR's specs for geometry_opacity
@@ -637,13 +644,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
637
644
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
638
645
public environmentIntensity : number = 1.0 ;
639
646
640
- /**
641
- * Debug Control allowing disabling the bump map on this material.
642
- */
643
- @serialize ( )
644
- @expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
645
- public disableBumpMap : boolean = false ;
646
-
647
647
/**
648
648
* Stores the reflection values in a texture.
649
649
*/
@@ -658,13 +658,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
658
658
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
659
659
public useSpecularWeightFromTextureAlpha = false ;
660
660
661
- /**
662
- * Stores surface normal data used to displace a mesh in a texture.
663
- */
664
- @serializeAsTexture ( )
665
- @expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
666
- public bumpTexture : Nullable < BaseTexture > ;
667
-
668
661
/**
669
662
* Stores the pre-calculated light information of a mesh in a texture.
670
663
*/
@@ -791,14 +784,14 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
791
784
public useObjectSpaceNormalMap = false ;
792
785
793
786
/**
794
- * Allows using the bump map in parallax mode.
787
+ * Allows using the normal map in parallax mode.
795
788
*/
796
789
@serialize ( )
797
790
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
798
791
public useParallax = false ;
799
792
800
793
/**
801
- * Allows using the bump map in parallax occlusion mode.
794
+ * Allows using the normal map in parallax occlusion mode.
802
795
*/
803
796
@serialize ( )
804
797
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
@@ -819,7 +812,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
819
812
public disableLighting = false ;
820
813
821
814
/**
822
- * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
815
+ * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
823
816
*/
824
817
@serialize ( )
825
818
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
@@ -890,7 +883,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
890
883
/**
891
884
* Enables specular anti aliasing in the PBR shader.
892
885
* It will both interacts on the Geometry for analytical and IBL lighting.
893
- * It also prefilter the roughness map based on the bump values.
886
+ * It also prefilter the roughness map based on the normalmap values.
894
887
*/
895
888
@serialize ( )
896
889
@expandToProperty ( "_markAllSubMeshesAsTexturesDirty" )
@@ -975,12 +968,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
975
968
*/
976
969
private _lightingInfos : Vector4 = new Vector4 ( this . _directIntensity , this . _emissiveIntensity , this . _environmentIntensity , 1.0 ) ;
977
970
978
- /**
979
- * Debug Control allowing disabling the bump map on this material.
980
- * @internal
981
- */
982
- public _disableBumpMap : boolean = false ;
983
-
984
971
/**
985
972
* Stores the reflection values in a texture.
986
973
* @internal
@@ -994,12 +981,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
994
981
*/
995
982
public _useSpecularWeightFromTextureAlpha = false ;
996
983
997
- /**
998
- * Stores surface normal data used to displace a mesh in a texture.
999
- * @internal
1000
- */
1001
- public _bumpTexture : Nullable < BaseTexture > = null ;
1002
-
1003
984
/**
1004
985
* Stores the pre-calculated light information of a mesh in a texture.
1005
986
* @internal
@@ -1103,13 +1084,13 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1103
1084
public _useObjectSpaceNormalMap = false ;
1104
1085
1105
1086
/**
1106
- * Allows using the bump map in parallax mode.
1087
+ * Allows using the normal map in parallax mode.
1107
1088
* @internal
1108
1089
*/
1109
1090
public _useParallax = false ;
1110
1091
1111
1092
/**
1112
- * Allows using the bump map in parallax occlusion mode.
1093
+ * Allows using the normal map in parallax occlusion mode.
1113
1094
* @internal
1114
1095
*/
1115
1096
public _useParallaxOcclusion = false ;
@@ -1179,7 +1160,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1179
1160
public _environmentBRDFTexture : Nullable < BaseTexture > = null ;
1180
1161
1181
1162
/**
1182
- * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
1163
+ * Force the shader to compute irradiance in the fragment shader in order to take normal mapping into account.
1183
1164
* @internal
1184
1165
*/
1185
1166
public _forceIrradianceInFragment = false ;
@@ -1224,7 +1205,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1224
1205
/**
1225
1206
* Enables specular anti aliasing in the PBR shader.
1226
1207
* It will both interacts on the Geometry for analytical and IBL lighting.
1227
- * It also prefilter the roughness map based on the bump values.
1208
+ * It also prefilter the roughness map based on the normalmap values.
1228
1209
* @internal
1229
1210
*/
1230
1211
public _enableSpecularAntiAliasing = false ;
@@ -1369,6 +1350,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1369
1350
this . _specularRoughness ;
1370
1351
this . _specularIor ;
1371
1352
this . _baseMetalRoughTexture ;
1353
+ this . _geometryNormalTexture ;
1372
1354
this . _geometryOpacity ;
1373
1355
this . _geometryOpacityTexture ;
1374
1356
this . _emissionColor ;
@@ -1621,13 +1603,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1621
1603
}
1622
1604
}
1623
1605
1624
- if ( engine . getCaps ( ) . standardDerivatives && this . _bumpTexture && MaterialFlags . BumpTextureEnabled && ! this . _disableBumpMap ) {
1625
- // Bump texture cannot be not blocking.
1626
- if ( ! this . _bumpTexture . isReady ( ) ) {
1627
- return false ;
1628
- }
1629
- }
1630
-
1631
1606
if ( this . _environmentBRDFTexture && MaterialFlags . ReflectionTextureEnabled ) {
1632
1607
// This is blocking.
1633
1608
if ( ! this . _environmentBRDFTexture . isReady ( ) ) {
@@ -1717,9 +1692,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1717
1692
// Order is important !
1718
1693
const ubo = this . _uniformBuffer ;
1719
1694
ubo . addUniform ( "vLightmapInfos" , 2 ) ;
1720
- ubo . addUniform ( "vBumpInfos" , 3 ) ;
1721
1695
ubo . addUniform ( "lightmapMatrix" , 16 ) ;
1722
- ubo . addUniform ( "bumpMatrix" , 16 ) ;
1723
1696
ubo . addUniform ( "vTangentSpaceParams" , 2 ) ;
1724
1697
ubo . addUniform ( "vLightingIntensity" , 4 ) ;
1725
1698
@@ -1821,10 +1794,7 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1821
1794
BindTextureMatrix ( this . _lightmapTexture , ubo , "lightmap" ) ;
1822
1795
}
1823
1796
1824
- if ( this . _bumpTexture && engine . getCaps ( ) . standardDerivatives && MaterialFlags . BumpTextureEnabled && ! this . _disableBumpMap ) {
1825
- ubo . updateFloat3 ( "vBumpInfos" , this . _bumpTexture . coordinatesIndex , this . _bumpTexture . level , this . _parallaxScaleBias ) ;
1826
- BindTextureMatrix ( this . _bumpTexture , ubo , "bump" ) ;
1827
-
1797
+ if ( this . geometryNormalTexture ) {
1828
1798
if ( scene . _mirroredCameraPosition ) {
1829
1799
ubo . updateFloat2 ( "vTangentSpaceParams" , this . _invertNormalMapX ? 1.0 : - 1.0 , this . _invertNormalMapY ? 1.0 : - 1.0 ) ;
1830
1800
} else {
@@ -1886,10 +1856,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1886
1856
if ( this . _lightmapTexture && MaterialFlags . LightmapTextureEnabled ) {
1887
1857
ubo . setTexture ( "lightmapSampler" , this . _lightmapTexture ) ;
1888
1858
}
1889
-
1890
- if ( this . _bumpTexture && engine . getCaps ( ) . standardDerivatives && MaterialFlags . BumpTextureEnabled && ! this . _disableBumpMap ) {
1891
- ubo . setTexture ( "bumpSampler" , this . _bumpTexture ) ;
1892
- }
1893
1859
}
1894
1860
1895
1861
// OIT with depth peeling
@@ -1963,10 +1929,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1963
1929
results . push ( this . _reflectionTexture ) ;
1964
1930
}
1965
1931
1966
- if ( this . _bumpTexture && this . _bumpTexture . animations && this . _bumpTexture . animations . length > 0 ) {
1967
- results . push ( this . _bumpTexture ) ;
1968
- }
1969
-
1970
1932
if ( this . _lightmapTexture && this . _lightmapTexture . animations && this . _lightmapTexture . animations . length > 0 ) {
1971
1933
results . push ( this . _lightmapTexture ) ;
1972
1934
}
@@ -1993,10 +1955,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1993
1955
activeTextures . push ( this . _reflectionTexture ) ;
1994
1956
}
1995
1957
1996
- if ( this . _bumpTexture ) {
1997
- activeTextures . push ( this . _bumpTexture ) ;
1998
- }
1999
-
2000
1958
if ( this . _lightmapTexture ) {
2001
1959
activeTextures . push ( this . _lightmapTexture ) ;
2002
1960
}
@@ -2026,10 +1984,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2026
1984
return true ;
2027
1985
}
2028
1986
2029
- if ( this . _bumpTexture === texture ) {
2030
- return true ;
2031
- }
2032
-
2033
1987
if ( this . _lightmapTexture === texture ) {
2034
1988
return true ;
2035
1989
}
@@ -2066,7 +2020,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2066
2020
}
2067
2021
2068
2022
this . _reflectionTexture ?. dispose ( ) ;
2069
- this . _bumpTexture ?. dispose ( ) ;
2070
2023
this . _lightmapTexture ?. dispose ( ) ;
2071
2024
}
2072
2025
@@ -2148,10 +2101,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2148
2101
fallbacks . addFallback ( fallbackRank ++ , "TANGENT" ) ;
2149
2102
}
2150
2103
2151
- if ( defines . BUMP ) {
2152
- fallbacks . addFallback ( fallbackRank ++ , "BUMP" ) ;
2153
- }
2154
-
2155
2104
fallbackRank = HandleFallbacksForShadows ( defines , fallbacks , this . _maxSimultaneousLights , fallbackRank ++ ) ;
2156
2105
2157
2106
if ( defines . SPECULARTERM ) {
@@ -2224,11 +2173,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2224
2173
"vFogInfos" ,
2225
2174
"vFogColor" ,
2226
2175
"pointSize" ,
2227
- "vBumpInfos" ,
2228
2176
"vLightmapInfos" ,
2229
2177
"mBones" ,
2230
2178
"normalMatrix" ,
2231
- "bumpMatrix" ,
2232
2179
"lightmapMatrix" ,
2233
2180
"vLightingIntensity" ,
2234
2181
"logarithmicDepthConstant" ,
@@ -2245,13 +2192,9 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2245
2192
}
2246
2193
2247
2194
const samplers = [
2248
- "reflectivitySampler" ,
2249
- "bumpSampler" ,
2250
2195
"lightmapSampler" ,
2251
2196
"environmentBrdfSampler" ,
2252
2197
"boneSampler" ,
2253
- "metallicReflectanceSampler" ,
2254
- "reflectanceSampler" ,
2255
2198
"morphTargets" ,
2256
2199
"oitDepthSampler" ,
2257
2200
"oitFrontColorSampler" ,
@@ -2378,13 +2321,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2378
2321
defines [ "MAINUV" + i ] = false ;
2379
2322
}
2380
2323
if ( scene . texturesEnabled ) {
2381
- defines . AMBIENTDIRECTUV = 0 ;
2382
- defines . OPACITYDIRECTUV = 0 ;
2383
- defines . EMISSIVEDIRECTUV = 0 ;
2384
- defines . REFLECTIVITYDIRECTUV = 0 ;
2385
- defines . METALLIC_REFLECTANCEDIRECTUV = 0 ;
2386
- defines . REFLECTANCEDIRECTUV = 0 ;
2387
- defines . BUMPDIRECTUV = 0 ;
2388
2324
defines . LIGHTMAPDIRECTUV = 0 ;
2389
2325
2390
2326
if ( engine . getCaps ( ) . textureLOD ) {
@@ -2428,20 +2364,16 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
2428
2364
defines . SPECULAR_WEIGHT_USE_ALPHA_ONLY = this . _useSpecularWeightFromTextureAlpha ;
2429
2365
}
2430
2366
2431
- if ( engine . getCaps ( ) . standardDerivatives && this . _bumpTexture && MaterialFlags . BumpTextureEnabled && ! this . _disableBumpMap ) {
2432
- PrepareDefinesForMergedUV ( this . _bumpTexture , defines , "BUMP" ) ;
2433
-
2367
+ if ( this . geometryNormalTexture ) {
2434
2368
if ( this . _useParallax && this . baseColorTexture && MaterialFlags . DiffuseTextureEnabled ) {
2435
2369
defines . PARALLAX = true ;
2436
2370
defines . PARALLAX_RHS = scene . useRightHandedSystem ;
2437
2371
defines . PARALLAXOCCLUSION = ! ! this . _useParallaxOcclusion ;
2438
2372
} else {
2439
2373
defines . PARALLAX = false ;
2440
2374
}
2441
-
2442
2375
defines . OBJECTSPACE_NORMALMAP = this . _useObjectSpaceNormalMap ;
2443
2376
} else {
2444
- defines . BUMP = false ;
2445
2377
defines . PARALLAX = false ;
2446
2378
defines . PARALLAX_RHS = false ;
2447
2379
defines . PARALLAXOCCLUSION = false ;
0 commit comments