void CDeferredLightContainer::AddWorldLight( CDeferredLight *l )
{
	int targetIndex = GetLightsAmount();

	Assert( targetIndex < DEFLIGHTCONTAINER_MAXLIGHTS );

	float spotConeInnerDot = SPOT_DEGREE_TO_RAD( l->GetSpotCone_Inner());
	float spotConeOuterDot = SPOT_DEGREE_TO_RAD(l->GetSpotCone_Outer());

	int styleSeed = l->GetStyle_Seed();

	if ( styleSeed < 0 )
		styleSeed = RandomInt( 0, DEFLIGHT_SEED_MAX );

	m_pos.Set( targetIndex, l->GetAbsOrigin() );
	m_ang.Set( targetIndex, l->GetAbsAngles() );

	m_col_diff.Set( targetIndex, l->GetColor_Diffuse() );
	m_col_amb.Set( targetIndex, l->GetColor_Ambient() );

	m_style_amt_speed_smooth.Set( targetIndex,
		Vector( l->GetStyle_Amount(), l->GetStyle_Speed(), l->GetStyle_Smooth() ) );
	m_ranges_vdist_vrange_sdist.Set( targetIndex,
		Vector( l->GetVisible_Distance(), l->GetVisible_FadeRange(), l->GetShadow_Distance() ) );
	m_style_ran_radius_power.Set( targetIndex,
		Vector( l->GetStyle_Random(), l->GetRadius(), l->GetFalloffPower() ) );
	m_ranges_srange_cinner_couter.Set( targetIndex,
		Vector( l->GetShadow_FadeRange(), spotConeInnerDot, spotConeOuterDot ) );

	SetEncodedDataInt( targetIndex,
		styleSeed, l->GetCookieIndex(),
		l->GetLight_Flags(), l->GetLight_Type() );

	m_iLightCount = targetIndex + 1;
}
예제 #2
0
void CDeferredLight::ApplyDataToLight()
{
	Assert( m_pLight != NULL );
	ABS_QUERY_GUARD( true );

	m_pLight->ang = GetRenderAngles();
	m_pLight->pos = GetRenderOrigin();

	m_pLight->col_diffuse = GetColor_Diffuse();
	m_pLight->col_ambient = GetColor_Ambient();

	m_pLight->flRadius = GetRadius();
	m_pLight->flFalloffPower = GetFalloffPower();

	m_pLight->flSpotCone_Inner = SPOT_DEGREE_TO_RAD( GetSpotCone_Inner() );
	m_pLight->flSpotCone_Outer = SPOT_DEGREE_TO_RAD( GetSpotCone_Outer() );

	m_pLight->iVisible_Dist = GetVisible_Distance();
	m_pLight->iVisible_Range = GetVisible_FadeRange();
	m_pLight->iShadow_Dist = GetShadow_Distance();
	m_pLight->iShadow_Range = GetShadow_FadeRange();

	m_pLight->iStyleSeed = GetStyle_Seed();
	m_pLight->flStyle_Amount = GetStyle_Amount();
	m_pLight->flStyle_Random = GetStyle_Random();
	m_pLight->flStyle_Smooth = GetStyle_Smooth();
	m_pLight->flStyle_Speed = GetStyle_Speed();

	m_pLight->iLighttype = GetLight_Type();
	m_pLight->iFlags >>= DEFLIGHTGLOBAL_FLAGS_MAX_SHARED_BITS;
	m_pLight->iFlags <<= DEFLIGHTGLOBAL_FLAGS_MAX_SHARED_BITS;
	m_pLight->iFlags |= GetLight_Flags();
	m_pLight->iCookieIndex = GetCookieIndex();

#if DEFCFG_ADAPTIVE_VOLUMETRIC_LOD
	GetVolumeLODDistances( m_pLight->flVolumeLOD0Dist,
		 m_pLight->flVolumeLOD1Dist, m_pLight->flVolumeLOD2Dist,
		 m_pLight->flVolumeLOD3Dist );
#endif

#if DEFCFG_CONFIGURABLE_VOLUMETRIC_LOD
	m_pLight->iVolumeSamples = GetVolumeSamples();
#endif
}