• Advertisement
Sign in to follow this  

CubeMap for Omnidirectional Light (Solved)

This topic is 3971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i have a question i doesn't work very well. my framebuffer object is create
glGenFramebuffersEXT(1, &this->ID);
glGenRenderbuffersEXT(1, &this->dbID);
glGenTextures (1, &this->texID);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->ID);
glBindTexture (GL_TEXTURE_CUBE_MAP, this->texID);
for(int i=0; i<6; i++)
{
	glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, this->texID, 0);
}
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, this->dbID);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
			GL_RENDERBUFFER_EXT, this->dbID);

i write to the frame buffer in this way
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->ID);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT+which);
render the shadow map in the FBO it works, if i render it in a FBO with a normal texture and render that texture to screen i see my shadow map. With Spotlights it works well ;), but it can be something wrong in the FBO with Cube Maps, i never worked with Cube Maps before. Render to the CubeMap
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP, fbo->texID);
//Render everything with the create ShadowMap shader Works with Spotlights
Then render the Scene Now render objects with Shader Vertex Shader
void main(	in float4 position : POSITION,
		out float4 positionOUT : POSITION,
		out float3 lightVector : TEXCOORD0,
		uniform float4 lightPosition,
		const uniform float4x4 model_view_projection_matrix)
{
	positionOUT = mul(model_view_projection_matrix, position);
        //Get LightVector for the scene
	lightVector = normalize(lightPosition.xyz -  (position * lightPosition.w));
}
Pixel Shader
void main(
		in samplerCUBE shadowMapL,
		int float3 lightVector : TEXCOORD0,
		out float4 color : COLOR
)
{
	float3 vShadowSample = texCUBE(shadowMapL, -lightVector);
	float fDepth = dot(lightVector, lightVector);
        //The Shadow Map is packed with the code of GPU Gems work well with one Shadow Map
	float fShadow = (fDepth - (vShadowSample.r*256 + vShadowSample.g) < 0) ? 1.0f : 0.0f;
	color = float4(fShadow, fShadow, fShadow, 1);	
}
but it doesnt work, i think my cube map is empty so, there must be something wrong with my FBO i don't know, with a normal texture2D map it works so the Shader which creates the ShadowMap works well. I never worked with CubeMaps i think i do it wrong. Please help me someone. THX [Edited by - KDSBest on April 7, 2007 11:32:41 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement