In this lesson, you will learn how to drive particle behaviors like scale, color, and speed by sampling external textures directly within the VFX Graph.
Beyond Uniformity: The Power of Attribute Maps
Up until now, we’ve relied on global properties or random distribution nodes to vary our particles. However, when you need intricate, non-random patterns—like a particle system that mimics the shape of a logo or pulses according to a heat map—procedural noise isn't enough. This is where Attribute Maps (or Texture Maps) come in.
An attribute map is simply a texture where each pixel represents data. For instance, in a grayscale map, the pixel value can dictate Size, while a color texture can dictate Color. By sampling these textures based on the particle's Position or UV coordinates, we can achieve highly detailed visual complexity.
Implementing the Map
To use an attribute map in VFX Graph, you aren't just applying a texture to the mesh; you are using the texture as a Data Source. You typically perform this in the Update or Initialize context:
- Sample Texture 2D Node: Bring your texture into the graph.
- Coordinate Mapping: Connect the
Positionnode (or a normalizedUVcoordinate) to the UV input of yourSample Texture 2Dnode. - Attribute Assignment: Pipe the output of the sampler into a
Set Attributenode. If you want to control particle speed, you might plug the texture output into aMultiplynode to scale aVelocityproperty.
// Conceptual logic inside the Graph:
float4 mapData = SampleTexture2D(AttributeMap, UV);
float scaleValue = mapData.r; // Use the Red channel for Size
SetAttribute(Size, scaleValue * GlobalMultiplier);
Why use maps over code?
Using a texture allows artists to "paint" particle behavior. If you want a cluster of particles to move faster in the center of an effect, you simply create a radial gradient texture where the center is white (high value) and the edges are black (low value). The GPU then interprets these values per-particle, allowing for thousands of unique behaviors without writing complex, branching CPU code.
Key Takeaway: Attribute maps shift the burden of behavioral variety from complex logical nodes to static textures, allowing you to "paint" intricate particle dynamics directly onto your visual effects.