Page 1 of 1

Can't figure out MaterialEx:setTexture()

Posted: Wed Dec 31, 2014 7:24 am
by minmay
MaterialEx:setTexture(string, string)

There is a crash if the second parameter is not a valid texture asset path, so it must be the texture that will replace the existing one. So I would assume that the first parameter is the name of the texture slot to change. But I've tried everything I can think of for the first parameter and nothing has gotten a result:
"diffuseMap"
"diffuse"
"dif"
"normalMap"
"normal"
etc.
The material still shows its old textures afterwards. Does anyone know what I can enter to actually change a visible texture?

Re: Can't figure out MaterialEx:setTexture()

Posted: Wed Dec 31, 2014 10:34 am
by petri
Try g_diffuseMap, g_normalMap, etc.

Re: Can't figure out MaterialEx:setTexture()

Posted: Wed Dec 31, 2014 7:57 pm
by minmay
That still doesn't work for me. For example:

Code: Select all

defineMaterial{
	name = "test",
	diffuseMap = "assets/textures/common/white.tga",
	doubleSided = false,
	lighting = true,
	alphaTest = false,
	blendMode = "Additive",
	textureAddressMode = "Wrap",
	glossiness = 0,
	depthBias = 0,
	onUpdate = function(self, time)
		print("test")
		self:setTexture("g_diffuseMap","assets/textures/common/black.tga")
	end,
}
"test" gets printed to the console so I know the onUpdate hook is executing, and other operations like setParam, setTexcoordScaleOffset work fine. But any model given this material just stays white.

Re: Can't figure out MaterialEx:setTexture()

Posted: Wed Dec 31, 2014 8:11 pm
by petri
You're right, it doesn't work :/ This feature was never tested because it is not used by the main campaign. Added to the bug list.