浏览代码

added default texture unpacking

ncannasse 7 年之前
父节点
当前提交
93f4697d24
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      h3d/shader/pbr/PropsTexture.hx

+ 23 - 0
h3d/shader/pbr/PropsTexture.hx

@@ -0,0 +1,23 @@
+package h3d.shader.pbr;
+
+class PropsTexture extends hxsl.Shader {
+	static var SRC = {
+		@param var texture : Sampler2D;
+		var output : {
+			metalness : Float,
+			roughness : Float,
+			occlusion : Float,
+		};
+		var calculatedUV : Vec2;
+		function fragment() {
+			var v = texture.get(calculatedUV);
+			output.metalness = v.r;
+			output.roughness = 1 - v.g * v.g;
+			output.occlusion = v.b;
+		}
+	}
+	public function new(?t) {
+		super();
+		this.texture = t;
+	}
+}