How do I iterate with texture in ShaderMaterial, as in the following example

How do I iterate with texture in ShaderMaterial, as in the following example
If you look inside Buffer A, you’ll notice that it using Buffer A in iChannel0 from within Buffer A.
example: https://www.shadertoy.com/view/wdtyDH

Or, how do I get the current render target in babylon and iterate over it in shader. Like the three.js case below, I want to convert it to babylon code, but don’t know how to deal with a code like the following:
example: https://github.com/martinRenou/threejs-caustics

  _render(renderer, mesh) {
    // Swap textures
    const _oldTarget = this.target;
    const _newTarget = this.target === this._targetA ? this._targetB : this._targetA;

    const oldTarget = renderer.getRenderTarget();

    renderer.setRenderTarget(_newTarget);

    mesh.material.uniforms['texture'].value = _oldTarget.texture;

    // // TODO Camera is useless here, what should be done?
    renderer.render(mesh, this._camera);

    renderer.setRenderTarget(oldTarget);

    this.target = _newTarget;
  }

I looked up babylon and found that RenderTargetTexture has a similar function, but it seems different.
If someone have idea, Please let me know.

You need to ping-pong between two render target textures.

This thread should help you (there are a lot of other threads related to porting shadertoy shaders to Babylon):

2 Likes