Sfoglia il codice sorgente

merge material/meshmaterial

Nicolas Cannnasse 8 anni fa
parent
commit
cef5b87d85

+ 95 - 0
h3d/mat/BaseMaterial.hx

@@ -0,0 +1,95 @@
+package h3d.mat;
+import h3d.mat.Data;
+import h3d.mat.Pass;
+
+class BaseMaterial {
+
+	var passes : Pass;
+	public var name : String;
+	public var mainPass(get, never) : Pass;
+
+	public var props(default,set) : MaterialProps;
+
+	public function new(?shader:hxsl.Shader) {
+		if( shader != null )
+			addPass(new Pass("default",null)).addShader(shader);
+	}
+
+	function set_props(p) {
+		this.props = p;
+		if( p != null ) p.apply(this);
+		return p;
+	}
+
+	public function addPass<T:Pass>( p : T ) : T {
+		var prev = null, cur = passes;
+		while( cur != null ) {
+			prev = cur;
+			cur = cur.nextPass;
+		}
+		if( prev == null )
+			passes = p;
+		else
+			prev.nextPass = p;
+		p.nextPass = null;
+		return p;
+	}
+
+	public function removePass( p : Pass ) {
+		var prev : Pass = null, cur = passes;
+		while( cur != null ) {
+			if( cur == p ) {
+				if( prev == null )
+					passes = p.nextPass;
+				else
+					prev.nextPass = p.nextPass;
+				p.nextPass = null;
+				return true;
+			}
+			prev = cur;
+			cur = cur.nextPass;
+		}
+		return false;
+	}
+
+	inline function get_mainPass() {
+		return passes;
+	}
+
+	public function getPasses() {
+		var p = passes;
+		var out = [];
+		while( p != null ) {
+			out.push(p);
+			p = p.nextPass;
+		}
+		return out.iterator();
+	}
+
+	public function getPass( name : String ) : Pass {
+		var p = passes;
+		while( p != null ) {
+			if( p.name == name )
+				return p;
+			p = p.nextPass;
+		}
+		return null;
+	}
+
+	public function allocPass( name : String, ?inheritMain = true ) : Pass {
+		var p = getPass(name);
+		if( p != null ) return p;
+		var p = new Pass(name, null, inheritMain ? mainPass : null);
+		addPass(p);
+		return p;
+	}
+
+	public function clone( ?m : BaseMaterial ) : BaseMaterial {
+		if( m == null ) m = new BaseMaterial();
+		m.mainPass.loadProps(mainPass);
+		// DO NOT clone passes (it's up to the superclass to recreate the passes + shaders)
+		m.name = name;
+		return m;
+	}
+
+}

+ 4 - 28
h3d/mat/DefaultMaterialProps.hx

@@ -8,27 +8,18 @@ enum MaterialKind {
 	SoftAdd;
 	SoftAdd;
 }
 }
 
 
