Author Topic: Can I bind multiple render targets in one render pass?  (Read 688 times)

0 Members and 1 Guest are viewing this topic.

4stronaut

  • Newbie

  • Offline
  • *

  • 2
    • View Profile
Can I bind multiple render targets in one render pass?
« on: March 21, 2014, 06:08:33 PM »
Can I bind multiple render targets in one render pass? like implementation for Deferred Rendering.
I read the example code, it bind one render target for each pass :(

JeGX

  • Global Moderator
  • Hero Member

  • Offline
  • *****

  • 581
    • View Profile
    • Geeks3D.com
Re: Can I bind multiple render targets in one render pass?
« Reply #1 on: March 21, 2014, 08:09:54 PM »
Yes, since v0.6.3.9, GLSL Hacker supports MRT.

There should be a demo in the code sample pack /host_api/MultipleRenderTargets/

To create a render target with two color buffers:

Code: [Select]
num_color_targets = 2
rt01 = gh_render_target.create_v2(width, height, num_color_targets)


When you need to bind color buffers as textures, just do:

Code: [Select]
gh_texture.rt_color_bind_v2(rt01, 0, 0) -- Color texture 0 on texture unit 0
gh_texture.rt_color_bind_v2(rt01, 1, 1) -- Color texture 1 on texture unit 1

In the fragment shader, just declare several outputs:
Code: [Select]
out vec4 FragData[2];

Let me know if the code sample pack is not up to date.
Hope that helps.

4stronaut

  • Newbie

  • Offline
  • *

  • 2
    • View Profile
Re: Can I bind multiple render targets in one render pass?
« Reply #2 on: March 22, 2014, 02:40:36 AM »
got it, thx :)
and thx for such a handy tool!