欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 金融 > HLSL Complex Shapes With For Loops

HLSL Complex Shapes With For Loops

2025/4/18 21:42:02 来源:https://blog.csdn.net/m0_57958061/article/details/147127346  浏览:    关键词:HLSL Complex Shapes With For Loops

制作一个动态的cycle的动画材质

首先我们使用hlsl来写一个圆

// The below expression will get compiled
// into the output of this node
float result = 0.0f;
for(int i = 0; i < nSize; i++)
{float angle = 2 * (i / nSize) * 3.14;float2 pos = center + radius * float2(cos(angle), sin(angle));result += length(pos - uv) < size;
}
return float3(result, result, result);

加入偏移让圆动起来

float result = 0.0f;
for(int i = 0; i < nSize; i++)
{float angle = 2 * (i / nSize) * time * 3.14;float2 pos = center + radius * float2(cos(angle), sin(angle));result += length(pos - uv) < size;
}
return float3(result, result, result);

多指针旋转

也就是沿着半径去增加点的数量

float result = 0.0f;
for(int i = 0; i < nSize; i++)
{for(int j = 0; j < nCopy; j++){float angle = 2 * (i / nSize) * time * 3.14;float2 pos = center + radius * (j / nCopy) * float2(cos(angle), sin(angle));result += length(pos - uv) < size;}
}
return float3(result, result, result);

后续可以按照自己的需求修改

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词