Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow choosing a specific frame when Zero FPS is supplied to a Spritesheet #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions Assets/lilToon/Shader/Includes/lil_common_functions.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,17 @@ float2 lilCalcDecalUV(
float2 lilCalcAtlasAnimation(float2 uv, float4 decalAnimation, float4 decalSubParam)
{
float2 outuv = lerp(float2(uv.x, 1.0-uv.y), 0.5, decalSubParam.z);
uint animTime = (uint)(LIL_TIME * decalAnimation.w) % (uint)decalAnimation.z;
uint offsetX = animTime % (uint)decalAnimation.x;
uint offsetY = animTime / (uint)decalAnimation.x;
uint animFrame;
if (decalAnimation.w == 0.0)
{
animFrame = (uint)decalAnimation.z;
}
else
{
animFrame = (uint)(LIL_TIME * decalAnimation.w) % (uint)decalAnimation.z;
}
uint offsetX = animFrame % (uint)decalAnimation.x;
uint offsetY = animFrame / (uint)decalAnimation.x;
outuv = (outuv + float2(offsetX,offsetY)) * decalSubParam.xy / decalAnimation.xy;
outuv.y = 1.0-outuv.y;
return outuv;
Expand Down