Explorar o código

added Texture.clearF, fixed PointShadowMap with R16F

Nicolas Cannasse %!s(int64=5) %!d(string=hai) anos
pai
achega
c069bf4f7d
Modificáronse 2 ficheiros con 22 adicións e 2 borrados
  1. 18 0
      h3d/mat/Texture.hx
  2. 4 2
      h3d/pass/PointShadowMap.hx

+ 18 - 0
h3d/mat/Texture.hx

@@ -216,6 +216,24 @@ class Texture {
 			alloc();
 	}
 
+	public function clearF( r : Float = 0., g : Float = 0., b : Float = 0., a : Float = 0., layer = -1 ) {
+		alloc();
+		if( !flags.has(Target) ) throw "Texture should be target";
+		var engine = h3d.Engine.getCurrent();
+		var color = new h3d.Vector(r,g,b,a);
+		if( layer < 0 ) {
+			for( i in 0...layerCount ) {
+				engine.pushTarget(this, i);
+				engine.clearF(color);
+				engine.popTarget();
+			}
+		} else {
+			engine.pushTarget(this, layer);
+			engine.clearF(color);
+			engine.popTarget();
+		}
+	}
+
 	public function clear( color : Int, alpha = 1., ?layer = -1 ) {
 		alloc();
 		if( #if (usegl || hlsdl || js) true #else flags.has(Target) #end && (width != 1 || height != 1) ) {

+ 4 - 2
h3d/pass/PointShadowMap.hx

@@ -141,8 +141,10 @@ class PointShadowMap extends Shadows {
 		if( tmpTex != null) return tmpTex;
 		tmpTex = new h3d.mat.Texture(1,1, [Target,Cube], format);
 		tmpTex.name = "defaultCubeShadowMap";
-		for(i in 0 ... 6)
-			tmpTex.clear(0xFFFFFF, i);
+		if( format == RGBA )
+			tmpTex.clear(0xFFFFFF);
+		else
+			tmpTex.clearF(1);
 		return tmpTex;
 	}