PDA

View Full Version : Is it possible to FBO+cubemap(or array tex)+MRT?



Ju-hyung
09-18-2008, 02:30 AM
First of all, sorry for my poor english.

I really want to know how to create FBO with MRT of certain condition

1. create FBO with cubemap color attachment and render each face simultaneously. (or multiple cubemap with attaching each color attachment and render six times for rendering)

2. create FBO with texture array color attachment with each texture array layer

some of that are need other extensions?

thanks

arekkusu
09-18-2008, 09:07 PM
For 1, you need EXT_geometry_shader4, to attach an entire cubemap to an FBO and set gl_Layer to direct each primitive to a specific face. Or, attach one face at a time and render six times, that works with just EXT_framebuffer_object.

For 2, you need ARB_draw_buffers and EXT_texture_array.

xcoers
09-19-2008, 12:48 AM
e.g
geometey shader:

#if __USE_GLSL_1_3__
#version 130
#extension GL_ARB_geometry_shader4:enable
#else
#version 120
#extension GL_EXT_geometry_shader4:enable

#define LAYERS 32
uniform vec3 texsize;

void main()
{


for(gl_Layer=0;gl_Layer<LAYERS;gl_Layer++)
{
for(int i=0;i<gl_VerticesIn;i++)
{
gl_Position=gl_PositionIn[i];
vec4 color;
coord.rg=gl_TexCoordIn[i][0].st;
color.b=gl_Layer+0.5;
color.rgb/=texsize;
color.a=1.0;
gl_FrontColor=color;
EmitVertex();
}
EndPrimitive();
}
}

fragment shader:

#if __USE_GLSL_1_3__
#version 130
#define tex2DARRAY(s,c) texture(s,c)
#extension GL_ARB_geometry_shader4:enable
#extension GL_ARB_texture_array:enable
#else
#version 120
#define tex2DARRAY(s,c) texture2DArray(s,c)
#extension GL_EXT_geometry_shader4:enable
#extension GL_EXT_texture_array:enable
#endif

uniform sampler2DArray arrayMap;

void main()
{
vec3 coord;
coord.xy=gl_TexCoord[0].st;
for(int i=0;i<8;i++)
{
coord.z=i*4;
vec4 color;
color =texture2DArray(arrayMap,coord);
coord.z+=1.0;
color+=texture2DArray(arrayMap,coord);
coord.z+=1.0;
color+=texture2DArray(arrayMap,coord);
coord.z+=1.0;
color+=texture2DArray(arrayMap,coord);
gl_FragData[i]=color;
}
}