Sign in to follow this  
Infinite_Daremo

Flickering lights when animating models - Resolved

Recommended Posts

For some reason when i animate my models lights seem to flicker. There is only 2 lights active in the scene a static source light and a dynamic spotlight but im not sure theyre the issue. Heres a video, the light blue coloured blob is the dynamic spotlight i randomly created its not the problem, the problem is what seems to look like lightning flashes: http://www.youtube.com/watch?v=8Kmwi2VAvOo Any ideas what could be causing this? Ill provide code if needed. [Edited by - Infinite_Daremo on July 2, 2008 4:28:55 PM]

Share this post


Link to post
Share on other sites
I think it's a hidden out-of-array-bounds error. Somewhere in your skinning (animation) code, you write to memory-space, that belongs to the lights' info variables.
Try to put some debugging code at places, where you access arrays - code, that checks what index for the array-access you'll be using.

Share this post


Link to post
Share on other sites
Im gonna debug now, ill post the code here for now incase theres a more obvious error:

void CBaseModel::doRender(float posX, float posY, float posZ, int frameNum)
{
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);

CVector *pointList = 0;
CVector tempVec0, tempVec1, tempVec2, normal;

pointList = &m_pModelData->pointList[ m_pModelData->numPoints * frameNum ]; // Pointer to current frame

glBindTexture( GL_TEXTURE_2D, m_pModelData->modelTex->texID );

// Render model
glBegin(GL_TRIANGLES);
for( int i = 0; i < m_pModelData->numTriangles; i++ )
{
normal = UTILITY.calculateNormal( &pointList[ m_pModelData->triIndex[i].meshIndex[0]], &pointList[ m_pModelData->triIndex[i].meshIndex[1]], &pointList[ m_pModelData->triIndex[i].meshIndex[2]] );
glNormal3f( normal.x, normal.y, normal.z );

// To avoid constant dereferencing
tempVec0 = pointList[ m_pModelData->triIndex[i].meshIndex[0]];
tempVec1 = pointList[ m_pModelData->triIndex[i].meshIndex[1]];
tempVec2 = pointList[ m_pModelData->triIndex[i].meshIndex[2]];

glTexCoord2f( m_pModelData->st[ m_pModelData->triIndex[i].stIndex[0]].s, m_pModelData->st[ m_pModelData->triIndex[i].stIndex[0]].t );
glVertex3f( tempVec0.x, tempVec0.y, tempVec0.z);

glTexCoord2f( m_pModelData->st[ m_pModelData->triIndex[i].stIndex[1]].s, m_pModelData->st[ m_pModelData->triIndex[i].stIndex[1]].t );
glVertex3f( tempVec1.x, tempVec1.y, tempVec1.z);

glTexCoord2f( m_pModelData->st[ m_pModelData->triIndex[i].stIndex[2]].s, m_pModelData->st[ m_pModelData->triIndex[i].stIndex[2]].t );
glVertex3f( tempVec2.x, tempVec2.y, tempVec2.z);
}
glEnd();
}

Share this post


Link to post
Share on other sites
In the vid it looks like the terrain is picking up too much shininess, a per frag shader (rather than what looks like standard vertex lighting) would eliminate the flashes.

Or you could lower the shininess, if of course that is the problem!

GLint materialShininess = 12; //try roughly in the range of 2 to 125
glMateriali( GL_FRONT, GL_SHININESS, materialShininess );

Share this post


Link to post
Share on other sites
I tried rendering without the terrain as i have not bothered calculating proper normals for it yet but the problem still persists.

Also debugging at the time of the lighting errors there is no out of bound reading. Everything seems to be fine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this