# Gpu particles perfomance

**URL:** <https://forums.unrealengine.com/t/gpu-particles-perfomance/317244>\
**Category:** FX\
**Tags:** particle-systems, gpu-particles, unreal-engine, Performance, Fog-Effects, question\
**Created:** [May 2, 2015, 7:38pm UTC](https://forums.unrealengine.com/t/gpu-particles-perfomance/317244 "2015-05-02T19:38:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0e2baaa3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0e2baaa3](https://forums.unrealengine.com/u/anonymous_user_0e2baaa3)\
**Post date:** [May 2, 2015, 7:38pm UTC](https://forums.unrealengine.com/t/gpu-particles-perfomance/317244/1 "2015-05-02T19:38:46Z")

</div>

I ran into this problem when the camera is very close to the Particle Emitter FPS falls somewhere with very stable 60 to 15.  
the effect is a …

 ![41055-emiter.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/7/0771d8db3f8657f482ba31703dcddfd4243599e4.jpeg)

material for effect

 ![41057-material.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/d/4/3d4b289453ad4f349d6117f17a21e6a4b1d0870c.png)

material parameter **distance** set from code only once if **dist** value changed

```
TArray<FString> Instances;
	UMaterialInstanceDynamic* MI = nullptr;
	Instances.Empty();
	FString Path = "MaterialInstanceConstant'/Game/BillBoards/fogMaterial_Inst.fogMaterial_Inst'";
	MI = (UMaterialInstanceDynamic*)LoadObject<UMaterialInstance>(NULL, *Path);
	if (MI)
	{
		MI->Modify();
		MI->SetScalarParameterValue("distance", dist);
	}

```

---

<div class="post-metadata">

**Author:** ![mkamradt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mkamradt](https://forums.unrealengine.com/u/mkamradt)\
**Post date:** [May 4, 2015, 1:04pm UTC](https://forums.unrealengine.com/t/gpu-particles-perfomance/317244/2 "2015-05-04T13:04:07Z")

</div>

Is this your tick function? If it is, then this looks really bogus.

You are loading a material instance every tick, which is already as slow as it gets. However you are also using the UMaterialInstance as UMaterialInstanceDynamic which is not correct. Try the CastChecked() instead of a plain c-style cast to make sure you can safely cast between the two types. So basically you are modifying the source asset (MaterialInstance) and not a dynamic instance of that material.

Instead you should create a dynamic material instance during initialization (e.g. BeginPlay), keep the pointer to it and then only set the distance parameter within your tick function.

Marc

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0e2baaa3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0e2baaa3](https://forums.unrealengine.com/u/anonymous_user_0e2baaa3)\
**Post date:** [May 4, 2015, 2:06pm UTC](https://forums.unrealengine.com/t/gpu-particles-perfomance/317244/3 "2015-05-04T14:06:56Z")

</div>

partly yes, this function is called in the game 1 - 2 times.
