GLSL到金属。瓷砖

问题描述 投票:0回答:1

我想在shadertoy上用实例来制作瓷砖效果(https:/www.shadertoy.comview3llcRN).这里是GLSL的代码。

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 uv = (2.*fragCoord.xy - iResolution.xy)/iResolution.y;    
    fragColor = vec4( texture(iChannel0, uv ).rgba );
}

结果。enter image description here

这是我在Metal上的代码:

kernel vec4 colorKernel(sampler source, float w, float h)
{
    vec2 d = vec2(w, h);
    vec2 uv = (2.*destCoord().xy - d.xy)/h;
    return vec4( sample(source, uv).rgba );
}

结果:

enter image description here

缺少了什么?我需要和shadertoy上一样的结果。

ios shader metal cikernel
1个回答
0
投票

问题是,当UV的坐标大于1时,它只返回空颜色。

© www.soinside.com 2019 - 2024. All rights reserved.