Geeks3D Forums

GeeXLab => GeeXLab - english forum => Topic started by: 4stronaut on March 21, 2014, 06:08:33 PM

Title: Can I bind multiple render targets in one render pass?
Post by: 4stronaut 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 :(
Title: Re: Can I bind multiple render targets in one render pass?
Post by: JeGX 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.
Title: Re: Can I bind multiple render targets in one render pass?
Post by: 4stronaut on March 22, 2014, 02:40:36 AM
got it, thx :)
and thx for such a handy tool!