Răsfoiți Sursa

MeshBatch : Fix negative scaledRadius during GPUCulling

TothBenoit 1 an în urmă
părinte
comite
1bfd91c528
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      h3d/scene/MeshBatch.hx

+ 3 - 3
h3d/scene/MeshBatch.hx

@@ -78,7 +78,7 @@ class ComputeIndirect extends hxsl.Shader {
 			var invocID = computeVar.globalInvocation.x;
 			var lod : Int = 0;
 			var pos = vec3(0) * modelView.mat3x4();
-			var vScale = vec3(1) * modelView.mat3x4() - pos;
+			var vScale = abs(vec3(1) * modelView.mat3x4() - pos);
 			var scaledRadius = max(max(vScale.x, vScale.y), vScale.z) * radius;
 			var toCam = camera.position - pos.xyz;
 			var distToCam = length(toCam);
@@ -407,7 +407,7 @@ class MeshBatch extends MultiMaterial {
 				if ( p.perObjectGlobal.gid == modelViewID ) {
 					batch.modelViewPos = pos - startPos;
 					addMatrix(worldPosition != null ? worldPosition : absPos);
-				} else if ( p.perObjectGlobal.gid == modelViewInverseID ) {				
+				} else if ( p.perObjectGlobal.gid == modelViewInverseID ) {
 					if( worldPosition == null )
 						addMatrix(getInvPos());
 					else {
@@ -421,7 +421,7 @@ class MeshBatch extends MultiMaterial {
 				} else if ( p.perObjectGlobal.gid == previousModelViewID )
 					addMatrix( worldPosition != null ? worldPosition : absPos );
 				else
-					throw "Unsupported global param "+p.perObjectGlobal.path;							
+					throw "Unsupported global param "+p.perObjectGlobal.path;
 				p = p.next;
 				continue;
 			}