本文整理汇总了C++中FIntRect::InflateRect方法的典型用法代码示例。如果您正苦于以下问题:C++ FIntRect::InflateRect方法的具体用法?C++ FIntRect::InflateRect怎么用?C++ FIntRect::InflateRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FIntRect
的用法示例。
在下文中一共展示了FIntRect::InflateRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetParameters
void SetParameters(const FRenderingCompositePassContext& Context)
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
FGlobalShader::SetParameters(ShaderRHI, Context.View);
DeferredParameters.Set(ShaderRHI, Context.View);
{
bool bFiltered = false;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MotionBlurFiltering"));
bFiltered = CVar->GetValueOnRenderThread() != 0;
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if(bFiltered)
{
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Border,AM_Border,AM_Clamp>::GetRHI());
}
else
{
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Border,AM_Border,AM_Clamp>::GetRHI());
}
}
if( Context.View.Family->EngineShowFlags.CameraInterpolation )
{
// Instead of finding the world space position of the current pixel, calculate the world space position offset by the camera position,
// then translate by the difference between last frame's camera position and this frame's camera position,
// then apply the rest of the transforms. This effectively avoids precision issues near the extents of large levels whose world space position is very large.
FVector ViewOriginDelta = Context.View.ViewMatrices.ViewOrigin - Context.View.PrevViewMatrices.ViewOrigin;
SetShaderValue(ShaderRHI, PrevViewProjMatrix, FTranslationMatrix(ViewOriginDelta) * Context.View.PrevViewRotationProjMatrix);
}
else
{
SetShaderValue( ShaderRHI, PrevViewProjMatrix, Context.View.ViewMatrices.GetViewRotationProjMatrix() );
}
TRefCountPtr<IPooledRenderTarget> InputPooledElement = Context.Pass->GetInput(ePId_Input0)->GetOutput()->RequestInput();
// to mask out samples from outside of the view
{
FIntPoint BufferSize = GSceneRenderTargets.GetBufferSizeXY();
FVector2D InvBufferSize(1.0f / BufferSize.X, 1.0f / BufferSize.Y);
FIntRect ClipRect = Context.View.ViewRect;
// to avoid leaking in content from the outside because of bilinear filtering, shrink
ClipRect.InflateRect(-1);
FVector2D MinUV(ClipRect.Min.X * InvBufferSize.X, ClipRect.Min.Y * InvBufferSize.Y);
FVector2D MaxUV(ClipRect.Max.X * InvBufferSize.X, ClipRect.Max.Y * InvBufferSize.Y);
FVector2D SizeUV = MaxUV - MinUV;
FVector2D Mul(1.0f / SizeUV.X, 1.0f / SizeUV.Y);
FVector2D Add = - MinUV * Mul;
FVector4 TextureViewMadValue(Mul.X, Mul.Y, Add.X, Add.Y);
SetShaderValue(ShaderRHI, TextureViewMad, TextureViewMadValue);
}
{
const float SizeX = Context.View.ViewRect.Width();
const float SizeY = Context.View.ViewRect.Height();
const float AspectRatio = SizeX / SizeY;
const float InvAspectRatio = SizeY / SizeX;
const FSceneViewState* ViewState = (FSceneViewState*) Context.View.State;
float MotionBlurTimeScale = ViewState ? ViewState->MotionBlurTimeScale : 1.0f;
float ViewMotionBlurScale = 0.5f * MotionBlurTimeScale * Context.View.FinalPostProcessSettings.MotionBlurAmount;
// MotionBlurInstanceScale was needed to hack some cases where motion blur wasn't working well, this shouldn't be needed any more, can clean this up later
float MotionBlurInstanceScale = 1;
float ObjectMotionBlurScale = MotionBlurInstanceScale * ViewMotionBlurScale;
// 0:no 1:full screen width, percent conversion
float MaxVelocity = Context.View.FinalPostProcessSettings.MotionBlurMax / 100.0f;
float InvMaxVelocity = 1.0f / MaxVelocity;
// *2 to convert to -1..1 -1..1 screen space
// / MaxFraction to map screenpos to -1..1 normalized MaxFraction
FVector4 MotionBlurParametersValue(
ObjectMotionBlurScale * InvMaxVelocity,
- ObjectMotionBlurScale * InvMaxVelocity * InvAspectRatio,
MaxVelocity * 2,
- MaxVelocity * 2 * AspectRatio);
SetShaderValue(ShaderRHI, MotionBlurParameters, MotionBlurParametersValue);
}
}
示例2: Process
void FRCPassPostProcessSelectionOutlineColor::Process(FRenderingCompositePassContext& Context)
{
#if WITH_EDITOR
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessSelectionOutlineBuffer);
const FPooledRenderTargetDesc* SceneColorInputDesc = GetInputDesc(ePId_Input0);
if(!SceneColorInputDesc)
{
// input is not hooked up correctly
return;
}
const FViewInfo& View = Context.View;
FIntRect ViewRect = View.ViewRect;
FIntPoint SrcSize = SceneColorInputDesc->Extent;
// Get the output render target
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the render target/viewport.
SetRenderTarget(Context.RHICmdList, FTextureRHIParamRef(), DestRenderTarget.TargetableTexture);
// This is a reversed Z depth surface, so 0.0f is the far plane.
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
Context.SetViewportAndCallRHI(ViewRect);
if (View.Family->EngineShowFlags.Selection)
{
FHitProxyDrawingPolicyFactory::ContextType FactoryContext;
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetBlendState(TStaticBlendStateWriteMask<CW_NONE, CW_NONE, CW_NONE, CW_NONE>::GetRHI());
// Note that the stencil value will overflow with enough selected objects
FEditorSelectionDrawingPolicy::ResetStencilValues();
// Run selection pass on static elements
FScene* Scene = View.Family->Scene->GetRenderScene();
if(Scene)
{
Scene->EditorSelectionDrawList.DrawVisible(Context.RHICmdList, View, View.StaticMeshEditorSelectionMap, View.StaticMeshBatchVisibility);
}
for (int32 MeshBatchIndex = 0; MeshBatchIndex < View.DynamicMeshElements.Num(); MeshBatchIndex++)
{
const FMeshBatchAndRelevance& MeshBatchAndRelevance = View.DynamicMeshElements[MeshBatchIndex];
const FPrimitiveSceneProxy* PrimitiveSceneProxy = MeshBatchAndRelevance.PrimitiveSceneProxy;
// Selected actors should be subdued if any component is individually selected
bool bActorSelectionColorIsSubdued = View.bHasSelectedComponents;
if (PrimitiveSceneProxy->IsSelected() && MeshBatchAndRelevance.Mesh->bUseSelectionOutline && PrimitiveSceneProxy->WantsSelectionOutline())
{
int32 StencilValue = 1;
if(PrimitiveSceneProxy->GetOwnerName() != NAME_BSP)
{
StencilValue = FEditorSelectionDrawingPolicy::GetStencilValue(View, PrimitiveSceneProxy);
}
// Note that the stencil value will overflow with enough selected objects
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), StencilValue);
const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh;
FHitProxyDrawingPolicyFactory::DrawDynamicMesh(Context.RHICmdList, View, FactoryContext, MeshBatch, false, true, MeshBatchAndRelevance.PrimitiveSceneProxy, MeshBatch.BatchHitProxyId);
}
}
// to get an outline around the objects if it's partly outside of the screen
{
FIntRect InnerRect = ViewRect;
// 1 as we have an outline that is that thick
InnerRect.InflateRect(-1);
// We could use Clear with InnerRect but this is just an optimization - on some hardware it might do a full clear (and we cannot disable yet)
// RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, InnerRect);
// so we to 4 clears - one for each border.
// top
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, ViewRect.Max.X, InnerRect.Min.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// bottom
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, InnerRect.Max.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// left
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, InnerRect.Min.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// right
Context.RHICmdList.SetScissorRect(true, InnerRect.Max.X, ViewRect.Min.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
Context.RHICmdList.SetScissorRect(false, 0, 0, 0, 0);
}
}
// Resolve to the output
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
#endif
//.........这里部分代码省略.........
示例3: Process
void FRCPassPostProcessSelectionOutlineColor::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessSelectionOutlineBuffer);
const FPooledRenderTargetDesc* SceneColorInputDesc = GetInputDesc(ePId_Input0);
if(!SceneColorInputDesc)
{
// input is not hooked up correctly
return;
}
const FViewInfo& View = Context.View;
FIntRect ViewRect = View.ViewRect;
FIntPoint SrcSize = SceneColorInputDesc->Extent;
// Get the output render target
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the render target/viewport.
SetRenderTarget(Context.RHICmdList, FTextureRHIParamRef(), DestRenderTarget.TargetableTexture);
// This is a reversed Z depth surface, so 0.0f is the far plane.
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
Context.SetViewportAndCallRHI(ViewRect);
if (View.Family->EngineShowFlags.Selection)
{
FHitProxyDrawingPolicyFactory::ContextType FactoryContext;
//@todo - use memstack
TMap<FName, int32> ActorNameToStencilIndex;
TMap<const FPrimitiveSceneProxy*, int32> IndividuallySelectedProxies;
ActorNameToStencilIndex.Add(NAME_BSP, 1);
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetBlendState(TStaticBlendStateWriteMask<CW_NONE, CW_NONE, CW_NONE, CW_NONE>::GetRHI());
for (int32 MeshBatchIndex = 0; MeshBatchIndex < View.DynamicMeshElements.Num(); MeshBatchIndex++)
{
const FMeshBatchAndRelevance& MeshBatchAndRelevance = View.DynamicMeshElements[MeshBatchIndex];
const FPrimitiveSceneProxy* PrimitiveSceneProxy = MeshBatchAndRelevance.PrimitiveSceneProxy;
#if WITH_EDITOR
// Selected actors should be subdued if any component is individually selected
bool bActorSelectionColorIsSubdued = View.bHasSelectedComponents;
#else
bool bActorSelectionColorIsSubdued = false;
#endif
if (PrimitiveSceneProxy->IsSelected() && MeshBatchAndRelevance.Mesh->bUseSelectionOutline)
{
const int32* AssignedStencilIndexPtr = PrimitiveSceneProxy->IsIndividuallySelected() ? IndividuallySelectedProxies.Find( PrimitiveSceneProxy ) : ActorNameToStencilIndex.Find(PrimitiveSceneProxy->GetOwnerName());
if (!AssignedStencilIndexPtr)
{
if( PrimitiveSceneProxy->IsIndividuallySelected() )
{
// Any component that is individually selected should have a stencil value of < 128 so that it can have a unique color. We offset the value by 2 because 0 means no selection and 1 is for bsp
int32 StencilValue = IndividuallySelectedProxies.Num() % 126 + 2;
AssignedStencilIndexPtr = &IndividuallySelectedProxies.Add(PrimitiveSceneProxy, StencilValue);
}
else
{
// If we are subduing actor color highlight then use the top level bits to indicate that to the shader.
int32 StencilValue = bActorSelectionColorIsSubdued ? ActorNameToStencilIndex.Num() % 128 + 128 : ActorNameToStencilIndex.Num() % 126 + 2;
AssignedStencilIndexPtr = &ActorNameToStencilIndex.Add(PrimitiveSceneProxy->GetOwnerName(), StencilValue);
}
}
// Note that the stencil value will overflow with enough selected objects
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), *AssignedStencilIndexPtr);
const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh;
FHitProxyDrawingPolicyFactory::DrawDynamicMesh(Context.RHICmdList, View, FactoryContext, MeshBatch, false, true, MeshBatchAndRelevance.PrimitiveSceneProxy, MeshBatch.BatchHitProxyId);
}
}
// to get an outline around the objects if it's partly outside of the screen
{
FIntRect InnerRect = ViewRect;
// 1 as we have an outline that is that thick
InnerRect.InflateRect(-1);
// We could use Clear with InnerRect but this is just an optimization - on some hardware it might do a full clear (and we cannot disable yet)
// RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, InnerRect);
// so we to 4 clears - one for each border.
// top
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, ViewRect.Max.X, InnerRect.Min.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// bottom
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, InnerRect.Max.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// left
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, InnerRect.Min.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
// right
Context.RHICmdList.SetScissorRect(true, InnerRect.Max.X, ViewRect.Min.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, (float)ERHIZBuffer::FarPlane, true, 0, FIntRect());
//.........这里部分代码省略.........
示例4: Process
//.........这里部分代码省略.........
}
// This is a reversed Z depth surface, using CF_GreaterEqual.
// Note that the stencil value will overflow with enough selected objects
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_GreaterEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), *AssignedStencilIndexPtr);
const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh;
FHitProxyDrawingPolicyFactory::DrawDynamicMesh(Context.RHICmdList, View, FactoryContext, MeshBatch, false, true, MeshBatchAndRelevance.PrimitiveSceneProxy, MeshBatch.BatchHitProxyId);
}
}
}
else if (View.VisibleDynamicPrimitives.Num() > 0)
{
TDynamicPrimitiveDrawer<FHitProxyDrawingPolicyFactory> Drawer(Context.RHICmdList, &View, FHitProxyDrawingPolicyFactory::ContextType(), true, false, false, true);
TMultiMap<FName, const FPrimitiveSceneInfo*> PrimitivesByActor;
for (int32 PrimitiveIndex = 0; PrimitiveIndex < View.VisibleDynamicPrimitives.Num();PrimitiveIndex++)
{
const FPrimitiveSceneInfo* PrimitiveSceneInfo = View.VisibleDynamicPrimitives[PrimitiveIndex];
// Only draw the primitive if relevant
if(PrimitiveSceneInfo->Proxy->IsSelected())
{
PrimitivesByActor.Add(PrimitiveSceneInfo->Proxy->GetOwnerName(), PrimitiveSceneInfo);
}
}
if (PrimitivesByActor.Num())
{
// 0 means no object, 1 means BSP so we start with 2
uint32 StencilValue = 2;
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetBlendState(TStaticBlendStateWriteMask<CW_NONE, CW_NONE, CW_NONE, CW_NONE>::GetRHI());
// Sort by actor
TArray<FName> Actors;
PrimitivesByActor.GetKeys(Actors);
for( TArray<FName>::TConstIterator ActorIt(Actors); ActorIt; ++ActorIt )
{
bool bBSP = *ActorIt == NAME_BSP;
if (bBSP)
{
// This is a reversed Z depth surface, using CF_GreaterEqual.
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_GreaterEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), 1);
}
else
{
// This is a reversed Z depth surface, using CF_GreaterEqual.
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<true, CF_GreaterEqual, true, CF_Always, SO_Keep, SO_Keep, SO_Replace>::GetRHI(), StencilValue);
// we want to use 1..255 for all objects, not correct silhouettes after that is acceptable
StencilValue = (StencilValue == 255) ? 2 : (StencilValue + 1);
}
TArray<const FPrimitiveSceneInfo*> Primitives;
PrimitivesByActor.MultiFind(*ActorIt, Primitives);
for( TArray<const FPrimitiveSceneInfo*>::TConstIterator PrimIt(Primitives); PrimIt; ++PrimIt )
{
const FPrimitiveSceneInfo* PrimitiveSceneInfo = *PrimIt;
// Render the object to the stencil/depth buffer
Drawer.SetPrimitive(PrimitiveSceneInfo->Proxy);
PrimitiveSceneInfo->Proxy->DrawDynamicElements(&Drawer, &View);
}
}
}
}
// to get an outline around the objects if it's partly outside of the screen
{
FIntRect InnerRect = ViewRect;
// 1 as we have an outline that is that thick
InnerRect.InflateRect(-1);
// We could use Clear with InnerRect but this is just an optimization - on some hardware it might do a full clear (and we cannot disable yet)
// RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, InnerRect);
// so we to 4 clears - one for each border.
// top
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, ViewRect.Max.X, InnerRect.Min.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, FIntRect());
// bottom
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, InnerRect.Max.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, FIntRect());
// left
Context.RHICmdList.SetScissorRect(true, ViewRect.Min.X, ViewRect.Min.Y, InnerRect.Min.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, FIntRect());
// right
Context.RHICmdList.SetScissorRect(true, InnerRect.Max.X, ViewRect.Min.Y, ViewRect.Max.X, ViewRect.Max.Y);
Context.RHICmdList.Clear(false, FLinearColor(0, 0, 0, 0), true, 0.0f, true, 0, FIntRect());
Context.RHICmdList.SetScissorRect(false, 0, 0, 0, 0);
}
}
// Resolve to the output
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}