Notifications
Clear all

[Closed] Pflow – assigning Multisub material to Dynamic material

I’m trying to use a multi-sub material with a Dynamic material in pFlow.

I’ve got to animate a gradient going up a bunch of objects. I tried using a single material with an animated Gradient ramp but couldn’t get it to work so rendered out a sequence and used ‘Animated Texture’ with ‘Same As Particle ID’ along with in the material using the ‘Sync Frames to particle ages’.

This works, for one material, the gradient ramps are all offset. But now I want to use a multisub material so I can have different gradient ramps for different objects. However I don’t seem to be able to assign the multisub materials to particles.

Just for a test I’ve got 2 materials in my multi sub and i’m trying to use script to control which one is used by all the particles, at the moment it’s a random mix of material assignments to different particles.

on ChannelsUsed pCont do
(
	 pCont.useTime = true
	 pCont.useAge = true
	 pCont.useMtlIndex = true

)

on Init pCont do 
(
 
)

on Proceed pCont do 
(
	count = pCont.NumParticles() 
	for i in 1 to count do
	(
	pCont.particleIndex = i 
	pCont.particleID = 2
	pCont.setParticleMtlIndex i 2
	--print pCont.particleID
	)
)

on Release pCont do 
(
 
)

Despite setting the particle material Index and the Particle ID to 2, the particles still render with a mix of both materials being assigned to random objects…

Running short of ideas now…

1 Reply

if you want to assign Material index through Script Operator set the “Assign Material ID” parameter of Dynamic Material to OFF.

Here is a sample for MultiMaterial with 3 subs:


on ChannelsUsed pCont do 
(
	 pCont.useMtlIndex = on
)

on Proceed pCont do 
(
	for i=1 to pCont.NumParticles() do
	(
		pCont.particleIndex = i
		pCont.setParticleMtlIndex i ((mod (i-1) 3) + 1)
	)
)