Sec*_*lly 1 shader opengl-es glsl fragment-shader opengl-es-2.0
我正在学习在 OpenGL ES 中使用着色器。
例如:这是我的游乐场片段着色器,它采用当前视频帧并使其灰度化:
varying highp vec2 textureCoordinate;
uniform sampler2D videoFrame;
void main() {
highp vec4 theColor = texture2D(videoFrame, textureCoordinate);
highp float avrg = (theColor[0] + theColor[1] + theColor[2]) / 3.0;
theColor[0] = avrg; // r
theColor[1] = avrg; // g
theColor[2] = avrg; // b
gl_FragColor = theColor;
}
Run Code Online (Sandbox Code Playgroud)
theColor表示当前像素。还可以访问同一坐标处的前一个像素会很酷。
出于好奇,我想将当前像素的颜色添加或乘以前一个渲染帧中像素的颜色。
我怎样才能保留之前的像素并将它们传递给我的片段着色器以便对它们做一些事情?
注意:它是 iPhone 上的 OpenGL ES 2.0。
| 归档时间: |
|
| 查看次数: |
2755 次 |
| 最近记录: |