Advertisement

When should MRT (Multiple Render Targets) be used?

Started by June 23, 2019 09:43 AM
2 comments, last by Makusik Fedakusik 5 years, 7 months ago

I had a question about exactly when I should use the MRT. This is not about rendering models, but about post-processing. For example, I need to draw some cubic textures (something like skybox rendering). And how much will drawing in one pass be faster than in several? And will it be faster?

My shaders looks like this:

vertex:


#version 330 core

layout(location = 0) in vec3 inPos;

out vec3 texCoords;

uniform mat4 transform;

void main() {
    vec4 pos = transform * vec4(inPos, 1.0);
    gl_Position = pos.xyww;
    texCoords = inPos;
}

fragment:


#version 330 core

#define vecout vec3
#define OUT_COLOR_COMPONENT 0

in vec3 texCoords;

layout(location = OUT_COLOR_COMPONENT) out vecout fragColor;

uniform samplerCube cubemap;
uniform vecout color = vecout(1.0);

void main() {
    fragColor = vecout(texture(cubemap, texCoords)) * color;
}

 

Advertisement

The simplest example - to fill g-buffer.  http://ogldev.atspace.co.uk/www/tutorial35/tutorial35.html

 

This topic is closed to new replies.

Advertisement