Browse Source

ChannelTexture review

ncannasse 7 years ago
parent
commit
8cfcd3984f
7 changed files with 24 additions and 6 deletions
  1. 5 0
      h3d/impl/TextureCache.hx
  2. 10 0
      h3d/mat/Pass.hx
  3. 1 1
      hxd/prefab/Prefab.hx
  4. 3 0
      hxsl/ChannelTexture.hx
  5. 1 1
      hxsl/Macros.hx
  6. 2 2
      hxsl/Shader.hx
  7. 2 2
      hxsl/Types.hx

+ 5 - 0
h3d/impl/TextureCache.hx

@@ -55,6 +55,11 @@ class TextureCache {
 		return t;
 	}
 
+	public function allocTargetScale( name : String, scale : Float, defaultDepth=true, ?format:hxd.PixelFormat ) {
+		var e = h3d.Engine.getCurrent();
+		return allocTarget(name, Math.ceil(e.width * scale), Math.ceil(e.height * scale), defaultDepth, format);
+	}
+
 	public function dispose() {
 		for( t in cache )
 			t.dispose();

+ 10 - 0
h3d/mat/Pass.hx

@@ -108,6 +108,16 @@ class Pass implements hxd.impl.Serializable {
 		this.colorMask = (r?1:0) | (g?2:0) | (b?4:0) | (a?8:0);
 	}
 
+	public function setColorChannel( c : hxsl.Channel) {
+		switch( c ) {
+		case R: setColorMask(true, false, false, false);
+		case G: setColorMask(false, true, false, false);
+		case B: setColorMask(false, false, true, false);
+		case A: setColorMask(false, false, false, true);
+		default: throw "Unsupported channel "+c;
+		}
+	}
+
 	public function addShader<T:hxsl.Shader>(s:T) : T {
 		// throwing an exception will require NG GameServer review
 		if( s == null ) return null;

+ 1 - 1
hxd/prefab/Prefab.hx

@@ -9,7 +9,7 @@ class Prefab {
 	public var source(default, set) : String;
 	public var children(default, null) : Array<Prefab>;
 	public var enabled : Bool = true;
-	public var props : {};
+	public var props : Any;
 
 	public function new(?parent) {
 		this.parent = parent;

+ 3 - 0
hxsl/ChannelTexture.hx

@@ -0,0 +1,3 @@
+package hxsl;
+
+typedef ChannelTexture = { texture : hxsl.Types.ChannelTextureType, channel : hxsl.Channel };

+ 1 - 1
hxsl/Macros.hx

@@ -46,7 +46,7 @@ class Macros {
 			var t = makeType(t);
 			macro : Array<$t>;
 		case TChannel(_):
-			macro : hxsl.Types.ChannelTexture;
+			macro : hxsl.Types.ChannelTextureType;
 		case TFun(_):
 			throw "assert";
 		case TBuffer(_):

+ 2 - 2
hxsl/Shader.hx

@@ -76,8 +76,8 @@ class Shader {
 					c = c.next;
 					continue;
 				}
-				var v : { texture : hxsl.Types.ChannelTexture, channel : hxsl.Channel } = v;
-				var sel : hxsl.Channel = v.channel;
+				var v : hxsl.ChannelTexture = v;
+				var sel = v.channel;
 				if( v.texture == null )
 					sel = Unknown
 				else if( sel == null || sel == Unknown ) {

+ 2 - 2
hxsl/Types.hx

@@ -8,11 +8,11 @@ typedef Texture = h3d.mat.Texture;
 typedef Sampler2D = h3d.mat.Texture;
 typedef Sampler2DArray = h3d.mat.TextureArray;
 typedef SamplerCube = h3d.mat.Texture;
-typedef ChannelTexture = h3d.mat.Texture;
+typedef ChannelTextureType = h3d.mat.Texture;
 typedef Buffer = h3d.Buffer;
 
 class ChannelTools {
-	public static inline function isPackedFormat( c : ChannelTexture ) {
+	public static inline function isPackedFormat( c : ChannelTextureType ) {
 		return c.format == h3d.mat.Texture.nativeFormat;
 	}
 }