ソースを参照

Fix computing static
Fix useless new texture in Environment.hx
Fix dispose of the current shadowmap for point light

ShiroSmith 5 年 前
コミット
4fc0c17a37
4 ファイル変更21 行追加12 行削除
  1. 2 1
      h3d/pass/PointShadowMap.hx
  2. 4 2
      h3d/scene/Object.hx
  3. 1 1
      h3d/scene/World.hx
  4. 14 8
      h3d/scene/pbr/Environment.hx

+ 2 - 1
h3d/pass/PointShadowMap.hx

@@ -241,8 +241,9 @@ class PointShadowMap extends Shadows {
 			return;
 			return;
 		draw(passes);
 		draw(passes);
 		var texture = pshader.shadowMap;
 		var texture = pshader.shadowMap;
-		if( staticTexture != null ) staticTexture.dispose();
+		var old = staticTexture;
 		staticTexture = texture.clone();
 		staticTexture = texture.clone();
+		if( old != null ) old.dispose();
 		staticTexture.name = "StaticPointShadowMap";
 		staticTexture.name = "StaticPointShadowMap";
 		pshader.shadowMap = staticTexture;
 		pshader.shadowMap = staticTexture;
 	}
 	}

+ 4 - 2
h3d/scene/Object.hx

@@ -696,7 +696,8 @@ class Object implements hxd.impl.Serializable {
 	}
 	}
 
 
 	function emitRec( ctx : RenderContext ) {
 	function emitRec( ctx : RenderContext ) {
-		if( !visible || (culled && inheritCulled) )
+
+		if( !visible || (culled && inheritCulled && !ctx.computingStatic) )
 			return;
 			return;
 
 
 		// fallback in case the object was added during a sync() event and we somehow didn't update it
 		// fallback in case the object was added during a sync() event and we somehow didn't update it
@@ -708,8 +709,9 @@ class Object implements hxd.impl.Serializable {
 			for( c in children )
 			for( c in children )
 				c.posChanged = true;
 				c.posChanged = true;
 		}
 		}
-		if( !culled )
+		if( !culled || ctx.computingStatic )
 			emit(ctx);
 			emit(ctx);
+
 		for( c in children )
 		for( c in children )
 			c.emitRec(ctx);
 			c.emitRec(ctx);
 	}
 	}

+ 1 - 1
h3d/scene/World.hx

@@ -667,7 +667,7 @@ class World extends Object {
 		super.syncRec(ctx);
 		super.syncRec(ctx);
 		// don't do in sync() since animations in our world might affect our chunks
 		// don't do in sync() since animations in our world might affect our chunks
 		for( c in allChunks ) {
 		for( c in allChunks ) {
-			c.root.visible = c.bounds.inFrustum(ctx.camera.frustum);
+			c.root.visible = ctx.computingStatic || c.bounds.inFrustum(ctx.camera.frustum);
 			if( c.root.visible ) {
 			if( c.root.visible ) {
 				c.lastFrame = ctx.frame;
 				c.lastFrame = ctx.frame;
 				initChunk(c);
 				initChunk(c);

+ 14 - 8
h3d/scene/pbr/Environment.hx

@@ -234,14 +234,20 @@ class Environment  {
 
 
 	public function compute() {
 	public function compute() {
 
 
-		lut = new h3d.mat.Texture(128, 128, [Target], RGBA16F);
-		lut.setName("irradLut");
-		diffuse = new h3d.mat.Texture(diffSize, diffSize, [Cube, Target], RGBA16F);
-		diffuse.setName("irradDiffuse");
-		specular = new h3d.mat.Texture(specSize, specSize, [Cube, Target, MipMapped, ManualMipMapGen], RGBA16F);
-		specular.setName("irradSpecular");
-		specular.mipMap = Linear;
-
+		if( lut == null ) {
+			lut = new h3d.mat.Texture(128, 128, [Target], RGBA16F);
+			lut.setName("irradLut");
+		}
+		if( diffuse == null ) {
+			diffuse = new h3d.mat.Texture(diffSize, diffSize, [Cube, Target], RGBA16F);
+			diffuse.setName("irradDiffuse");
+		}
+		if( specular == null ) {
+			specular = new h3d.mat.Texture(specSize, specSize, [Cube, Target, MipMapped, ManualMipMapGen], RGBA16F);
+			specular.setName("irradSpecular");
+			specular.mipMap = Linear;
+		}
+		
 		computeIrradLut();
 		computeIrradLut();
 		computeIrradiance();
 		computeIrradiance();
 	}
 	}