Переглянути джерело

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 роки тому
батько
коміт
14569bbc9b

+ 1 - 0
dist/preview release/what's new.md

@@ -90,6 +90,7 @@
 - (Viewer) Viewer supports model animations ([RaananW](https://github.com/RaananW))
 - Tests for sharpen, chromatic aberration, default pipeline and enable/disable post processes ([trevordev](https://github.com/trevordev))
 - onPointer* callbacks have now the event type as a 3rd variable ([RaananW](https://github.com/RaananW))
+- Lightmap texture in PBR material follow the gammaSpace Flag of the texture ([sebavan](https://github.com/sebavan))
 
 ## Bug fixes
 

+ 2 - 0
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -65,6 +65,7 @@
         public LIGHTMAP = false;
         public LIGHTMAPDIRECTUV = 0;
         public USELIGHTMAPASSHADOWMAP = false;
+        public GAMMALIGHTMAP = false;
 
         public REFLECTION = false;
         public REFLECTIONMAP_3D = false;
@@ -1105,6 +1106,7 @@
                     if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
                         MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
                         defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
+                        defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
                     } else {
                         defines.LIGHTMAP = false;
                     }

+ 5 - 1
src/Shaders/pbr.fragment.fx

@@ -602,7 +602,11 @@ void main(void) {
 #endif
 
 #ifdef LIGHTMAP
-	vec3 lightmapColor = toLinearSpace(texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb) * vLightmapInfos.y;
+	vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb);
+	#ifdef GAMMALIGHTMAP
+		lightmapColor = toLinearSpace(lightmapColor);
+	#endif
+	lightmapColor *= vLightmapInfos.y
 #endif
 
 	lightingInfo info;