Hardware Rendering with Scripted Material Plugins


#1

Is this even possible? I’m just trying to restrict my artists from filling in map slots that shouldn’t be so that I can automate the export processes a bit better.

The following is my simple plugin.

plugin material PFO_StandardMaterial
name:"PFO Standard Material"
classID:#(0x378768c7, 0x63ef5281)
extends:StandardMaterial replaceUI:true version:1
(
	parameters main rollout:params
	(
		diffMap type:#texturemap ui:diffMap
		bumpMap type:#texturemap ui:bumpMap
		specMap type:#texturemap ui:specMap
		controlMap type:#texturemap ui:controlMap
		
		on diffMap set val do
		(
			delegate.diffuseMap = diffMap
		)
		
		on bumpMap set val do
		(
			delegate.bumpMap.normal_map = bumpMap
		)
		
		on specMap set val do
		(
			delegate.specularMap = specMap
		)
		
		on controlMap set val do
		(
			delegate.ambientMap = controlMap
			delegate.ambientMapEnable = false
		)
	)
	
	rollout params "PFO Standard Material"
	(
		label diffLabel "Diffuse Map" across:2 offset:[-40,0]
		mapButton diffMap "" width:180 offset:[-40,0]
		label bumpLabel "Normal Map" across:2 offset:[-40,0]
		mapButton bumpMap "" width:180 offset:[-40,0]
		label specLabel "S/G/R Map" across:2 offset:[-40,0]
		mapButton specMap "" width:180 offset:[-41,0]
		label controlLabel "Control Map" across:2 offset:[-40,0]
		mapButton controlMap "" width:180 offset:[-40,0]
	)
	
	on create do
	(
		delegate.shaderType = 1
		delegate.bumpMap = Normal_Bump()
		delegate.bumpMapAmount = 100
	)
)

In essence, I’m just remapping which slots go to what and removing the extraneous UI that gets ignored on export anyway. However, I can no longer actually view the normal mapping in 3DStudio, since it takes away my ability to turn on hardware rendering for this material. What else should I be doing?

edit: This is dumb. The material looks correct in the sample swatch, but I just can’t enable the normal maps on the viewport for some reason.


#2

Maybe you should look at using custom HLSL shaders instead of modifiying Max Shaders.

http://www.bencloward.com/tutorials_shaders1.shtml


#3

Yeah. I was trying to save some time by just putting together a scripted plugin. I have yet to make shaders for 3DStudio. While I’ve done my share of straight-up CG for Unity and other engines, doing stuff for 3DStudio seems like it requires a lot more effort, and I’m having to play catch-up during crunch time. sigh

Thanks for the link, though. I appreciate that.