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值,直接运行,类似如图

相关推荐
zxm851338 分钟前
UV使用及UV与Anaconda的区别
大数据·学习·机器学习·uv
mxwin13 小时前
Unity Shader 极坐标特效 从数学原理到实战案例
unity·游戏引擎·shader·uv
wa的一声哭了2 天前
uv简单使用
uv
mxwin2 天前
Unity Shader UI 流光效果完全推导指南
ui·unity·游戏引擎·shader·uv
kishu_iOS&AI2 天前
PyCharm 结合 uv 进行 AI 大模型开发
人工智能·pycharm·大模型·uv
mxwin3 天前
Unity Shader FLOWMAP岩浆流动制作案例
unity·游戏引擎·shader·uv
mxwin3 天前
Unity Shader 用 Ramp 贴图实现薄膜干涉效果
unity·游戏引擎·贴图·shader·uv
mxwin3 天前
Unity Shader · UV 技术 用 UV 坐标打造水波涟漪效果
unity·游戏引擎·shader·uv
银月光科技4 天前
UV固化技术崛起:高端制造的下一项标配技术
人工智能·制造·uv
Python大数据分析@4 天前
Python包管理器 uv是否替代conda?
python·conda·uv