-enum ShadowsMode {
-	None;
-	Active;
-	CastOnly;
-	ReceiveOnly;
-}
-
 @:structInit
 @:structInit
 class DefaultMaterialProps {
 class DefaultMaterialProps {
 
 
 	public var kind(default,null) : MaterialKind;
 	public var kind(default,null) : MaterialKind;
-	public var shadows(default, null) : ShadowsMode;
 	public var cull(default, null) : Bool;
 	public var cull(default, null) : Bool;
 
 
-	public function new( ?kind : MaterialKind, ?shadows : ShadowsMode, ?cull : Bool ) {
+	public function new( ?kind : MaterialKind, ?cull : Bool ) {
 		this.kind = kind == null ? Opaque : kind;
 		this.kind = kind == null ? Opaque : kind;
-		this.shadows = shadows == null ? Active : shadows;
 		this.cull = cull == null ? true : cull;
 		this.cull = cull == null ? true : cull;
 	}
 	}
 
 
-	public function apply( m : Material ) {
+	public function apply( m : BaseMaterial ) {
 		var mainPass = m.mainPass;
 		var mainPass = m.mainPass;
 		switch( kind ) {
 		switch( kind ) {
 		case Opaque, AlphaKill:
 		case Opaque, AlphaKill:
@@ -53,36 +44,22 @@ class DefaultMaterialProps {
 			tshader.killAlpha = kind == AlphaKill;
 			tshader.killAlpha = kind == AlphaKill;
 			tshader.killAlphaThreshold = 0.5;
 			tshader.killAlphaThreshold = 0.5;
 		}
 		}
-		switch( shadows ) {
-		case None:
-			m.shadows = false;
-		case Active:
-			m.shadows = true;
-		case CastOnly:
-			m.castShadows = true;
-			m.receiveShadows = false;
-		case ReceiveOnly:
-			m.castShadows = false;
-			m.receiveShadows = true;
-		}
 		mainPass.culling = cull ? Back : None;
 		mainPass.culling = cull ? Back : None;
 	}
 	}
 
 
 	public function inspect( onChange : Void -> Void ) : Array<hxd.inspect.Property> {
 	public function inspect( onChange : Void -> Void ) : Array<hxd.inspect.Property> {
 		return [
 		return [
 			PEnum("kind", MaterialKind, function() return kind, function(v) { kind = v; onChange(); }),
 			PEnum("kind", MaterialKind, function() return kind, function(v) { kind = v; onChange(); }),
-			PEnum("shadows", ShadowsMode, function() return shadows, function(v) { shadows = v; onChange(); }),
 			PBool("cull", function() return cull, function(v) { cull = v; onChange(); }),
 			PBool("cull", function() return cull, function(v) { cull = v; onChange(); }),
 		];
 		];
 	}
 	}
 
 
 	public function getData() : Dynamic {
 	public function getData() : Dynamic {
-		return { kind : kind.getName(), shadows : shadows.getName(), cull : cull };
+		return { kind : kind.getName(), cull : cull };
 	}
 	}
 
 
 	public function loadData( o : Dynamic ) {
 	public function loadData( o : Dynamic ) {
 		kind = MaterialKind.createByName(o.kind);
 		kind = MaterialKind.createByName(o.kind);
-		shadows = ShadowsMode.createByName(o.shadows);
 		cull = o.cull;
 		cull = o.cull;
 	}
 	}
 
 
@@ -90,11 +67,10 @@ class DefaultMaterialProps {
 	#if (haxe_ver < 3.3)
 	#if (haxe_ver < 3.3)
 		var m = new DefaultMaterialProps();
 		var m = new DefaultMaterialProps();
 		m.kind = Alpha;
 		m.kind = Alpha;
-		m.shadows = None;
 		m.cull = false;
 		m.cull = false;
 		return m;
 		return m;
 	#else
 	#else
-		return { kind : Alpha, shadows : None, cull : false }
+		return { kind : Alpha, cull : false }
 	#end
 	#end
 	}
 	}
 
 

+ 116 - 82
h3d/mat/Material.hx

@@ -1,104 +1,52 @@
 package h3d.mat;
 package h3d.mat;
-import h3d.mat.Data;
-import h3d.mat.Pass;
 
 
-class Material {
+class Material extends BaseMaterial {
 
 
-	var passes : Pass;
-	public var name : String;
-	public var mainPass(get, never) : Pass;
-
-	public var props(default,set) : MaterialProps;
+	var mshader : h3d.shader.BaseMesh;
 
 
 	public var shadows(get, set) : Bool;
 	public var shadows(get, set) : Bool;
 	public var castShadows(default, set) : Bool;
 	public var castShadows(default, set) : Bool;
 	public var receiveShadows(default, set) : Bool;
 	public var receiveShadows(default, set) : Bool;
 
 
-	public function new(?shader:hxsl.Shader) {
-		if( shader != null )
-			addPass(new Pass("default",null)).addShader(shader);
+	public var textureShader(default, null) : h3d.shader.Texture;
+	public var specularShader(default, null) : h3d.shader.SpecularTexture;
+	public var texture(get, set) : h3d.mat.Texture;
+	public var specularTexture(get,set) : h3d.mat.Texture;
+
+	public var color(get, set) : Vector;
+	public var specularAmount(get, set) : Float;
+	public var specularPower(get, set) : Float;
+	public var blendMode(default, set) : BlendMode;
+
+	public function new(?texture) {
+		mshader = new h3d.shader.BaseMesh();
+		blendMode = None;
+		super(mshader);
+		this.texture = texture;
 	}
 	}
 
 
-	function set_props(p) {
-		this.props = p;
-		if( p != null ) p.apply(this);
-		return p;
+	inline function get_specularPower() {
+		return mshader.specularPower;
 	}
 	}
 
 
-	public function addPass<T:Pass>( p : T ) : T {
-		var prev = null, cur = passes;
-		while( cur != null ) {
-			prev = cur;
-			cur = cur.nextPass;
-		}
-		if( prev == null )
-			passes = p;
-		else
-			prev.nextPass = p;
-		p.nextPass = null;
-		return p;
-	}
-
-	public function removePass( p : Pass ) {
-		var prev : Pass = null, cur = passes;
-		while( cur != null ) {
-			if( cur == p ) {
-				if( prev == null )
-					passes = p.nextPass;
-				else
-					prev.nextPass = p.nextPass;
-				p.nextPass = null;
-				return true;
-			}
-			prev = cur;
-			cur = cur.nextPass;
-		}
-		return false;
+	inline function set_specularPower(v) {
+		return mshader.specularPower = v;
 	}
 	}
 
 
-	inline function get_mainPass() {
-		return passes;
+	inline function get_specularAmount() {
+		return mshader.specularAmount;
 	}
 	}
 
 
-	public function getPasses() {
-		var p = passes;
-		var out = [];
-		while( p != null ) {
-			out.push(p);
-			p = p.nextPass;
-		}
-		return out.iterator();
-	}
-
-	public function getPass( name : String ) : Pass {
-		var p = passes;
-		while( p != null ) {
-			if( p.name == name )
-				return p;
-			p = p.nextPass;
-		}
-		return null;
+	inline function set_specularAmount(v) {
+		return mshader.specularAmount = v;
 	}
 	}
 
 
-	public function allocPass( name : String, ?inheritMain = true ) : Pass {
-		var p = getPass(name);
-		if( p != null ) return p;
-		var p = new Pass(name, null, inheritMain ? mainPass : null);
-		addPass(p);
-		return p;
+	inline function get_color() {
+		return mshader.color;
 	}
 	}
 
 
-	public function clone( ?m : Material ) : Material {
-		if( m == null ) m = new Material();
-		#if debug
-		if( Type.getClass(m) != Type.getClass(this) ) throw this + " is missing clone()";
-		#end
-		m.mainPass.loadProps(mainPass);
-		// DO NOT clone passes (it's up to the superclass to recreate the passes + shaders)
-		m.castShadows = castShadows;
-		m.receiveShadows = receiveShadows;
-		m.name = name;
-		return m;
+	inline function set_color(v) {
+		return mshader.color = v;
 	}
 	}
 
 
 	inline function get_shadows() {
 	inline function get_shadows() {
@@ -132,4 +80,90 @@ class Material {
 		return receiveShadows = v;
 		return receiveShadows = v;
 	}
 	}
 
 
-}
+	override function clone( ?m : BaseMaterial ) : BaseMaterial {
+		var m = m == null ? new Material() : cast m;
+		super.clone(m);
+		m.castShadows = castShadows;
+		m.receiveShadows = receiveShadows;
+		m.texture = texture;
+		if( textureShader != null ) {
+			m.textureShader.additive = textureShader.additive;
+			m.textureShader.killAlpha = textureShader.killAlpha;
+			m.textureShader.killAlphaThreshold = textureShader.killAlphaThreshold;
+		}
+		m.color = color;
+		m.blendMode = blendMode;
+		return m;
+	}
+
+	function set_blendMode(v:BlendMode) {
+		if( mainPass != null ) {
+			mainPass.setBlendMode(v);
+			switch( v ) {
+			case None:
+				mainPass.depthWrite = true;
+				mainPass.setPassName("default");
+			case Alpha:
+				mainPass.depthWrite = true;
+				mainPass.setPassName("alpha");
+			case Add:
+				mainPass.depthWrite = false;
+				mainPass.setPassName("additive");
+			case SoftAdd:
+				mainPass.depthWrite = false;
+				mainPass.setPassName("additive");
+			case Multiply:
+				mainPass.depthWrite = false;
+				mainPass.setPassName("additive");
+			case Erase:
+				mainPass.depthWrite = false;
+				mainPass.setPassName("additive");
+			case Screen:
+				mainPass.depthWrite = false;
+				mainPass.setPassName("additive");
+			}
+		}
+		return blendMode = v;
+	}
+
+	function get_specularTexture() {
+		return specularShader == null ? null : specularShader.texture;
+	}
+
+	function get_texture() {
+		return textureShader == null ? null : textureShader.texture;
+	}
+
+	function set_texture(t) {
+		if( t == null ) {
+			if( textureShader != null ) {
+				mainPass.removeShader(textureShader);
+				textureShader = null;
+			}
+		} else {
+			if( textureShader == null ) {
+				textureShader = new h3d.shader.Texture();
+				mainPass.addShader(textureShader);
+			}
+			textureShader.texture = t;
+		}
+		return t;
+	}
+
+	function set_specularTexture(t) {
+		if( t == null ) {
+			if( specularShader != null ) {
+				mainPass.removeShader(specularShader);
+				specularShader = null;
+			}
+		} else {
+			if( specularShader == null ) {
+				specularShader = new h3d.shader.SpecularTexture();
+				mainPass.addShader(specularShader);
+			}
+			specularShader.texture = t;
+		}
+		return t;
+	}
+
+}

+ 0 - 131
h3d/mat/MeshMaterial.hx

@@ -1,131 +0,0 @@
-package h3d.mat;
-
-class MeshMaterial extends Material {
-
-	var mshader : h3d.shader.BaseMesh;
-	public var textureShader(default, null) : h3d.shader.Texture;
-	public var specularShader(default, null) : h3d.shader.SpecularTexture;
-	public var texture(get, set) : h3d.mat.Texture;
-	public var specularTexture(get,set) : h3d.mat.Texture;
-
-	public var color(get, set) : Vector;
-	public var specularAmount(get, set) : Float;
-	public var specularPower(get, set) : Float;
-	public var blendMode(default, set) : BlendMode;
-
-	public function new(?texture) {
-		mshader = new h3d.shader.BaseMesh();
-		blendMode = None;
-		super(mshader);
-		this.texture = texture;
-	}
-
-	inline function get_specularPower() {
-		return mshader.specularPower;
-	}
-
-	inline function set_specularPower(v) {
-		return mshader.specularPower = v;
-	}
-
-	inline function get_specularAmount() {
-		return mshader.specularAmount;
-	}
-
-	inline function set_specularAmount(v) {
-		return mshader.specularAmount = v;
-	}
-
-	inline function get_color() {
-		return mshader.color;
-	}
-
-	inline function set_color(v) {
-		return mshader.color = v;
-	}
-
-	override function clone( ?m : Material ) : Material {
-		var m = m == null ? new MeshMaterial() : cast m;
-		super.clone(m);
-		m.texture = texture;
-		if( textureShader != null ) {
-			m.textureShader.additive = textureShader.additive;
-			m.textureShader.killAlpha = textureShader.killAlpha;
-			m.textureShader.killAlphaThreshold = textureShader.killAlphaThreshold;
-		}
-		m.color = color;
-		m.blendMode = blendMode;
-		return m;
-	}
-
-	function set_blendMode(v:BlendMode) {
-		if( mainPass != null ) {
-			mainPass.setBlendMode(v);
-			switch( v ) {
-			case None:
-				mainPass.depthWrite = true;
-				mainPass.setPassName("default");
-			case Alpha:
-				mainPass.depthWrite = true;
-				mainPass.setPassName("alpha");
-			case Add:
-				mainPass.depthWrite = false;
-				mainPass.setPassName("additive");
-			case SoftAdd:
-				mainPass.depthWrite = false;
-				mainPass.setPassName("additive");
-			case Multiply:
-				mainPass.depthWrite = false;
-				mainPass.setPassName("additive");
-			case Erase:
-				mainPass.depthWrite = false;
-				mainPass.setPassName("additive");
-			case Screen:
-				mainPass.depthWrite = false;
-				mainPass.setPassName("additive");
-			}
-		}
-		return blendMode = v;
-	}
-
-	function get_specularTexture() {
-		return specularShader == null ? null : specularShader.texture;
-	}
-
-	function get_texture() {
-		return textureShader == null ? null : textureShader.texture;
-	}
-
-	function set_texture(t) {
-		if( t == null ) {
-			if( textureShader != null ) {
-				mainPass.removeShader(textureShader);
-				textureShader = null;
-			}
-		} else {
-			if( textureShader == null ) {
-				textureShader = new h3d.shader.Texture();
-				mainPass.addShader(textureShader);
-			}
-			textureShader.texture = t;
-		}
-		return t;
-	}
-
-	function set_specularTexture(t) {
-		if( t == null ) {
-			if( specularShader != null ) {
-				mainPass.removeShader(specularShader);
-				specularShader = null;
-			}
-		} else {
-			if( specularShader == null ) {
-				specularShader = new h3d.shader.SpecularTexture();
-				mainPass.addShader(specularShader);
-			}
-			specularShader.texture = t;
-		}
-		return t;
-	}
-
-}

+ 1 - 1
h3d/mat/Pass.hx

@@ -1,7 +1,7 @@
 package h3d.mat;
 package h3d.mat;
 import h3d.mat.Data;
 import h3d.mat.Data;
 
 
-@:allow(h3d.mat.Material)
+@:allow(h3d.mat.BaseMaterial)
 @:build(hxd.impl.BitsBuilder.build())
 @:build(hxd.impl.BitsBuilder.build())
 class Pass {
 class Pass {
 
 

+ 2 - 2
h3d/parts/GpuParticles.hx

@@ -449,11 +449,11 @@ class GpuParticles extends h3d.scene.MultiMaterial {
 			volumeBounds = h3d.col.Bounds.fromValues(o.bounds[0] - o.bounds[3] * 0.5, o.bounds[1] - o.bounds[4] * 0.5, o.bounds[2] - o.bounds[5] * 0.5, o.bounds[3], o.bounds[4], o.bounds[5]);
 			volumeBounds = h3d.col.Bounds.fromValues(o.bounds[0] - o.bounds[3] * 0.5, o.bounds[1] - o.bounds[4] * 0.5, o.bounds[2] - o.bounds[5] * 0.5, o.bounds[3], o.bounds[4], o.bounds[5]);
 	}
 	}
 
 
-	public function addGroup( ?g : GpuPartGroup, ?material : h3d.mat.MeshMaterial, ?index ) {
+	public function addGroup( ?g : GpuPartGroup, ?material : h3d.mat.Material, ?index ) {
 		if( g == null )
 		if( g == null )
 			g = new GpuPartGroup();
 			g = new GpuPartGroup();
 		if( material == null ) {
 		if( material == null ) {
-			material = new h3d.mat.MeshMaterial();
+			material = new h3d.mat.Material();
 			material.mainPass.culling = None;
 			material.mainPass.culling = None;
 			material.mainPass.depthWrite = false;
 			material.mainPass.depthWrite = false;
 			material.blendMode = Alpha;
 			material.blendMode = Alpha;

+ 2 - 2
h3d/prim/ModelCache.hx

@@ -33,7 +33,7 @@ class ModelCache {
 	public function loadModel( res : hxd.res.Model ) : h3d.scene.Object {
 	public function loadModel( res : hxd.res.Model ) : h3d.scene.Object {
 		var obj = loadLibrary(res).makeObject(loadTexture.bind(res));
 		var obj = loadLibrary(res).makeObject(loadTexture.bind(res));
 		for( m in obj.getMaterials() )
 		for( m in obj.getMaterials() )
-			initMaterial(res, Std.instance(m, h3d.mat.MeshMaterial));
+			initMaterial(res, Std.instance(m, h3d.mat.Material));
 		return obj;
 		return obj;
 	}
 	}
 
 
@@ -76,7 +76,7 @@ class ModelCache {
 	/**
 	/**
 		This can be overriden by subclasses in order to customize material setup depending on your game semantics
 		This can be overriden by subclasses in order to customize material setup depending on your game semantics
 	**/
 	**/
-	public function initMaterial( model : hxd.res.Model, material : h3d.mat.MeshMaterial ) {
+	public function initMaterial( model : hxd.res.Model, material : h3d.mat.Material ) {
 		material.mainPass.enableLights = true;
 		material.mainPass.enableLights = true;
 		material.shadows = true;
 		material.shadows = true;
 	}
 	}

+ 2 - 2
h3d/scene/Mesh.hx

@@ -3,12 +3,12 @@ package h3d.scene;
 class Mesh extends Object {
 class Mesh extends Object {
 
 
 	public var primitive : h3d.prim.Primitive;
 	public var primitive : h3d.prim.Primitive;
-	public var material : h3d.mat.MeshMaterial;
+	public var material : h3d.mat.Material;
 
 
 	public function new( prim, ?mat, ?parent ) {
 	public function new( prim, ?mat, ?parent ) {
 		super(parent);
 		super(parent);
 		this.primitive = prim;
 		this.primitive = prim;
-		if( mat == null ) mat = new h3d.mat.MeshMaterial(null);
+		if( mat == null ) mat = new h3d.mat.Material(null);
 		this.material = mat;
 		this.material = mat;
 	}
 	}
 
 

+ 1 - 1
h3d/scene/MultiMaterial.hx

@@ -2,7 +2,7 @@ package h3d.scene;
 
 
 class MultiMaterial extends Mesh {
 class MultiMaterial extends Mesh {
 
 
-	public var materials : Array<h3d.mat.MeshMaterial>;
+	public var materials : Array<h3d.mat.Material>;
 
 
 	public function new( prim, ?mats, ?parent ) {
 	public function new( prim, ?mats, ?parent ) {
 		super(prim, mats == null ? null : mats[0], parent);
 		super(prim, mats == null ? null : mats[0], parent);

+ 3 - 3
hxd/fmt/fbx/Library.hx

@@ -4,7 +4,7 @@ using hxd.fmt.fbx.Data;
 class Library extends BaseLibrary {
 class Library extends BaseLibrary {
 
 
 
 
-	public function makeObject( ?textureLoader : String -> FbxNode -> h3d.mat.MeshMaterial ) : h3d.scene.Object {
+	public function makeObject( ?textureLoader : String -> FbxNode -> h3d.mat.Material ) : h3d.scene.Object {
 		var scene = new h3d.scene.Object();
 		var scene = new h3d.scene.Object();
 		var hgeom = new Map();
 		var hgeom = new Map();
 		var hskins = new Map();
 		var hskins = new Map();
@@ -14,7 +14,7 @@ class Library extends BaseLibrary {
 			textureLoader = function(_,_) {
 			textureLoader = function(_,_) {
 				if( tmpTex == null )
 				if( tmpTex == null )
 					tmpTex = h3d.mat.Texture.fromColor(0xFF00FF);
 					tmpTex = h3d.mat.Texture.fromColor(0xFF00FF);
-				return new h3d.mat.MeshMaterial(tmpTex);
+				return new h3d.mat.Material(tmpTex);
 			}
 			}
 		}
 		}
 
 
@@ -57,7 +57,7 @@ class Library extends BaseLibrary {
 				while( tmats.length > lastAdded )
 				while( tmats.length > lastAdded )
 					tmats.pop();
 					tmats.pop();
 				if( tmats.length == 0 )
 				if( tmats.length == 0 )
-					tmats.push(new h3d.mat.MeshMaterial(h3d.mat.Texture.fromColor(0xFF00FF)));
+					tmats.push(new h3d.mat.Material(h3d.mat.Texture.fromColor(0xFF00FF)));
 				// create object
 				// create object
 				if( tmats.length == 1 )
 				if( tmats.length == 1 )
 					o.obj = new h3d.scene.Mesh(prim, tmats[0], scene);
 					o.obj = new h3d.scene.Mesh(prim, tmats[0], scene);

+ 1 - 1
hxd/fmt/hmd/Library.hx

@@ -256,7 +256,7 @@ class Library {
 
 
 	function makeMaterial( model : Model, mid : Int, loadTexture : String -> h3d.mat.Texture ) {
 	function makeMaterial( model : Model, mid : Int, loadTexture : String -> h3d.mat.Texture ) {
 		var m = header.materials[mid];
 		var m = header.materials[mid];
-		var mat = new h3d.mat.MeshMaterial();
+		var mat = new h3d.mat.Material();
 		mat.name = m.name;
 		mat.name = m.name;
 		if( m.diffuseTexture != null ) {
 		if( m.diffuseTexture != null ) {
 			mat.texture = loadTexture(m.diffuseTexture);
 			mat.texture = loadTexture(m.diffuseTexture);

+ 2 - 2
samples/Base3D.hx

@@ -27,13 +27,13 @@ class Base3D extends hxd.App {
 		var tex = hxd.Res.hxlogo.toTexture();
 		var tex = hxd.Res.hxlogo.toTexture();
 
 
 		// create a material with this texture
 		// create a material with this texture
-		var mat = new h3d.mat.MeshMaterial(tex);
+		var mat = new h3d.mat.Material(tex);
 
 
 		// our first cube mesh on the 3D scene with our created material
 		// our first cube mesh on the 3D scene with our created material
 		obj1 = new Mesh(prim, mat, s3d);
 		obj1 = new Mesh(prim, mat, s3d);
 
 
 		// creates another cube, this time with no texture
 		// creates another cube, this time with no texture
-		obj2 = new Mesh(prim, new h3d.mat.MeshMaterial(), s3d);
+		obj2 = new Mesh(prim, new h3d.mat.Material(), s3d);
 
 
 		// set the second cube color
 		// set the second cube color
 		obj2.material.color.setColor(0xFFB280);
 		obj2.material.color.setColor(0xFFB280);

+ 1 - 1
samples/Sao.hx

@@ -54,7 +54,7 @@ class Sao extends SampleApp {
 	var wscale = 1.;
 	var wscale = 1.;
 	var renderer : CustomRenderer;
 	var renderer : CustomRenderer;
 
 
-	function initMaterial( m : h3d.mat.MeshMaterial ) {
+	function initMaterial( m : h3d.mat.Material ) {
 		m.mainPass.enableLights = true;
 		m.mainPass.enableLights = true;
 		if( !Std.instance(s3d.renderer,CustomRenderer).hasMRT ) {
 		if( !Std.instance(s3d.renderer,CustomRenderer).hasMRT ) {
 			m.addPass(new h3d.mat.Pass("depth", m.mainPass));
 			m.addPass(new h3d.mat.Pass("depth", m.mainPass));

+ 2 - 2
samples/Stencil.hx

@@ -17,12 +17,12 @@ class Stencil extends hxd.App {
 		var tex = hxd.Res.hxlogo.toTexture();
 		var tex = hxd.Res.hxlogo.toTexture();
 
 
 		{	// create the top cube
 		{	// create the top cube
-			var obj = new Mesh(prim, new h3d.mat.MeshMaterial(tex), root);
+			var obj = new Mesh(prim, new h3d.mat.Material(tex), root);
 			obj.material.mainPass.enableLights = true;
 			obj.material.mainPass.enableLights = true;
 		}
 		}
 
 
 		{	// create the cube reflection
 		{	// create the cube reflection
-			var obj = new Mesh(prim, new h3d.mat.MeshMaterial(tex), root);
+			var obj = new Mesh(prim, new h3d.mat.Material(tex), root);
 			obj.scaleZ = -1;
 			obj.scaleZ = -1;
 			obj.material.color.setColor(0x55C8FF);
 			obj.material.color.setColor(0x55C8FF);
 
 

+ 1 - 1
tools/fbx/TreeView.hx

@@ -435,7 +435,7 @@ class TreeView
 
 
 class TreeMaterial extends TreeView {
 class TreeMaterial extends TreeView {
 
 
-	var mat : h3d.mat.MeshMaterial;
+	var mat : h3d.mat.Material;
 
 
 	public function new(o, parent, mat) {
 	public function new(o, parent, mat) {
 		this.mat = mat;
 		this.mat = mat;

+ 4 - 4
tools/fbx/Viewer.hx

@@ -262,7 +262,7 @@ class Viewer extends hxd.App {
 	function textureLoader( textureName : String, matData : FbxNode ) {
 	function textureLoader( textureName : String, matData : FbxNode ) {
 		var t = new h3d.mat.Texture(1, 1);
 		var t = new h3d.mat.Texture(1, 1);
 		t.clear(0xFF0000);
 		t.clear(0xFF0000);
-		var mat = new h3d.mat.MeshMaterial(t);
+		var mat = new h3d.mat.Material(t);
 		loadTexture(textureName, mat);
 		loadTexture(textureName, mat);
 		mat.mainPass.getShader(h3d.shader.Texture).killAlpha = true;
 		mat.mainPass.getShader(h3d.shader.Texture).killAlpha = true;
 		mat.mainPass.blend(SrcAlpha, OneMinusSrcAlpha);
 		mat.mainPass.blend(SrcAlpha, OneMinusSrcAlpha);
@@ -274,7 +274,7 @@ class Viewer extends hxd.App {
 		return mat;
 		return mat;
 	}
 	}
 
 
-	function loadTexture( textureName : String, mat : h3d.mat.MeshMaterial, handleAlpha = true ) {
+	function loadTexture( textureName : String, mat : h3d.mat.Material, handleAlpha = true ) {
 		var t = mat.texture;
 		var t = mat.texture;
 		var texBasePath = textureName.split("\\").join("/").split("/");
 		var texBasePath = textureName.split("\\").join("/").split("/");
 		var fileBasePath = props.curFile.split("\\").join("/").split("/");
 		var fileBasePath = props.curFile.split("\\").join("/").split("/");
@@ -386,7 +386,7 @@ class Viewer extends hxd.App {
 				t.clear(0xFF00FF);
 				t.clear(0xFF00FF);
 				t.wrap = Repeat;
 				t.wrap = Repeat;
 				t.setName(name);
 				t.setName(name);
-				loadTexture(name, new h3d.mat.MeshMaterial(t));
+				loadTexture(name, new h3d.mat.Material(t));
 				return t;
 				return t;
 			});
 			});
 
 
@@ -438,7 +438,7 @@ class Viewer extends hxd.App {
 			// auto hide meshes with special names
 			// auto hide meshes with special names
 			if( o.name != null && (o.name.toLowerCase().indexOf("selection") != -1 || o.name.toLowerCase().indexOf("collide") != -1) ) {
 			if( o.name != null && (o.name.toLowerCase().indexOf("selection") != -1 || o.name.toLowerCase().indexOf("collide") != -1) ) {
 				var mats = o.getMaterials();
 				var mats = o.getMaterials();
-				if( o.numChildren == 0 && mats.length == 1 && Std.instance(mats[0], h3d.mat.MeshMaterial).texture == null )
+				if( o.numChildren == 0 && mats.length == 1 && Std.instance(mats[0], h3d.mat.Material).texture == null )
 					o.visible = false;
 					o.visible = false;
 			}
 			}