Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do I understand your code right, that you want to render a result to a texture in the first <code>if-else</code>-block and render that result to screen in the second <code>if-else</code>-block? If so, then it looks like you have a mistake in how you organize your input and output to begin with. This is what happens in your first pass (I reduced your code):</p> <pre><code>if(counter%2==0) { glBindFramebuffer(GL_FRAMEBUFFER, fboA); // will render to textureA glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureB); // textureB is our input } else { ... } if (counter % 2 == 0) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureB); // textureB still as input? not textureA? } else { ... } </code></pre> <p>...and this is what happens in the second pass:</p> <pre><code>if(counter%2==0) { ... } else { glBindFramebuffer(GL_FRAMEBUFFER, fboB); // will render to textureB glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureA); // textureA as input } if (counter % 2 == 0) { ... } else { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textureA); // textureA as input again? } </code></pre> <p>The reason why you see something in the first frame is, because you actually render your input data, but not the result of your first pass. And the reason why you have black screen in your second pass may be that your fragment shader does not work correctly. Judging from your shader code, a mistake in accessing the neighbor texels seems to be the most plausible cause for that. Can you provide the values of <code>du</code>and <code>dv</code>?</p> <p>Also I don't think that using only one texture unit should make any trouble, as Brad pointed out earlier. I'm not sure about that though.</p> <p>On a side note: for ping-ponging you should consider creating your <a href="http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/tutorial.html#feedback2" rel="nofollow" title="Dominik Göddeke -- GPGPU::Basic Math Tutorial">FBOs as an array</a> to make your code a lot more readable.</p> <p><strong>EDIT:</strong></p> <p>I you have problems setting your uniforms <code>du</code> and <code>dv</code> with <code>glUniform1f()</code>, try <code>glUniform1i()</code> (you need to cast with <code>float()</code> in your shader then) or <code>glUniform1fv()</code> instead. I once had the same problem with the PowerVR GLES2 drivers, where this function didn't do anything and caused the uniform to be <code>0.0</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload