예제 #1
0
//------------------------------------------------------------------------------
void PointLight::GetShadowRay( const Intersection& _intersection, RayList& o_shadowRays, DisList& o_disList, float& o_attenuation ) const
{
	Vector lightDir = Position() - _intersection.Position();
	float dis = lightDir.Length();
	o_disList.push_back(dis);
	float attenuation = m_intensity /( dis*dis );
	Clamp( attenuation, 0, 1);
	o_attenuation = attenuation;
	Normalise( lightDir );

	o_shadowRays.push_back( Ray( _intersection.Position() + lightDir * EPSILON, lightDir, g_air ) );
}
예제 #2
0
//------------------------------------------------------------------------------
void AreaLight::GetShadowRay ( const Intersection& _intersection, RayList& o_shadowRays, DisList& o_disList, float& o_attenuation ) const
{
	std::vector<Vector>::const_iterator iter = m_lightSamplesTransformed.begin ();
	while( iter != m_lightSamplesTransformed.end() )
	{
		Vector lightDir = *iter - _intersection.Position();
		float dis = lightDir.Length ();
		o_disList.push_back( dis );
		float attenuation = m_intensity / ( dis * dis );
		Clamp(attenuation, 0, 1);
		o_attenuation = attenuation;
		Normalise( lightDir );

		o_shadowRays.push_back ( Ray ( _intersection.Position () + _intersection.Normal () * 0.01, lightDir, g_air ) );
		++iter;
	}
}