一种分隔屏幕显示效果

原shader地址:http://glslsandbox.com/e#40822.0

个人实现效果:

width="600" height="350" src="https://www.shadertoy.com/embed/XlfyWB?gui=false&t=0&paused=false" allowfullscreen="">

const float lineScale = 40.0;

float GetColor(vec2 pos)
{
    float radius = atan(pos.x, pos.y);
    float num = abs(pos.x) + abs(pos.y);
    //float num = length(pos);
    float curLine = floor(num * lineScale);
    float speed = sin(curLine * 24.3);
    float offset = fract(sin(speed));

    float c = step(.4, tan(radius + offset + speed * iTime ));

    float rnd = offset;
    return c * rnd;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;

    fragColor = vec4(GetColor(uv ), GetColor(uv - 0.003), GetColor(uv),1.0);
}

其中

float num = abs(pos.x) + abs(pos.y);
    //float num = length(pos);
float curLine = floor(num * lineScale);

是屏幕分隔算法,将屏幕分割成倾斜的方框,分隔效果如图示:

这里写图片描述

length(pos)将屏幕分割成圆环。

float c = step(.4, tan(radius + offset + speed * iTime ));

控制当前环中显示颜色的地方。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值