Lights from a render list

Published January 03, 2010
Advertisement
Made some structural changes today to prepare my newly created lighting system for use with the scene.

I've got my system gathering spotlights from a render list and drawing as many as possible in a single pass; it performs quite well with around 50 lights per pass. This render list is gathered by the scene (ill detail my scene system in a later post) but atm the lighting is only debug data.






My light manager is capable of taking lights from a render list, batching them up into uniforms, and rendering as many as possible with a single pass. This will cut down on the number of fullscreen quads to be rendered. Fillrate is my primary bottleneck right now. I've seen methods which render the AABB of a light system as some kind of volume on screen, which conveniently means projecting it and reducing the number of fragments to render by orders of magnitude, this will likely be a good option.
	void LightManager::startList(RenderList3D& source){		current_position = source.light_begin(), last_position = source.light_end();	}	LightManager::Step LightManager::stepList(int shader_program)	{		static SpotLight dummy_light;		dummy_light.setOn(true);		static std::vector<float> pos(3 * available_spotlights);		static std::vector<float> dir(3 * available_spotlights);		static std::vector<float> colour(3 * available_spotlights);		static std::vector<float> radius(available_spotlights);		static std::vector<float> cosAngle(available_spotlights);		for(int i = 0; i < available_spotlights; i++)		{			SpotLight * l;			if(current_position != last_position)			{	// apply each light in turn				l = ( current_position->light );				current_position++;			}			else			{	// fill the remainder of the list with dummy lights				l = &dummy_light;			}			pos[3 * i + 0] = l->pos[0];			pos[3 * i + 1] = l->pos[1];			pos[3 * i + 2] = l->pos[2];			dir[3 * i + 0] = l->dir[0];			dir[3 * i + 1] = l->dir[1];			dir[3 * i + 2] = l->dir[2];			colour[3 * i + 0] = l->rgb[0];			colour[3 * i + 1] = l->rgb[1];			colour[3 * i + 2] = l->rgb[2];			cosAngle = cos(l->angle * 0.0174532925f);			radius = l->on ? l->radius : 1e-1f;		}		GLint location = glGetUniformLocation(shader_program, "uLightPos");		if(location != -1)			glUniform3fv(location, available_spotlights, &pos[0]);		location = glGetUniformLocation(shader_program, "uLightDir");		if(location != -1)			glUniform3fv(location, available_spotlights, &dir[0]);		location = glGetUniformLocation(shader_program, "uLightColour");		if(location != -1)			glUniform3fv(location, available_spotlights, &colour[0]);		location = glGetUniformLocation(shader_program, "uLightRadius");		if(location != -1)			glUniform1fv(location, available_spotlights,  &radius[0]);		location = glGetUniformLocation(shader_program, "uLightCosAngle");		if(location != -1)			glUniform1fv(location, available_spotlights,  &cosAngle[0]);		if(current_position != last_position)		{	// we are still iterating our spotlights			return SPOTLIGHTS;		}		else		{	// we have reached the end of the list			return FINISHED;		}	}

My next step is to work the way lights are gathered into the scene itself, I've created various code paths for lights in the scene but not integrated this with my 3d editor.
that: add point lights to the system.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement