Skip to content

Commit cf8143a

Browse files
author
Mike Bond
committed
Remove lightmap from OpenPBR
1 parent c3d174f commit cf8143a

File tree

10 files changed

+17
-122
lines changed

10 files changed

+17
-122
lines changed

packages/dev/core/src/Materials/PBR/openPbrMaterial.ts

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,6 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
251251
public PARALLAXOCCLUSION = false;
252252
public NORMALXYSCALE = true;
253253

254-
public LIGHTMAP = false;
255-
public LIGHTMAPDIRECTUV = 0;
256-
public USELIGHTMAPASSHADOWMAP = false;
257-
public GAMMALIGHTMAP = false;
258-
public RGBDLIGHTMAP = false;
259-
260254
public REFLECTION = false;
261255
public REFLECTIONMAP_3D = false;
262256
public REFLECTIONMAP_SPHERICAL = false;
@@ -278,7 +272,6 @@ export class OpenPBRMaterialDefines extends ImageProcessingDefinesMixin(OpenPBRM
278272
public LODINREFLECTIONALPHA = false;
279273
public GAMMAREFLECTION = false;
280274
public RGBDREFLECTION = false;
281-
public LINEARSPECULARREFLECTION = false;
282275
public RADIANCEOCCLUSION = false;
283276
public HORIZONOCCLUSION = false;
284277

@@ -658,20 +651,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
658651
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
659652
public useSpecularWeightFromTextureAlpha = false;
660653

661-
/**
662-
* Stores the pre-calculated light information of a mesh in a texture.
663-
*/
664-
@serializeAsTexture()
665-
@expandToProperty("_markAllSubMeshesAsTexturesDirty", null)
666-
public lightmapTexture: Nullable<BaseTexture>;
667-
668-
/**
669-
* If true, the light map contains occlusion information instead of lighting info.
670-
*/
671-
@serialize()
672-
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
673-
public useLightmapAsShadowmap = false;
674-
675654
/**
676655
* Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
677656
*/
@@ -981,36 +960,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
981960
*/
982961
public _useSpecularWeightFromTextureAlpha = false;
983962

984-
/**
985-
* Stores the pre-calculated light information of a mesh in a texture.
986-
* @internal
987-
*/
988-
public _lightmapTexture: Nullable<BaseTexture> = null;
989-
990-
/**
991-
* The color of a material in ambient lighting.
992-
* @internal
993-
*/
994-
public _ambientColor = new Color3(0, 0, 0);
995-
996-
/**
997-
* AKA Specular Color in other nomenclature.
998-
* @internal
999-
*/
1000-
public _reflectivityColor = new Color3(1, 1, 1);
1001-
1002-
/**
1003-
* The color applied when light is reflected from a material.
1004-
* @internal
1005-
*/
1006-
public _reflectionColor = new Color3(1, 1, 1);
1007-
1008-
/**
1009-
* Specifies that the material will use the light map as a show map.
1010-
* @internal
1011-
*/
1012-
public _useLightmapAsShadowmap = false;
1013-
1014963
/**
1015964
* This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
1016965
* makes the reflect vector face the model (under horizon).
@@ -1597,12 +1546,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
15971546
}
15981547
}
15991548

1600-
if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1601-
if (!this._lightmapTexture.isReadyOrNotBlocking()) {
1602-
return false;
1603-
}
1604-
}
1605-
16061549
if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
16071550
// This is blocking.
16081551
if (!this._environmentBRDFTexture.isReady()) {
@@ -1691,8 +1634,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
16911634
public override buildUniformLayout(): void {
16921635
// Order is important !
16931636
const ubo = this._uniformBuffer;
1694-
ubo.addUniform("vLightmapInfos", 2);
1695-
ubo.addUniform("lightmapMatrix", 16);
16961637
ubo.addUniform("vTangentSpaceParams", 2);
16971638
ubo.addUniform("vLightingIntensity", 4);
16981639

@@ -1789,11 +1730,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
17891730
}
17901731
}
17911732

1792-
if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1793-
ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
1794-
BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
1795-
}
1796-
17971733
if (this.geometryNormalTexture) {
17981734
if (scene._mirroredCameraPosition) {
17991735
ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
@@ -1852,10 +1788,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
18521788
if (defines.ENVIRONMENTBRDF) {
18531789
ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
18541790
}
1855-
1856-
if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1857-
ubo.setTexture("lightmapSampler", this._lightmapTexture);
1858-
}
18591791
}
18601792

18611793
// OIT with depth peeling
@@ -1929,10 +1861,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
19291861
results.push(this._reflectionTexture);
19301862
}
19311863

1932-
if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
1933-
results.push(this._lightmapTexture);
1934-
}
1935-
19361864
return results;
19371865
}
19381866

@@ -1955,10 +1883,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
19551883
activeTextures.push(this._reflectionTexture);
19561884
}
19571885

1958-
if (this._lightmapTexture) {
1959-
activeTextures.push(this._lightmapTexture);
1960-
}
1961-
19621886
return activeTextures;
19631887
}
19641888

@@ -1984,10 +1908,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
19841908
return true;
19851909
}
19861910

1987-
if (this._lightmapTexture === texture) {
1988-
return true;
1989-
}
1990-
19911911
return false;
19921912
}
19931913

@@ -2020,7 +1940,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
20201940
}
20211941

20221942
this._reflectionTexture?.dispose();
2023-
this._lightmapTexture?.dispose();
20241943
}
20251944

20261945
this._renderTargets.dispose();
@@ -2115,10 +2034,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
21152034
fallbacks.addFallback(fallbackRank++, "USEIRRADIANCEMAP");
21162035
}
21172036

2118-
if (defines.LIGHTMAP) {
2119-
fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
2120-
}
2121-
21222037
if (defines.NORMAL) {
21232038
fallbacks.addFallback(fallbackRank++, "NORMAL");
21242039
}
@@ -2173,10 +2088,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
21732088
"vFogInfos",
21742089
"vFogColor",
21752090
"pointSize",
2176-
"vLightmapInfos",
21772091
"mBones",
21782092
"normalMatrix",
2179-
"lightmapMatrix",
21802093
"vLightingIntensity",
21812094
"logarithmicDepthConstant",
21822095
"vTangentSpaceParams",
@@ -2192,7 +2105,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
21922105
}
21932106

21942107
const samplers = [
2195-
"lightmapSampler",
21962108
"environmentBrdfSampler",
21972109
"boneSampler",
21982110
"morphTargets",
@@ -2321,7 +2233,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
23212233
defines["MAINUV" + i] = false;
23222234
}
23232235
if (scene.texturesEnabled) {
2324-
defines.LIGHTMAPDIRECTUV = 0;
23252236

23262237
if (engine.getCaps().textureLOD) {
23272238
defines.LODBASEDMICROSFURACE = true;
@@ -2347,15 +2258,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
23472258
this._baseDiffuseRoughnessTexture != null;
23482259
PrepareDefinesForIBL(scene, reflectionTexture, defines, this.realTimeFiltering, this.realTimeFilteringQuality, !useSHInFragment);
23492260

2350-
if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
2351-
PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
2352-
defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
2353-
defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
2354-
defines.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
2355-
} else {
2356-
defines.LIGHTMAP = false;
2357-
}
2358-
23592261
if (MaterialFlags.SpecularTextureEnabled) {
23602262
if (this._baseMetalRoughTexture) {
23612263
defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;

packages/dev/core/src/Shaders/ShadersInclude/openPbrUboDeclaration.fx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ layout(std140, column_major) uniform;
2323
// }
2424

2525
uniform Material {
26-
vec2 vLightmapInfos;
27-
mat4 lightmapMatrix;
2826
vec2 vTangentSpaceParams;
2927
vec4 vLightingIntensity;
3028
float pointSize;

packages/dev/core/src/Shaders/ShadersInclude/openpbrFragmentDeclaration.fx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ uniform vec2 vGeometryOpacityInfos;
4242
uniform vec2 vEmissionInfos;
4343
#endif
4444

45-
#ifdef LIGHTMAP
46-
uniform vec2 vLightmapInfos;
47-
#endif
48-
4945
#ifdef METALLIC_ROUGHNESS
5046
uniform vec2 vBaseMetalRoughInfos;
5147
#endif

packages/dev/core/src/Shaders/ShadersInclude/openpbrFragmentSamplersDeclaration.fx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
1111
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
12-
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
1312

1413
// Reflection
1514
#ifdef REFLECTION

packages/dev/core/src/Shaders/openpbr.fragment.fx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ void main(void) {
143143
// Mopaque-base =mix(Mglossy-diffuse,Ssubsurface,S) whereS =subsurface_weight
144144
// Mglossy-diffuse =layer(Sdiffuse,Sgloss)
145145

146+
// Base roughness is modified by the coat layer
147+
// rB′ = mix(rB, min(1, rB^4 + 2rC^4)^1/4 , C) where C = coat_weight (61) in OpenPBR spec
148+
149+
// Sample specular lobe IBL and analytic lights separately from BRDF for each layer
150+
// - pass in roughness, anisotropy, sample vector (and tangent?). Same code for reflection and refraction.
151+
// - Coat: - one sample - pass in coat_roughness_anisotropy, coat_roughness, geometry_coat_normal
152+
// - Base:- one sample - pass in geometry_normal, specular_roughness, specular_anisotropy
153+
// - Translucent refraction
154+
// - thin-walled refraction - i.e. no refraction
155+
// Sample diffuse lobe IBL and analytic lights separately from BRDF for each layer
156+
// - only Base layer has diffuse lobe
157+
// - pass in base_diffuse_roughness, geometry_normal, base_color
158+
// - Subsurface - refracted/transmitted diffuse - (geometry_thin_walled with subsurface is the same as glTF diffuse transmission)
146159

147160

148161
// _____________________________ AO _______________________________
@@ -159,8 +172,6 @@ void main(void) {
159172
#endif
160173
);
161174

162-
#include<pbrBlockLightmapInit>
163-
164175
#ifdef UNLIT
165176
vec3 diffuseBase = vec3(1., 1., 1.);
166177
#else // !UNLIT
@@ -233,6 +244,8 @@ vec4 specularColor = vSpecularColor;
233244
// _____________________________ Compute Geometry info _________________________________
234245
#include<openpbrBlockGeometryInfo>
235246

247+
// Share code for reflection and refraction
248+
// Pass in values to select between reflection and refraction, diffuse and specular, anisotropic and isotropic
236249
// _____________________________ Reflection Info _______________________________________
237250
#ifdef REFLECTION
238251
reflectionOutParams reflectionOut;
@@ -250,9 +263,6 @@ vec4 specularColor = vSpecularColor;
250263
#endif
251264
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
252265
, NdotVUnclamped
253-
#endif
254-
#ifdef LINEARSPECULARREFLECTION
255-
, roughness
256266
#endif
257267
, reflectionSampler
258268
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)

packages/dev/core/src/Shaders/openpbr.vertex.fx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ attribute vec4 color;
4646
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion)
4747
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
4848
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
49-
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
5049

5150
// Output
5251
varying vec3 vPositionW;
@@ -225,7 +224,6 @@ void main(void) {
225224
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_MATRIXNAME_,ambientOcclusion,_INFONAME_,AmbientOcclusionInfos.x)
226225
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
227226
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
228-
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
229227

230228
// TBN
231229
#include<openpbrNormalMapVertex>

packages/dev/core/src/ShadersWGSL/ShadersInclude/openPbrUboDeclaration.fx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
uniform vLightmapInfos: vec2f;
3-
uniform lightmapMatrix: mat4x4f;
42
uniform vTangentSpaceParams: vec2f;
53
uniform vLightingIntensity: vec4f;
64
uniform pointSize: f32;

packages/dev/core/src/ShadersWGSL/ShadersInclude/openpbrFragmentSamplersDeclaration.fx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
1111
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
12-
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
13-
1412

1513
// Reflection
1614
#ifdef REFLECTION

packages/dev/core/src/ShadersWGSL/openpbr.fragment.fx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ fn main(input: FragmentInputs) -> FragmentOutputs {
132132
#endif
133133
);
134134

135-
#include<pbrBlockLightmapInit>
136-
137135
#ifdef UNLIT
138136
var diffuseBase: vec3f = vec3f(1., 1., 1.);
139137
#else

packages/dev/core/src/ShadersWGSL/openpbr.vertex.fx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ attribute color: vec4f;
4242
#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion)
4343
#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
4444
#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
45-
#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
4645

4746
// Output
4847
varying vPositionW: vec3f;
@@ -209,12 +208,11 @@ fn main(input : VertexInputs) -> FragmentInputs {
209208
#include<samplerVertexImplementation>(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_MATRIXNAME_,geometryNormal,_INFONAME_,GeometryNormalInfos.x)
210209
#include<samplerVertexImplementation>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_MATRIXNAME_,geometryOpacity,_INFONAME_,GeometryOpacityInfos.x)
211210
#include<samplerVertexImplementation>(_DEFINENAME_,EMISSION,_VARYINGNAME_,Emission,_MATRIXNAME_,emission,_INFONAME_,EmissionInfos.x)
212-
211+
213212
#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_MATRIXNAME_,ambientOcclusion,_INFONAME_,AmbientOcclusionInfos.x)
214213
#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
215214
#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
216-
#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
217-
215+
218216
// TBN
219217
#include<openpbrNormalMapVertex>
220218

0 commit comments

Comments
 (0)