本文整理汇总了C++中Light::GetShadowIntensity方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::GetShadowIntensity方法的具体用法?C++ Light::GetShadowIntensity怎么用?C++ Light::GetShadowIntensity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light::GetShadowIntensity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Prepare
//.........这里部分代码省略.........
float mulY = (float)(faceHeight - 4) / height;
float addX = 2.5f / width;
float addY = 2.5f / height;
#endif
// If using 4 shadow samples, offset the position diagonally by half pixel
if (renderer->GetShadowQuality() & SHADOWQUALITY_HIGH_16BIT)
{
addX -= 0.5f / width;
addY -= 0.5f / height;
}
graphics->SetShaderParameter(PSP_SHADOWCUBEADJUST, Vector4(mulX, mulY, addX, addY));
}
{
// Calculate shadow camera depth parameters for point light shadows and shadow fade parameters for
// directional light shadows, stored in the same uniform
Camera* shadowCamera = lightQueue_->shadowSplits_[0].shadowCamera_;
float nearClip = shadowCamera->GetNearClip();
float farClip = shadowCamera->GetFarClip();
float q = farClip / (farClip - nearClip);
float r = -q * nearClip;
const CascadeParameters& parameters = light->GetShadowCascade();
float viewFarClip = camera_->GetFarClip();
float shadowRange = parameters.GetShadowRange();
float fadeStart = parameters.fadeStart_ * shadowRange / viewFarClip;
float fadeEnd = shadowRange / viewFarClip;
float fadeRange = fadeEnd - fadeStart;
graphics->SetShaderParameter(PSP_SHADOWDEPTHFADE, Vector4(q, r, fadeStart, 1.0f / fadeRange));
}
{
float intensity = light->GetShadowIntensity();
float fadeStart = light->GetShadowFadeDistance();
float fadeEnd = light->GetShadowDistance();
if (fadeStart > 0.0f && fadeEnd > 0.0f && fadeEnd > fadeStart)
intensity = Lerp(intensity, 1.0f, Clamp((light->GetDistance() - fadeStart) / (fadeEnd - fadeStart), 0.0f, 1.0f));
float pcfValues = (1.0f - intensity);
float samples = renderer->GetShadowQuality() >= SHADOWQUALITY_HIGH_16BIT ? 4.0f : 1.0f;
graphics->SetShaderParameter(PSP_SHADOWINTENSITY, Vector4(pcfValues / samples, intensity, 0.0f, 0.0f));
}
float sizeX = 1.0f / (float)shadowMap->GetWidth();
float sizeY = 1.0f / (float)shadowMap->GetHeight();
graphics->SetShaderParameter(PSP_SHADOWMAPINVSIZE, Vector4(sizeX, sizeY, 0.0f, 0.0f));
Vector4 lightSplits(M_LARGE_VALUE, M_LARGE_VALUE, M_LARGE_VALUE, M_LARGE_VALUE);
if (lightQueue_->shadowSplits_.Size() > 1)
lightSplits.x_ = lightQueue_->shadowSplits_[0].farSplit_ / camera_->GetFarClip();
if (lightQueue_->shadowSplits_.Size() > 2)
lightSplits.y_ = lightQueue_->shadowSplits_[1].farSplit_ / camera_->GetFarClip();
if (lightQueue_->shadowSplits_.Size() > 3)
lightSplits.z_ = lightQueue_->shadowSplits_[2].farSplit_ / camera_->GetFarClip();
graphics->SetShaderParameter(PSP_SHADOWSPLITS, lightSplits);
}
}
// Set material-specific shader parameters and textures
if (material_)
{
if (graphics->NeedParameterUpdate(SP_MATERIAL, material_))
{
// Update shader parameter animations
示例2: Prepare
//.........这里部分代码省略.........
float mulY = (float)(faceHeight - 4) / height;
float addX = 2.5f / width;
float addY = 2.5f / height;
#endif
// If using 4 shadow samples, offset the position diagonally by half pixel
if (renderer->GetShadowQuality() == SHADOWQUALITY_PCF_16BIT || renderer->GetShadowQuality() == SHADOWQUALITY_PCF_24BIT)
{
addX -= 0.5f / width;
addY -= 0.5f / height;
}
graphics->SetShaderParameter(PSP_SHADOWCUBEADJUST, Vector4(mulX, mulY, addX, addY));
}
{
// Calculate shadow camera depth parameters for point light shadows and shadow fade parameters for
// directional light shadows, stored in the same uniform
Camera* shadowCamera = lightQueue_->shadowSplits_[0].shadowCamera_;
float nearClip = shadowCamera->GetNearClip();
float farClip = shadowCamera->GetFarClip();
float q = farClip / (farClip - nearClip);
float r = -q * nearClip;
const CascadeParameters& parameters = light->GetShadowCascade();
float viewFarClip = camera->GetFarClip();
float shadowRange = parameters.GetShadowRange();
float fadeStart = parameters.fadeStart_ * shadowRange / viewFarClip;
float fadeEnd = shadowRange / viewFarClip;
float fadeRange = fadeEnd - fadeStart;
graphics->SetShaderParameter(PSP_SHADOWDEPTHFADE, Vector4(q, r, fadeStart, 1.0f / fadeRange));
}
{
float intensity = light->GetShadowIntensity();
float fadeStart = light->GetShadowFadeDistance();
float fadeEnd = light->GetShadowDistance();
if (fadeStart > 0.0f && fadeEnd > 0.0f && fadeEnd > fadeStart)
intensity =
Lerp(intensity, 1.0f, Clamp((light->GetDistance() - fadeStart) / (fadeEnd - fadeStart), 0.0f, 1.0f));
float pcfValues = (1.0f - intensity);
float samples = 1.0f;
if (renderer->GetShadowQuality() == SHADOWQUALITY_PCF_16BIT || renderer->GetShadowQuality() == SHADOWQUALITY_PCF_24BIT)
samples = 4.0f;
graphics->SetShaderParameter(PSP_SHADOWINTENSITY, Vector4(pcfValues / samples, intensity, 0.0f, 0.0f));
}
float sizeX = 1.0f / (float)shadowMap->GetWidth();
float sizeY = 1.0f / (float)shadowMap->GetHeight();
graphics->SetShaderParameter(PSP_SHADOWMAPINVSIZE, Vector2(sizeX, sizeY));
Vector4 lightSplits(M_LARGE_VALUE, M_LARGE_VALUE, M_LARGE_VALUE, M_LARGE_VALUE);
if (lightQueue_->shadowSplits_.Size() > 1)
lightSplits.x_ = lightQueue_->shadowSplits_[0].farSplit_ / camera->GetFarClip();
if (lightQueue_->shadowSplits_.Size() > 2)
lightSplits.y_ = lightQueue_->shadowSplits_[1].farSplit_ / camera->GetFarClip();
if (lightQueue_->shadowSplits_.Size() > 3)
lightSplits.z_ = lightQueue_->shadowSplits_[2].farSplit_ / camera->GetFarClip();
graphics->SetShaderParameter(PSP_SHADOWSPLITS, lightSplits);
if (graphics->HasShaderParameter(PSP_VSMSHADOWPARAMS))
graphics->SetShaderParameter(PSP_VSMSHADOWPARAMS, renderer->GetVSMShadowParameters());
if (light->GetShadowBias().normalOffset_ > 0.0f)
{
Vector4 normalOffsetScale(Vector4::ZERO);