UE4/Class PopcornFXAttributeSampler

From PopcornFX
Jump to: navigation, search
UE4-logo-g.png

(last edit version: v1.0.0-preview-8)


Class PopcornFXAttributeSampler

An attribute sampler is a particle sampler exposed in the attribute list. It can used in SpawnerScripts and can be overridden in Unreal Engine 4.


In PopcornFX Editor

To expose a Particle Sampler as an Attribute, create your Particle Sampler in the Attribute Samplers folder.

Ue-attrsampler-pk.png


Attribute Sampler Types

Shapes

Ue-attrsampler-steps.png


  • 1: Spawn a new PopcornFX Attribute Sampler Actor in the level
  • 2: Attach it (dragndrop) to your effect emitter
  • 3: Setup the Attribute Sampler
  • 4: Set PopcornFXEmitter's attribute sampler to your Attribute Sampler Actor

Note: You need to restart the emitter after changing attribute sampler properties.


About "Use Relative Transforms"

if enabled, the transforms of the attribute sampler will be relative to the parent Actor, so it can be used in the SpawnerScript's Eval() function.

if disabled, the world transforms will be used, it is meant to be used in the SpawnerScript's PostEval() function.


Static Meshes

Ue-attrsampler-mesh.png

Static mesh needs to build a cache, see Static Mesh Codec.


Skinned Mesh

The skinned mesh attribute sampler allow you to sample Skinned meshes (USkeletalMeshComponent, UDestructibleComponent).

Ue-skinned-mesh.gif

Each frame, this attribute sampler will start to skin vertex positions, normals, tangents (if requested) on the CPU asynchronously as soon as possible (right after each component's update their bones) so that the skinning itself doesn't consume GameThread time.

Different streams can be accessed from an effect, such as:

  • Positions
  • Normals
  • Tangents
  • Colors
  • UVs
  • Surface velocities (!= Bone velocity)

By default, skinned mesh attribute samplers are setup to only skin vertex positions. This is done so by default they don't consume much CPU time and memory.

Hints

  • Don't enable all streams by default, try to only enable those that your effects would need to avoid consuming too much CPU time / memory.
  • Hiding/Unhiding bones is not costless, we need to rebuild acceleration structures each time you do so, to keep correct distribution over the mesh. Try to batch "HideBoneByName" together in the same frame.
  • If you hide/unhide bones of the skinned mesh (or you sample a DestructibleComponent), make sure you have at least bSkinPositions checked, so that the attribute sampler can refresh its "sampling distribution table".

Curves

The curve attribute sampler allow you to sample Unreal Engine Curves (FCurveFloat, FCurveVector, FCurveLinearColor).


Ue-attrsampler-curve.png


  • Create your curve asset (Create -> Miscellaneous -> Curve)
  • Drag & drop a PopcornFXAttributeSamplerActor in your level and assign it to your effect as shown above
  • Set the Sampler Component Type value to Curve
  • Set the Curve Dimension value (Warning : this field must match the default attribute's curve dimension)
  • Check Is Double Curve if necessary
  • Assign your asset(s), depending on Is Double Curve


Hints

The curves will be automatically converted to PopcornFX's own curve type internally, though, here's some advices:

  • Curves values will be clamped to a 0-1 range
  • Curves supports independant key times for each axis, but you should be aware that other axis will interpolate the missing key times
  • 2 Dimension curves are not supported, as there is no FCurveVector2D type.


Images

Please refer to Texture sampling in order to properly setup your sampled texture.


Ue-attrsampler-texture.png


  • Drag & drop a PopcornFXAttributeSamplerActor in your level and assign it to your effect as shown above
  • Set the Sampler Component Type to Image
  • Assign your texture asset


Texts

Ue-attrsampler-text.png


  • Drag & drop a PopcornFXAttributeSamplerActor in your level and assign it to your effect as shown above
  • Set the Sampler Component Type to Text
  • Setup the Text field