Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl 从frag着色器写入纹理?_Opengl_Glsl_Textures_Shader - Fatal编程技术网

Opengl 从frag着色器写入纹理?

Opengl 从frag着色器写入纹理?,opengl,glsl,textures,shader,Opengl,Glsl,Textures,Shader,因此,我将纹理读入片段着色器。我可以输出到“显示”;但是如何输出/写入另一个纹理?基本上我想做的是: read in info from texture 1 // working do stuff with data //working. output to texture 2 // ?? display texture 2 // working. 第二轮: read in infom from texture 2 // working do stuff with data //wor

因此,我将纹理读入片段着色器。我可以输出到“显示”;但是如何输出/写入另一个纹理?基本上我想做的是:

read in info from texture 1  // working
do stuff with data //working.
output to texture 2  // ??
display texture 2  // working.
第二轮:

read in infom from texture 2  // working
do stuff with data //working.
output to texture 1 // ??
display texture 1 /// working.
我想在GPU上完成这一切。在CPU上做这件事很容易,但会降低性能(因此,我为什么要在着色器中做这件事)

我想我想使用帧、纹理或像素缓冲区

更多信息如果需要,纹理将进入着色器,如下所示:



着色器:

#version 330 core

out vec4 outputColor;
in vec2 fragPosition;  // 2d texture
uniform sampler2D TextureOne;

void main() {
    outputColor = texture(TextureOne, fragPosition);  
    //outputColor goes to output display.
}

使用帧缓冲区对象(FBO)写入纹理,它们用作自定义绘制缓冲区,可以将纹理附加为绘制缓冲区(附件),颜色写入将转到纹理。

使用帧缓冲区对象(FBO)写入纹理,它们用作自定义绘制缓冲区,可以将纹理附加为绘制缓冲区(附件)颜色写入将转到纹理。

嗨!好的,我有一个FBO,它使用:glFramebufferTexture2D绑定纹理。我还将纹理传递到我的frag着色器。这一切终于开始工作了。你有任何frag着色器写入FBO/纹理的例子吗?嗨!好的,我有一个FBO,它使用:glFramebufferTexture2D绑定纹理。我有一个FBO,它使用:glFramebufferTexture2D绑定纹理同时将纹理传递到我的frag着色器。这一切终于开始工作了。你有任何将frag着色器写入FBO/texture的示例吗?
#version 330 core

out vec4 outputColor;
in vec2 fragPosition;  // 2d texture
uniform sampler2D TextureOne;

void main() {
    outputColor = texture(TextureOne, fragPosition);  
    //outputColor goes to output display.
}