【问题标题】:Swift uniform typename not recognizedSwift 统一类型名无法识别
【发布时间】:2016-03-11 18:14:14
【问题描述】:

我正在尝试使用 swift 让着色器在 spritekit 中工作。在着色器中,据我所知,我正确声明了三个制服,但出现错误: program_source:8:1: 错误:未知类型名称'uniform'

uniform vec4 info;
uniform vec4 pixelSize;
uniform sampler2D innerImage;

完整的着色器

uniform vec4 info; // x is time spent transitioning
// y is time it takes to transition

uniform vec4 pixelSize; // x is pixel size on the x
// y is pixel size on the y

uniform sampler2D innerImage;

void main()
{
    vec4 sceneColor = texture2D(u_texture,v_tex_coord);

    float radius = info.x / info.y;
    float distance = length(v_tex_coord - info.zw);

    vec2 innerGreyCircle = radius - pixelSize.xy * 25;
    vec2 outerColorCircle = radius + pixelSize.xy * 25;

    if(distance < radius)
    {
        //vec2 circle = radius - pixelSize.xy * 25;
        if(distance > innerGreyCircle.x || distance > innerGreyCircle.y)
        {
            vec2 tc = v_tex_coord;
            vec2 p = -1.0 + 2.0 * tc;
            float len = length(p);
            vec2 newTexCoord = tc + (p / len) * cos(len * 12.0f - info.x * 4.0f) * 1.0f;
            sceneColor = texture2D(innerImage,newTexCoord);//.xyz;//filter, newTexCoord).xyz;
        }

        float grey = dot(sceneColor.rgb, 1) / 3 * 1.5f;
        sceneColor = vec4(grey, grey, grey, 1);
    }
    else if(distance < outerColorCircle.x || distance < outerColorCircle.y)
    {
        vec2 tc = v_tex_coord;
        vec2 p = -1.0 + 2.0 * tc;
        float len = length(p);
        vec2 newTexCoord = tc + (p / len) * cos(len * 12.0f - info.x * 4.0f) * 1.0f;
        sceneColor = texture2D(innerImage,newTexCoord);//.xyz;//filter,       newTexCoord).xyz;
}

    gl_FragColor = sceneColor;
}

【问题讨论】:

    标签: swift sprite-kit fragment-shader uniform


    【解决方案1】:

    我猜你在 spritekit、swift 和 glsl 的组合中使用某些东西时不需要开头的声明。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-26
      • 1970-01-01
      相关资源
      最近更新 更多