Render to 3D texture

Hi all,

currently i am working on Light Propagation Volumes algorithm. But I am stuck in init phase. I don’t know how to fill 3D grid with some values. I have tried to attach 3D texture as render target and then i selected appropriate layer in geometry shader but without success. Texture is completely black in all layers (according to Nsight it contains all zeros). Minimal code i have used:

Vertex shader

#version 430
layout(location = 0) in vec2 vPosition;

void main()
{
	gl_Position =  vec4(vPosition,0.0,1.0);
}

Geometry shader:

#version 430
layout(points )in;
layout(points ,max_vertices = 1 )out;

void main(){
	gl_Position=gl_in[0].gl_Position; //or vec4(0.0,0.0,0.0,1.0)
	gl_Layer = 1;
	EmitVertex();
	EndPrimitive();
}

Fragment shader:

#version 430
layout(location=0) out vec4 c; //GL_COLOR_ATTACHMENT0

void main()
{
	c = vec4(1.0,0.0,0.0,1.0);
}

and finaly GL code:

//Texture creation
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_3D, tex);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 5, 5, 5, 0, GL_RGBA, GL_FLOAT, NULL);

//... some code
//create FBO, bind render buffer (these steps are omitted for simplicity)
//and attach texture to fbo
//FBO creation doesn't throw any exception
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D, tex, 0, 0);
static const GLenum draw_buffers[] =
	{
	GL_COLOR_ATTACHMENT0
	};
glDrawBuffers(1, draw_buffers);

//Draw loop
//set up view port, clearing color, clear buffer, Bind fbo
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
glViewport(0, 0, WIDTH, HEIGHT);
glDisable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
injectLight.Use(); //Activate the shader program
glBindVertexArray(VAO);
glDrawArrays(GL_POINTS, 0, TEST_NUM_POINT); //TEST_NUM_POINT = 1 and VBO contains only one point (0.0,0.0)
glBindVertexArray(0);
injectLight.UnUse();
glBindFramebuffer(GL_FRAMEBUFFER, 0);

I would expect that this code should write vec4(1.0,0.0,0.0,1.0) into layer number 1 (second layer in 3D texture). But as i said earlier texture is completely black. Is something wrong with my code?

EDIT: Added minimal source code (VS 2013 project, contains all the libraries and it’s configured, just open and run). Link:
https://dl.dropboxusercontent.com/u/20467425/DevTalk/minimal_sources.zip

I’ll answer to myself. Code above now works. Mistake was in using glFramebufferTexture3D. When I use glFramebufferTexture function, everything works as expected.