creator shader:从零开始,做个地面震动效果,类似冲击波?

底图尺寸吗? :joy:

CCProgram fs %{

precision highp float;

#include

#include

in vec4 v_color;

#define iResolution vec2(195., 270.)

#if USE_TEXTURE

in vec2 v_uv0;

uniform sampler2D texture;

#endif

uniform Constantsl {

float u_time;

};

void main () {

// vec4 o = vec4(1, 1, 1, 1);

vec2 uv = v_uv0;

vec2 p = vec2(.5, .5);

vec2 off = p - uv;

off.x *= iResolution.x / iResolution.y;

float dis = length(off);

float r = .02;

r += u_time * .6;

float width = .005;

float border = .01;

border *= r * 30.5;

float circle = smoothstep(r + width + border, r + width, dis) - smoothstep(r, r - border, dis);

uv = uv + (uv - p) * circle;

vec4 tex = texture2D(texture, uv);



circle *= .2;

circle *= max(.1 - dis, 0.);

gl_FragColor = vec4(tex.xyz, tex.w);

}

}%

代码是这样的

1赞

怎么样在ts里面动态改变圆心的位置呀 大佬

论坛搜索 setProperty

mark 冲击波

加上*(dis-r)* 2.有奇效

为啥我搞出来的效果很奇怪 圆会一直扩散

好家伙666666

LIKK(0@MEAJSZ$}~OQ67
打开页面学习,后面同事以为我搞黄色。

不邀请你同事一起嘛?? 好东西要分享啊

可否参考一下? :see_no_evil:

demo4.zip (792.8 KB)

:+1: :+1: :+1: