Forráskód Böngészése

added UVDelta, updated UVScroll (auto scroll)

ncannasse 10 éve
szülő
commit
d263fde0a1
3 módosított fájl, 30 hozzáadás és 4 törlés
  1. 2 2
      h3d/anim/LinearAnimation.hx
  2. 18 0
      h3d/shader/UVDelta.hx
  3. 10 2
      h3d/shader/UVScroll.hx

+ 2 - 2
h3d/anim/LinearAnimation.hx

@@ -136,9 +136,9 @@ class LinearAnimation extends Animation {
 			}
 			if( o.uvs != null ) {
 				var mat = o.targetObject.toMesh().material;
-				var s = mat.mainPass.getShader(h3d.shader.UVScroll);
+				var s = mat.mainPass.getShader(h3d.shader.UVDelta);
 				if( s == null ) {
-					s = mat.mainPass.addShader(new h3d.shader.UVScroll());
+					s = mat.mainPass.addShader(new h3d.shader.UVDelta());
 					mat.texture.wrap = Repeat;
 				}
 				s.uvDelta.x = uvLerp(o.uvs[frame1 << 1],o.uvs[frame2 << 1],k2);

+ 18 - 0
h3d/shader/UVDelta.hx

@@ -0,0 +1,18 @@
+package h3d.shader;
+
+class UVDelta extends hxsl.Shader {
+
+	static var SRC = {
+		@param var uvDelta : Vec2;
+		var calculatedUV : Vec2;
+		function vertex() {
+			calculatedUV += uvDelta;
+		}
+	};
+
+	public function new( dx = 0., dy = 0. ) {
+		super();
+		uvDelta.set(dx, dy);
+	}
+
+}

+ 10 - 2
h3d/shader/UVScroll.hx

@@ -3,11 +3,19 @@ package h3d.shader;
 class UVScroll extends hxsl.Shader {
 
 	static var SRC = {
-		@param var uvDelta : Vec2;
+		@global var global : {
+			var time : Float;
+		};
+		@param var uvSpeed : Vec2;
 		var calculatedUV : Vec2;
 		function vertex() {
-			calculatedUV += uvDelta;
+			calculatedUV += uvSpeed * global.time;
 		}
 	};
 
+	public function new( vx = 0., vy = 0. ) {
+		super();
+		uvSpeed.set(vx, vy);
+	}
+
 }