Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Assets/Nova/Runtime/Core/Shaders/Particles.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,17 @@ half2 GetFlowMapUvOffset(TEXTURE2D_PARAM(flowMap, sampler_flowMap),
#endif
}

// Returns the progress for flip-book.
// Returns the progress for flip-book (Texture2D Array).
// Returns an integer frame index to prevent texture bleeding.
half FlipBookProgress(in half progress, in half sliceCount)
{
float result = progress;
result = clamp(result, 0, 0.999);
result = frac(result);
result *= sliceCount;
result -= 0.5;
return result;
// Clamp progress to [0, 0.999) range
half clampedProgress = clamp(progress, 0.0, 0.999);

// Calculate frame index and floor to integer
// This prevents texture bleeding in Texture2D Array sampling
half frameIndex = clampedProgress * sliceCount;
return floor(frameIndex);
}

// Returns the progress for flip-book blending.
Expand Down