Exemplo n.º 1
0
bool CConvexTest::SetLight()
{
	ShaderManager *pShaderMgr = m_Shader.GetShaderManager();
	if( !pShaderMgr )
		return false;

	ShaderLightManager *pShaderLightMgr = m_Shader.GetShaderManager()->GetShaderLightManager().get();
	if( pShaderLightMgr )
	{
		pShaderLightMgr->ClearLights();

		HemisphericDirectionalLight light;
		light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
		light.Attribute.LowerDiffuseColor.SetRGBA( 0.1f, 0.1f, 0.1f, 1.0f );
		light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -1.8f, -0.9f ) );

//		pShaderLightMgr->SetLight( 0, light );
//		pShaderLightMgr->SetDirectionalLightOffset( 0 );
//		pShaderLightMgr->SetNumDirectionalLights( 1 );
		pShaderLightMgr->SetHemisphericDirectionalLight( light );

		pShaderLightMgr->CommitChanges();

		return true;
	}
	else
		return false;
}
void SimpleOverlayEffectsDemo::SetLights()
{
    ShaderManager *pShaderMgr = m_Shader.GetShaderManager();

    if( !pShaderMgr )
        return;

    ShaderManager& shader_mgr = *pShaderMgr;

//	if( !shader_loaded )
//		return false;

    ShaderLightManager *pShaderLightMgr = shader_mgr.GetShaderLightManager().get();
    if( !pShaderLightMgr )
        return;

    pShaderLightMgr->ClearLights();

    HemisphericDirectionalLight light;
    light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
    light.Attribute.LowerDiffuseColor.SetRGBA( 0.1f, 0.1f, 0.1f, 1.0f );
    light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -1.8f, 0.9f ) );

//	pShaderLightMgr->SetLight( 0, light );
//	pShaderLightMgr->SetDirectionalLightOffset( 0 );
//	pShaderLightMgr->SetNumDirectionalLights( 1 );
    pShaderLightMgr->SetHemisphericDirectionalLight( light );

    pShaderLightMgr->CommitChanges();
}
Exemplo n.º 3
0
void LightingDemo::SetHSDirectionalLights( ShaderLightManager& shader_light_mgr, bool random_color )
{
	// Always use hemispheric lights
	const bool use_hemespheric_light = true;

	if( use_hemespheric_light )
	{
//		HemisphericDirectionalLight light;
//		light.Attribute.UpperDiffuseColor.SetRGBA( 0.0f, 1.0f, 1.0f, 1.0f );
//		light.Attribute.LowerDiffuseColor.SetRGBA( 1.0f, 0.1f, 0.1f, 1.0f );
//		light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -1.8f, -0.9f ) );
		HemisphericDirectionalLight light;
//		light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
//		light.Attribute.LowerDiffuseColor.SetRGBA( 0.0f, 0.0f, 0.0f, 1.0f );
		light.Attribute.UpperDiffuseColor = SFloatRGBAColor::Red();
		light.Attribute.LowerDiffuseColor = SFloatRGBAColor::Blue();
		light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -1.5f, -0.9f ) );
		shader_light_mgr.SetHemisphericDirectionalLight( light );
	}
	else
	{
		DirectionalLight dir_light;
		dir_light.DiffuseColor = SFloatRGBColor(1,1,1);
		dir_light.fIntensity = 1.0f;
		dir_light.vDirection = Vec3GetNormalized( Vector3( 1.2f, -1.8f, 1.0f ) );
		shader_light_mgr.SetDirectionalLight( dir_light );
	}
}
Exemplo n.º 4
0
void LightingDemo::SetHSSpotights( ShaderLightManager& shader_light_mgr, bool random_color )
{
	int x = m_NumLightsX;
	int z = m_NumLightsZ;
	float span_x = 32.0f;
	float span_z = 32.0f;
//	int num_point_lights = 4;
//	for( int i=0; i<num_point_lights; i++ )
	float interval_x = (2 <= x) ? span_x / (float)(x-1) : 0.0f;
	float interval_z = (2 <= z) ? span_z / (float)(z-1) : 0.0f;
	int num_point_lights = z * x;
	int light_index = 0;
	for( int i=0; i<z; i++ )
	{
		for( int j=0; j<x; j++ )
		{
			HemisphericSpotlight light;
//			light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
			int color_index = light_index % numof(s_rand_colors);
			light_index++;
			light.Attribute.UpperDiffuseColor = s_rand_colors[color_index];
			light.Attribute.LowerDiffuseColor.SetRGBA( 0.0f, 0.0f, 0.0f, 1.0f );
			light.vPosition = Vector3(
				(float)j * interval_x - span_x * 0.5f,
				1.0f,
				(float)i * interval_z - span_z * 0.5f );
//			light.fAttenuation[0] = 0.1f;
//			light.fAttenuation[1] = 0.1f;
//			light.fAttenuation[2] = 0.1f;
			shader_light_mgr.SetHemisphericSpotlight( light );
		}
	}
}
Exemplo n.º 5
0
void CMultiShapeActorsTest::SetLights()
{
	ShaderManager *pShaderManager = m_Shader.GetShaderManager();
//	ShaderManager& shader_mgr = pShaderManager ? (*pShaderManager) : FixedFunctionPipelineManager();
	if( !pShaderManager )
		return;

	ShaderManager& shader_mgr = *pShaderManager;

	ShaderLightManager *pShaderLightMgr = shader_mgr.GetShaderLightManager().get();
	if( !pShaderLightMgr )
		return;

	pShaderLightMgr->ClearLights();

//	DirectionalLight dir_light;
//	dir_light.DiffuseColor = SFloatRGBColor(1,1,1);
//	dir_light.fIntensity = 1.0f;
//	dir_light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -2.5f, -0.9f ) );
//	pShaderLightMgr->SetDirectionalLight( dir_light );

	bool set_pnt_light = false;
	if( set_pnt_light )
	{
		PointLight pnt_light;
		pnt_light.DiffuseColor = SFloatRGBColor(1,1,1);
		pnt_light.fIntensity = 1.0f;
		pnt_light.vPosition = Vector3( 0.3f, 3.5f, -1.9f );
		pnt_light.fAttenuation[0] = 1.0f;
		pnt_light.fAttenuation[1] = 1.0f;
		pnt_light.fAttenuation[2] = 0.1f;
		pShaderLightMgr->SetPointLight( pnt_light );
	}

	HemisphericDirectionalLight hdir_light;
	hdir_light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
	hdir_light.Attribute.LowerDiffuseColor.SetRGBA( 0.3f, 0.3f, 0.3f, 1.0f );
	hdir_light.vDirection = Vec3GetNormalized( Vector3( -1.0f, -2.5f, -0.9f ) );
	pShaderLightMgr->SetHemisphericDirectionalLight( hdir_light );

	pShaderLightMgr->CommitChanges();
}