本文整理汇总了C++中Light::GetIntensity方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::GetIntensity方法的具体用法?C++ Light::GetIntensity怎么用?C++ Light::GetIntensity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light::GetIntensity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetupDirectionalLight
void GLSLProgram<real>::SetupLights()
{
const std::vector<Light<real>*>* lights = RenderState<real>::Get()->GetLights();
// Setup enabled lights
for ( uint i=0 ; i<lights->size() && i<mLightLocations.size() ; ++i )
{
Light<real>* light = (*lights)[i];
glUniform1i( mLightLocations[i].enabled, true );
glUniform1i( mLightLocations[i].type, light->GetLightType() );
Vector3<float> position = light->GetLocalToGlobal() * Vector3<real>( 0, 0, 0 );
glUniform3fv( mLightLocations[i].position, 1, (float*)&position );
Color<float> intensity = light->GetIntensity();
glUniform4fv( mLightLocations[i].intensity, 1, (float*)&intensity );
Color<float> ambient = light->GetAmbient();
glUniform4fv( mLightLocations[i].ambient, 1, (float*)&ambient );
// Setup sub-parameters
switch( light->GetLightType() )
{
case Light<real>::TypeDirectional: SetupDirectionalLight( i, light ); break;
case Light<real>::TypePoint: SetupPointLight( i, light ); break;
case Light<real>::TypeSpot: SetupSpotLight( i, light ); break;
}
}
// Disabled lights
for ( uint i=lights->size() ; i<mLightLocations.size() ; ++i )
glUniform1i( mLightLocations[i].enabled, false );
// Nb of lights
glUniform1i( mNbLightsLocation, lights->size() );
}
示例2: finalColor
Color<real> BlinnPhongShader<real>::GetDiffuseAndSpecular( const Light<real>& light )
{
Color<real> finalColor( 0, 0, 0, 1 );
////////////////////////////////////////////
//////////////////IFT 3355//////////////////
////////////////////////////////////////////
//Ici, vous calculerez les composantes
//diffuse et spéculaire en vous servant des
//propriétés du matériau.
////////////////////////////////////////////
//////////////////IFT 3355//////////////////
////////////////////////////////////////////
Vector3<real> lightPos = light.GetGlobalPosition();
Vector3<real> lightDir = (lightPos - mIntersection.GetPosition()).Normalized();
real r2 = (mIntersection.GetPosition() - lightPos).SquaredLength();
Vector3<real> intersectionShifted = mIntersection.GetPosition() + EPS*mIntersection.GetNormal();
// Shadow+Diffuse
bool lightVisible = mRayTracer.IsLightVisible(intersectionShifted, &light);
if (!lightVisible)
return finalColor;
switch (light.GetLightType()) {
case Light<real>::TypeDirectional:
case Light<real>::TypeSpot:
case Light<real>::TypePoint:
finalColor += mMaterial.GetDiffuse() *
std::max<real>(0, lightDir * mIntersection.GetNormal()) *
GetMaterialSurfaceColor();
break;
}
// Specular
const Camera<real> *cam = mScene.GetActiveCamera();
Vector3<real> camDir = cam->GetFrontDirection();
Vector3<real> H = lightDir + camDir;
H.Normalize();
Vector3<real> N = mIntersection.GetNormal();
real n = mMaterial.GetShininess();
real cs = (n+2)/2;
Color<real> ks = mMaterial.GetSpecular();
Color<real> m = mMaterial.GetMetallic();
finalColor += cs * ks *
(m*GetMaterialSurfaceColor() + (Color<real>(1, 1, 1, 1) - m)) *
pow(N * H, n);
return finalColor * light.GetIntensity() / (r2 * PI);
}
示例3: LightPass
//applying the light at the "stencil-approved" areas
void DefRenderer::LightPass(Camera *cam, Renderer *r)
{
//setting to pass the stencil test when != 0
glStencilFunc(GL_NOTEQUAL, 0, 0xFF);
//writing only on top of the colors from geometry pass
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glDisable(GL_DEPTH_TEST);
//using additive blending to mix the light and scene fragments
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
//try to render from the back to preserve depth information
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
r->Ready();
mat4 model = r->GetParentGO()->GetModelMatrix();
mat4 mvp = cam->Get() * model;
r->GetProgram()->SetUniform("Model", value_ptr(model));
r->GetProgram()->SetUniform("MVP", value_ptr(mvp));
vec4 deviceCenter = vec4(mvp * vec4(0, 0, 0, 1)); //center in device coords
vec3 center(deviceCenter.x, deviceCenter.y, deviceCenter.z);
r->GetProgram()->SetUniform("Center", ¢er);
Light *l = r->GetParentGO()->GetLight();
float intensity = l->GetIntensity();
r->GetProgram()->SetUniform("Intensity", &intensity);
vec4 color = l->GetColor();
r->GetProgram()->SetUniform("Color", &color);
r->Render();
glCullFace(GL_BACK);
glDisable(GL_BLEND);
CHECK_GL_ERROR();
}
示例4: ReadFrom
void LightPropertyControl::ReadFrom(Entity * sceneNode)
{
NodesPropertyControl::ReadFrom(sceneNode);
Light *light = GetLight(sceneNode);
DVASSERT(light);
propertyList->AddSection("property.lightnode.light", GetHeaderState("property.lightnode.light", true));
propertyList->AddComboProperty("property.lightnode.type", types);
propertyList->SetComboPropertyIndex("property.lightnode.type", light->GetType());
propertyList->AddColorProperty("property.lightnode.ambient.color");
propertyList->SetColorPropertyValue("property.lightnode.ambient.color", light->GetAmbientColor());
propertyList->AddColorProperty("property.lightnode.diffuse.color");
propertyList->SetColorPropertyValue("property.lightnode.diffuse.color", light->GetDiffuseColor());
propertyList->AddColorProperty("property.lightnode.specular.color");
propertyList->SetColorPropertyValue("property.lightnode.specular.color", light->GetSpecularColor());
propertyList->AddFloatProperty("property.lightnode.intensity");
propertyList->SetFloatPropertyValue("property.lightnode.intensity", light->GetIntensity());
//propertyList->AddFloatProperty("property.lightnode.material.shininess", light->GetShininess())
propertyList->AddSection("property.lightnode.staticlight", GetHeaderState("property.lightnode.staticlight", true));
propertyList->AddBoolProperty("property.staticlight.enable");
propertyList->SetBoolPropertyValue("property.staticlight.enable", sceneNode->GetCustomProperties()->GetBool("editor.staticlight.enable", true));
propertyList->AddBoolProperty("Cast shadows");
propertyList->SetBoolPropertyValue("Cast shadows", sceneNode->GetCustomProperties()->GetBool("editor.staticlight.castshadows", true));
propertyList->AddFloatProperty("Intensity");
propertyList->SetFloatPropertyValue("Intensity", sceneNode->GetCustomProperties()->GetFloat("editor.intensity", 1.f));
propertyList->AddFloatProperty("Falloff cutoff");
propertyList->SetFloatPropertyValue("Falloff cutoff", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.falloffcutoff", 1000.f));
propertyList->AddFloatProperty("Falloff exponent");
propertyList->SetFloatPropertyValue("Falloff exponent", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.falloffexponent", 1.f));
if(Light::TYPE_DIRECTIONAL == light->GetType())
{
propertyList->AddFloatProperty("Shadow angle");
propertyList->SetFloatPropertyValue("Shadow angle", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.shadowangle", 0.f));
propertyList->AddIntProperty("Shadow samples");
propertyList->SetIntPropertyValue("Shadow samples", sceneNode->GetCustomProperties()->GetInt32("editor.staticlight.shadowsamples", 1));
}
else if(Light::TYPE_POINT == light->GetType())
{
propertyList->AddFloatProperty("Shadow radius");
propertyList->SetFloatPropertyValue("Shadow radius", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.shadowradius", 0.f));
}
propertyList->AddSection("property.lightnode.dynamiclight", GetHeaderState("property.lightnode.dynamiclight", true));
propertyList->AddBoolProperty("property.dynamiclight.enable");
propertyList->SetBoolPropertyValue("property.dynamiclight.enable", sceneNode->GetCustomProperties()->GetBool("editor.dynamiclight.enable", true));
}
示例5: InitFields
void GameObjectLightComponentWidget::InitFields()
{
Light* light = nullptr;
////////////////////////////////////////
// Set Ready to false, so Light cannot change
// properties while been initialized
m_IsReady = false;
////////////////////////////////////////
// Check Engine Viewer
AEAssert(m_EngineViewer != nullptr);
if (m_EngineViewer == nullptr)
{
return;
}
////////////////////////////////////////
// Verify LOC and Get Light Object
light = GetLight();
if(light == nullptr)
{
AETODO("Add log");
return;
}
////////////////////////////////////////
// Set Light Type
SetLightTypeComboBoxIndex(light->GetLightType());
////////////////////////////////////////
// Set Enabled
m_GameObjectLightComponentWidgetQtUI.m_Enabled->setChecked(light->IsEnabled());
////////////////////////////////////////
// Set Intensity
m_GameObjectLightComponentWidgetQtUI.m_IntensitySB->setValue(static_cast<double>(light->GetIntensity()));
////////////////////////////////////////
// Set Color
QColor qColor = AEQTHelpers::GetQColorFromColor(light->GetColor());
SetColorToColorWidget(qColor);
////////////////////////////////////////
// Set Near and Far Attenuation
m_GameObjectLightComponentWidgetQtUI.m_NearAttSB->setValue(static_cast<double>(light->GetNearAttenuation()));
m_GameObjectLightComponentWidgetQtUI.m_FarAttSB->setValue(static_cast<double>(light->GetFarAttenuation()));
////////////////////////////////////////
// Set Shadow Enabled
m_GameObjectLightComponentWidgetQtUI.m_ShadowEnabled->setChecked(light->IsShadowEnabled());
m_GameObjectLightComponentWidgetQtUI.m_DrawFrustum->setEnabled(light->IsShadowEnabled());
////////////////////////////////////////
// Enable/Visibility of Angle options
if(light->GetLightType() == LightType::Spot)
{
m_GameObjectLightComponentWidgetQtUI.m_LabelAngle->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_LabelFalloffAngle->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setVisible(true);
////////////////////////////////////////
// Get Spot Light
SpotLight* spotLight = reinterpret_cast<SpotLight*>(light);
////////////////////////////////////////
// Set Angle and Fall out Angle
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setValue(static_cast<double>(spotLight->GetAngle()));
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setValue(static_cast<double>(spotLight->GetFallOffAngle()));
}
else
{
m_GameObjectLightComponentWidgetQtUI.m_LabelAngle->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_LabelFalloffAngle->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setVisible(false);
}
////////////////////////////////////////
// Enable/Visibility of Draw Frustum Cascades
if (light->GetLightType() == LightType::Directional)
{
m_GameObjectLightComponentWidgetQtUI.m_DrawCascadeFrustums->setVisible(true);
}
else
{
m_GameObjectLightComponentWidgetQtUI.m_DrawCascadeFrustums->setVisible(false);
}
////////////////////////////////////////
// Light is Ready to change properties
m_IsReady = true;
}