cocos creator3.8 箭头的uv 流动shader

CCEffect %{

techniques:

  • passes:

  • vert: sprite-vs:vert

frag: sprite-fs:frag

depthStencilState:

depthTest: false

depthWrite: false

blendState:

targets:

  • blend: true

blendSrc: src_alpha

blendDst: one_minus_src_alpha

blendDstAlpha: one_minus_src_alpha

rasterizerState:

cullMode: none

properties:

mainTexture: { value: white }

tiling: { value: [1.0, 1.0] }

flowSpeed: { value: 5.0 }

}%

CCProgram sprite-vs %{

precision highp float;

#include <builtin/uniforms/cc-global>

#if USE_LOCAL

#include <builtin/uniforms/cc-local>

#endif

in vec3 a_position;

in vec2 a_texCoord;

in vec4 a_color;

out vec4 v_color;

out vec2 uv0;

vec4 vert() {

vec4 pos = vec4(a_position, 1);

#if USE_LOCAL

pos = cc_matWorld * pos;

#endif

pos = cc_matViewProj * pos;

uv0 = a_texCoord;

v_color = a_color;

return pos;

}

}%

CCProgram sprite-fs %{

precision highp float;

#include <builtin/uniforms/cc-global>

#include <builtin/internal/embedded-alpha>

in vec4 v_color;

in vec2 uv0;

uniform sampler2D mainTexture;

uniform Properties {

vec2 tiling;

float flowSpeed;

};

vec4 frag() {

// 计算流动的UV坐标

float t = cc_time.x; // 引擎内置时间(秒)

vec2 uv = vec2(uv0.x * tiling.x, fract(uv0.y * tiling.y + t * flowSpeed)); // y轴方向反向流动,随高度重复

// 采样纹理

vec4 texColor = texture(mainTexture, uv);

// 直接返回纹理颜色乘以顶点颜色

vec4 o = v_color * texColor;

return o;

}

}%

将箭头图片拖到场景中,修改图片的材质,该一下箭头图片node节点的高度 ,同时修改一下材质上 tile 的y值,直接运行,类似如图

相关推荐
SCBAiotAigc5 天前
2026.2.25:conda与uv并存时,如何取消base激活
人工智能·python·conda·uv
wumingxiaoyao6 天前
从 requirements.txt 到 uv:多模块 Monorepo 的依赖管理升级指南(用法、特点、区别与最佳实践 + 例子)
pip·uv·pip tool
宸迪16 天前
【python】使用uv管理项目包依赖
linux·python·uv
铬锐特实业19 天前
自动化点胶+低粘度UV胶:流水线效率提升方案 |铬锐特实业
uv·光固化胶水·铬锐特·紫外线胶水·uv胶
放飞自我的Coder20 天前
【UV python包管理工具 简单应用足够】
python·uv
恒云客20 天前
FastAPI 容器化UV部署
前端·fastapi·uv
永霖光电_UVLED21 天前
LEDINTRO推出突破性无害230nm UV LED空气杀菌球
uv
TTGGGFF21 天前
UV 全命令速查手册
大数据·elasticsearch·uv
知识即是力量ol21 天前
亿级数据下的基数统计:从 Set 到 HyperLogLog 的进阶实战
redis·set·uv·bitmap·hyperloglog·亿级数据
玄同76521 天前
我的 Trae Skill 实践|使用 UV 工具一键搭建 Python 项目开发环境
开发语言·人工智能·python·langchain·uv·trae·vibe coding