Exemplo n.º 1
0
void CalculateDirectionalLight(Vertex_VCN *pVertices, int num_vertices, Vector4 &light_direction, Vector4 &light_color)
{
	for ( int i=0; i<num_vertices; i++ )
	{
		Vector4 normal = g_world_matrix.RotateVector(pVertices[i].m_Normal);
		Vector4 intensity = VectorDot(normal, light_direction);
		intensity.Abs();
		pVertices[i].m_Color = intensity * light_color;
	}
}
Exemplo n.º 2
0
void CalculatePointLight(Vertex_VCN *pVertices, int num_vertices, Vector4 &light_position, Vector4 &light_color)
{
	for ( int i=0; i<num_vertices; i++ )
	{
		Vector4 position = pVertices[i].m_Position * g_world_matrix;
		Vector4 vertex_to_light = light_position - position; 
		vertex_to_light.Normalize();
		Vector4 normal = g_world_matrix.RotateVector(pVertices[i].m_Normal);
		Vector4 intensity = VectorDot(normal, vertex_to_light);
		intensity.Abs();
		pVertices[i].m_Color = intensity * light_color;
	}
}