无法编译顶点着色器GPUImage

时间:2015-07-11 20:03:33

标签: ios objective-c opengl-es gpuimage

我试图在GPUImage中使用一些自定义滤镜,我想要使用一些顶点和片段着色器。当我尝试使用过滤器时,我得到一个错误,说我的着色器无法编译,并抛出Filter shader link failed

的异常

以下是我设置相机的代码

videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPresetHigh cameraPosition:AVCaptureDevicePositionBack];
    videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
    videoCamera.horizontallyMirrorFrontFacingCamera = NO;
    videoCamera.horizontallyMirrorRearFacingCamera = NO;
    videoCamera.frameRate = 30;

    filter = [[GPUImageFilter alloc]initWithVertexShaderFromString:@"AlphaDisplayShader" fragmentShaderFromString:@"AlphaDisplayShader"];

    [videoCamera addTarget:filter];
    GPUImageView *filterView = [[GPUImageView alloc]initWithFrame:self.view.frame];
    [self.view addSubview:filterView];

    [filter addTarget:filterView];

    [videoCamera startCameraCapture];

对于我的着色器,我有:

AlphaDisplayShader.fsh

varying highp vec2 textureCoordinate;
precision mediump float;

uniform sampler2D videoFrame;
uniform float inputAlpha;

void main()
{
    //vec4 textureColor = texture2D(videoFrame, textureCoordinate);
    //gl_FragColor = 0.5 * textureColor;

    gl_FragColor = texture2D(videoFrame, textureCoordinate);


    //normal
    gl_FragColor.a *= inputAlpha;

    //gl_FragColor.r=1.0;

    //lightrail
    //gl_FragColor.r *= inputColor.a;
    //gl_FragColor.g *= inputColor.a;
    //gl_FragColor.b *= inputColor.a;

}

AlphaDisplayShader.vsh

attribute vec4 position;
attribute vec4 inputTextureCoordinate;

varying vec2 textureCoordinate;

void main()
{
    gl_Position = position;
    textureCoordinate = inputTextureCoordinate.xy;
}

我正在尝试使用这些过滤器模拟长时间曝光的照片,有人看到我的错误所在吗?我也在使用最新的Xcode官方版本。

0 个答案:

没有答案