Kaynağa Gözat

SinusDeform now with parameters and uses global time

ncannasse 10 yıl önce
ebeveyn
işleme
831ff7037d
1 değiştirilmiş dosya ile 10 ekleme ve 2 silme
  1. 10 2
      h3d/shader/SinusDeform.hx

+ 10 - 2
h3d/shader/SinusDeform.hx

@@ -4,16 +4,24 @@ class SinusDeform extends hxsl.Shader {
 
 	static var SRC = {
 
-		@param var time : Float;
+		@global var time : Float;
+		@param var speed : Float;
 		@param var frequency : Float;
 		@param var amplitude : Float;
 
 		var calculatedUV : Vec2;
 
 		function fragment() {
-			calculatedUV.x += sin(calculatedUV.y * frequency + time) * amplitude;
+			calculatedUV.x += sin(calculatedUV.y * frequency + time * speed) * amplitude;
 		}
 
 	};
 
+	public function new( frequency = 10., amplitude = 0.01, speed = 1. ) {
+		super();
+		this.frequency = frequency;
+		this.amplitude = amplitude;
+		this.speed = speed;
+	}
+
 }