【发布时间】: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