示例#1
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
void CEntityTypeLight::Render( void )
{
	BaseClass::Render();

	if( IsSelected() )
	{
		CBaseGeometry *geom = GetRenderInterfaces()->GetRendererInterf()->GetLightList()->GetUnitSphere();
		CPointLight *light = GetRenderInterfaces()->GetRendererInterf()->GetLightList()->GetPointLight(m_lightIndex);

		//calculate light geometry scales
		float fMaxDist = light->GetDist();
		geom->SetScale(fMaxDist);
		geom->SetAbsPos(GetAbsCenter());
		geom->SetAbsAngles(GetAbsAngles());

		CShader *pShd = GetShaderManager()->GetActiveShader();
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		GetGLStateSaver()->Disable(GL_CULL_FACE);
		pShd->EnableTexturing(false);
		pShd->SetDrawColor(1, 1, 0, 1);
		geom->RenderNoTextureBufferOnly(false);
		pShd->SetDrawColor(1, 1, 1, 1);
		GetGLStateSaver()->Enable(GL_CULL_FACE);
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}
}
示例#2
0
// add_random_light
// Spawns a random point light with random color and a random
// Position between 3 and -3 in all directions
static void add_random_light()
{
	CPointLight rnd;

	float x = (rand() % 1024 / 1024.0F) * 24.0F - 24.0F;
	float y = (rand() % 1024 / 1024.0F) * 24.0F - 24.0F;
	float z = (rand() % 1024 / 1024.0F) * 24.0F - 24.0F;

	vec3 lpos = {x, y, z};
	rnd.SetPosition(lpos);

	float r = rand() % 1024 / 1024.0F;
	float g = rand() % 1024 / 1024.0F;
	float b = rand() % 1024 / 1024.0F;

	int b1, b2, b3, b4, b5, b6;
	b1 = rand() % 54;
	b2 = rand() % 54;
	b3 = rand() % 54;
	b4 = rand() % 54;
	b5 = rand() % 54;
	b6 = rand() % 54;


	vec3 lcolor = {r, g, b};
	rnd.SetColor(lcolor);
	rnd.SetRadius(4.0F);


	g_lightManager->AddLight(&rnd);
}
示例#3
0
// init_render_targets(void)
// This function obtains handles, loads textures, and sets up the various offscreen
// targets required for this demo.
// For this demo, there are 3 offscreen color targets that share an offscreen depth buffer.
// They are the normaldepth buffer, the primary ssao target, and the temp blur target.
static void init_render_targets()
{
	int dispWidth = GetScreenWidth();
	int dispHeight = GetScreenHeight();

	unsigned int msaaFlags = SAMPLE_NEAREST;

	g_normalDepthColor = g_pTexInterface->AddRenderTarget(dispWidth, dispHeight, PIXEL_FORMAT_RGBA32F, SAMPLE_TRILINEAR_ANISO);
	g_offscreenDepth   = g_pTexInterface->AddDepthStencilTarget(dispWidth, dispHeight, 32, 0);
	g_lightBuffer	   = g_pTexInterface->AddRenderTarget(dispWidth, dispHeight, PIXEL_FORMAT_RGBA8, SAMPLE_TRILINEAR_ANISO);

	g_msaaColor = INVALID_HANDLE;
	g_msaaDepth = INVALID_HANDLE;
	if(g_bMSAA)
	{
		msaaFlags |= (MSAA_8_SAMPLES | TEXTURE_WRITE_ONLY);
		g_msaaColor		   = g_pTexInterface->AddRenderTarget(dispWidth, dispHeight, PIXEL_FORMAT_RGBA8, msaaFlags);
		g_msaaDepth		   = g_pTexInterface->AddDepthStencilTarget(dispWidth, dispHeight, 32, 0, msaaFlags);
	}
	g_resolveTexture   = g_pTexInterface->AddRenderTarget(dispWidth, dispHeight, PIXEL_FORMAT_RGBA8, SAMPLE_NEAREST);
	g_edgeTexture	   = g_pTexInterface->AddRenderTarget(dispWidth, dispHeight, PIXEL_FORMAT_RGBA8, SAMPLE_NEAREST);



	// Generate and load random texture for SSAO //
	g_randomTexture = g_pTexInterface->AddTexture("Media/Textures/splash.dds", SAMPLE_BILINEAR | SAMPLE_CLAMP);
	g_groundTexture = g_pTexInterface->AddTexture("Media/Textures/brick-walk-texture.bmp", SAMPLE_TRILINEAR_ANISO | SAMPLE_WRAP);
	g_pTexInterface->SetGlobalAnisotropy(16.0F);

	// Gen global light //
	vec3 color = {0.5f, 0.5f, 0.5f};
	vec3 pos = {0.0f, 0.0f, 0.0f};
	CPointLight pl;
	pl.SetColor(color);
	pl.SetPosition(pos);
	pl.SetRadius(40.0f);
	g_lightManager->AddLight(&pl);
}
示例#4
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
void CEntityTypeLight::UpdateLightParams( void )
{
	Vector3f constLinQuad = StrUtils::GetVector3( GetValue("constlinquad") ).Normalize();
	Vector4f color = StrUtils::GetVector4( GetValue("color") );
	float maxDist = StrUtils::GetFloat( GetValue("maxdist") );
	color.x /= 255.0f;
	color.y /= 255.0f;
	color.z /= 255.0f;
	CPointLight *light = GetRenderInterfaces()->GetRendererInterf()->GetLightList()->GetPointLight(m_lightIndex);
	light->SetColor( color );
	light->SetConstant( constLinQuad.x );
	light->SetLinear( constLinQuad.y );
	light->SetQuadratic( constLinQuad.z );
	light->SetAbsPos( GetAbsCenter() );
	light->SetMaxDist( maxDist );
}