Browse Source

Embedded Env BRDF

Sebastien Vandenberghe 8 years ago
parent
commit
4f1a3da237

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

@@ -442,6 +442,8 @@
 
                 return this._renderTargets;
             }
+
+            this._environmentBRDFTexture = TextureTools.GetEnvironmentBRDFTexture(scene);
         }
 
         public abstract getClassName(): string;

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

@@ -512,6 +512,8 @@
          */
         constructor(name: string, scene: Scene) {
             super(name, scene);
+
+            this._environmentBRDFTexture = TextureTools.GetEnvironmentBRDFTexture(scene);
         }
 
         public getClassName(): string {

+ 4 - 2
src/Shaders/pbr.fragment.fx

@@ -534,11 +534,13 @@ void main(void) {
 #include<lightFragment>[0..maxSimultaneousLights]
 
 // _________________________ Specular Environment Oclusion __________________________
-#ifdef ENVIRONMENTBRDF
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
 	// Indexed on cos(theta) and roughness
 	vec2 brdfSamplerUV = vec2(NdotV, roughness);
+	
 	// We can find the scale and offset to apply to the specular value.
-	vec2 environmentBrdf = texture2D(environmentBrdfSampler, brdfSamplerUV).xy;
+	vec4 environmentBrdf = texture2D(environmentBrdfSampler, brdfSamplerUV);
+
 	vec3 specularEnvironmentReflectance = specularEnvironmentR0 * environmentBrdf.x + environmentBrdf.y;
 
 	#ifdef AMBIENTINGRAYSCALE

File diff suppressed because it is too large
+ 15 - 1
src/Tools/babylon.textureTools.ts


+ 2 - 0
src/babylon.scene.ts

@@ -190,6 +190,8 @@
         public clearColor: Color4 = new Color4(0.2, 0.2, 0.3, 1.0);
         public ambientColor = new Color3(0, 0, 0);
 
+        public _environmentBRDFTexture: BaseTexture;
+
         protected _environmentTexture: BaseTexture;
         /**
          * Texture used in all pbr material as the reflection texture.