Exemple #1
0
void Shader::SetUniformPointLight(const std::string& uniformName, const PointLight& pointLight) const
{
	SetUniformVector3f(uniformName + ".base.color", pointLight.GetColor());
	SetUniformf(uniformName + ".base.intensity", pointLight.GetIntensity());
	SetUniformf(uniformName + ".atten.constant", pointLight.GetAttenuation().GetConstant());
	SetUniformf(uniformName + ".atten.linear", pointLight.GetAttenuation().GetLinear());
	SetUniformf(uniformName + ".atten.exponent", pointLight.GetAttenuation().GetExponent());
	SetUniformVector3f(uniformName + ".position", pointLight.GetTransform().GetTransformedPos());
	SetUniformf(uniformName + ".range", pointLight.GetRange());
}
	void Scene::UpdateAllPointLights()
	{
		int size = m_pointLightList.size();
		LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSSIZE, &size, SHADER_INT);
		//PointLight* light = m_pointLightList.at(0)
		//LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSDIFFUSE, &(light->GetDiffuse()), SHADER_LIGHT_DIFFUSE);

		for(int i = 0; i<m_pointLightList.size(); i++)
		{
			PointLight* light = m_pointLightList.at(i);
			float rad = light->GetRadius();
			LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSDIFFUSE, &(light->GetDiffuse()), i, SHADER_LIGHT_DIFFUSE);
			LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSAMBIENT, &(light->GetAmbient()), i, SHADER_LIGHT_AMBIENT);
			LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSSPECULAR, &(light->GetSpecular()), i, SHADER_LIGHT_SPECULAR);
			LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSRADIUS, &rad, i, SHADER_LIGHT_RADIUS);
			LowLevelGraphics::ShaderProgram::UpdateGlobalShaderParameter(LowLevelGraphics::POINTLIGHTSTRANSFORM, &(light->GetTransform()->GetMatrix()), i, SHADER_LIGHT_TRANSFORM);
		}
	}