Explorar o código

- Add frustum culling for pointlights

ShiroSmith %!s(int64=7) %!d(string=hai) anos
pai
achega
c68e9542e4
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      h3d/scene/pbr/PointLight.hx

+ 5 - 1
h3d/scene/pbr/PointLight.hx

@@ -43,7 +43,11 @@ class PointLight extends Light {
 		pbr.invLightRange4 = 1 / (range * range * range * range);
 		pbr.pointSize = size;
 
-		super.emit(ctx);
+		// Frustum Culling
+		var sphereVolume = new h3d.col.Sphere();
+		sphereVolume.r = this.range;
+		if(ctx.camera.getFrustum().hasSphere( sphereVolume))
+			super.emit(ctx);
 	}
 
 }