Mesh Data Particles refuses to change colour in runtime

Hi community.

In 4.17 version of UE4 we were using Mesh Data emitter for different particle systems and we were able to change colour this way:

  • take particle system component
  • get material from particle system component
  • create material instance from this material
  • change parameter of this new material instance
  • set new material instance as material for particle system component

In 4.17 everything worked great and colour were changing for all type of particle emitters, BUT in 4.19 Mesh Data emitter stopped to accept this change in runtime.
GPU sprites are fine, even Ribbon data emitter type behaves right.

Does anybody experienced this problem ? Is there a way how to force particle system component to somehow reload materials that is using ?

Any advice is very welcome :slight_smile:

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

Submitted, thank you for pointing me out. I started this thread in hope that somebody find a way to bypass this problem :slight_smile:

Thanks

For anyone who hit this same issue as me.

Official issue can be tracked here: Unreal Engine Issues and Bug Tracker (UE-59923)

If this is something you really need and issue is not fixed I have solution for you.

Open Engine\Source\Runtime\Engine\Private\Particles\ParticleEmitterInstances.cpp

and use this

void FParticleMeshEmitterInstance::Tick_MaterialOverrides(int32 EmitterIndex)
{
	// we need to do this here, since CurrentMaterials is unique to mesh emitters, so this can't be done from the component. CurrentMaterials 
	// may end up in MeshMaterials, so if this doesn't get updated, rendering may access a garbage collected material

	// make sure currentmaterials are all set to the emitter material, so we don't end up with GC'd material pointers
	// in MeshMaterials when GetMeshMaterials pushes CurrentMaterials to MeshMaterials
	if (Component && Component->EmitterMaterials.IsValidIndex(EmitterIndex))
	{
		if (Component->EmitterMaterials[EmitterIndex])
		{
			//HACK(JAKUB.HUBACEK): HACK STARTS HERE
			//NOTE(jakub.hubacek): FParticleMeshEmitterInstance partially takes in account that mesh could have more than 1 material, but then it fails to take takes default material from array of current materials 
			if (Component->EmitterMaterials[EmitterIndex])
			{
				CurrentMaterial = Component->EmitterMaterials[EmitterIndex];
			}
			//HACK(JAKUB.HUBACEK): HACK ENDS HERE

			for (UMaterialInterface *& CurMat : CurrentMaterials)
			{
				CurMat = Component->EmitterMaterials[EmitterIndex];
			}			
		}
	}	
... function continues here

where my change is within

//HACK(JAKUB.HUBACEK):
area


Have a nice day

Jakub

1 Like

Lifesaving solution. Thank you.

Hi! Did you test this solution on 4.21? I added the code as indicated but with no change ingame. The mesh particles are still not being updated with the dynamic instance applied to the emitter.