本文整理汇总了C++中FIntRect::Width方法的典型用法代码示例。如果您正苦于以下问题:C++ FIntRect::Width方法的具体用法?C++ FIntRect::Width怎么用?C++ FIntRect::Width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FIntRect
的用法示例。
在下文中一共展示了FIntRect::Width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InternalClearMRT
void FVulkanCommandListContext::InternalClearMRT(FVulkanCmdBuffer* CmdBuffer, bool bClearColor, int32 NumClearColors, const FLinearColor* ClearColorArray, bool bClearDepth, float Depth, bool bClearStencil, uint32 Stencil, FIntRect ExcludeRect)
{
#if VULKAN_USE_NEW_RENDERPASSES
const VkExtent2D& Extents = RenderPassState.CurrentRenderPass->GetLayout().GetExtent2D();
if (ExcludeRect.Min.X == 0 && ExcludeRect.Width() == Extents.width && ExcludeRect.Min.Y == 0 && Extents.height)
{
//if (ForceFullScreen == EForceFullScreenClear::EDoNotForce)
{
return;
}
//else
{
//ensureMsgf(false, TEXT("Forced Full Screen Clear ignoring Exclude Rect Restriction"));
}
}
ensure(ExcludeRect.Area() == 0);
if (RenderPassState.CurrentRenderPass)
{
VkClearRect Rect;
FMemory::Memzero(Rect);
Rect.rect.offset.x = 0;
Rect.rect.offset.y = 0;
Rect.rect.extent = Extents;
VkClearAttachment Attachments[MaxSimultaneousRenderTargets + 1];
FMemory::Memzero(Attachments);
uint32 NumAttachments = NumClearColors;
if (bClearColor)
{
for (int32 i = 0; i < NumClearColors; ++i)
{
Attachments[i].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Attachments[i].colorAttachment = i;
Attachments[i].clearValue.color.float32[0] = ClearColorArray[i].R;
Attachments[i].clearValue.color.float32[1] = ClearColorArray[i].G;
Attachments[i].clearValue.color.float32[2] = ClearColorArray[i].B;
Attachments[i].clearValue.color.float32[3] = ClearColorArray[i].A;
}
}
if (bClearDepth || bClearStencil)
{
Attachments[NumClearColors].aspectMask = bClearDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : 0;
Attachments[NumClearColors].aspectMask |= bClearStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0;
Attachments[NumClearColors].colorAttachment = 0;
Attachments[NumClearColors].clearValue.depthStencil.depth = Depth;
Attachments[NumClearColors].clearValue.depthStencil.stencil = Stencil;
++NumAttachments;
}
VulkanRHI::vkCmdClearAttachments(CmdBuffer->GetHandle(), NumAttachments, Attachments, 1, &Rect);
}
else
{
ensure(0);
//VulkanRHI::vkCmdClearColorImage(CmdBuffer->GetHandle(), )
}
#else
#if VULKAN_ALLOW_MIDPASS_CLEAR
const VkExtent2D& Extents = PendingState->GetRenderPass().GetLayout().GetExtent2D();
if (ExcludeRect.Min.X == 0 && ExcludeRect.Width() == Extents.width && ExcludeRect.Min.Y == 0 && Extents.height)
{
//if (ForceFullScreen == EForceFullScreenClear::EDoNotForce)
{
return;
}
//else
{
//ensureMsgf(false, TEXT("Forced Full Screen Clear ignoring Exclude Rect Restriction"));
}
}
ensure(ExcludeRect.Area() == 0);
VkClearRect Rect;
FMemory::Memzero(Rect);
Rect.rect.offset.x = 0;
Rect.rect.offset.y = 0;
Rect.rect.extent = PendingState->GetRenderPass().GetLayout().GetExtent2D();
VkClearAttachment Attachments[MaxSimultaneousRenderTargets + 1];
FMemory::Memzero(Attachments);
uint32 NumAttachments = NumClearColors;
if (bClearColor)
{
for (int32 i = 0; i < NumClearColors; ++i)
{
Attachments[i].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
Attachments[i].colorAttachment = i;
Attachments[i].clearValue.color.float32[0] = ClearColorArray[i].R;
Attachments[i].clearValue.color.float32[1] = ClearColorArray[i].G;
Attachments[i].clearValue.color.float32[2] = ClearColorArray[i].B;
Attachments[i].clearValue.color.float32[3] = ClearColorArray[i].A;
}
}
//.........这里部分代码省略.........
示例2: Process
void FRCPassPostProcessSubsurfaceRecombine::Process(FRenderingCompositePassContext& Context)
{
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
check(InputDesc);
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = SceneContext.GetBufferSizeXY();
check(DestSize.X);
check(DestSize.Y);
check(SrcSize.X);
check(SrcSize.Y);
FIntRect SrcRect = FIntRect(0, 0, InputDesc->Extent.X, InputDesc->Extent.Y);
FIntRect DestRect = View.ViewRect;
TRefCountPtr<IPooledRenderTarget>& SceneColor = SceneContext.GetSceneColor();
const FSceneRenderTargetItem& DestRenderTarget = SceneColor->GetRenderTargetItem();
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
Context.RHICmdList.SetBlendState(TStaticBlendState<CW_RGBA,BO_Add,BF_SourceAlpha,BF_InverseSourceAlpha,BO_Add,BF_SourceAlpha,BF_InverseSourceAlpha>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
bool bDoSpecularCorrection = DoSpecularCorrection();
SCOPED_DRAW_EVENTF(Context.RHICmdList, SubsurfacePass, TEXT("SubsurfacePassRecombine#%d"), (int32)bDoSpecularCorrection);
if(bDoSpecularCorrection)
{
SetSubsurfaceRecombineShader<1>(Context, VertexShader);
}
else
{
SetSubsurfaceRecombineShader<0>(Context, VertexShader);
}
DrawPostProcessPass(
Context.RHICmdList,
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestSize,
SrcSize,
*VertexShader,
View.StereoPass,
Context.HasHmdMesh(),
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
示例3: DisplaySubtitle
void FSubtitleManager::DisplaySubtitle( FCanvas* Canvas, FActiveSubtitle* Subtitle, FIntRect& Parms, const FLinearColor& Color )
{
// These should be valid in here
check( GEngine );
check( Canvas );
CurrentSubtitleHeight = 0.0f;
// This can be NULL when there's an asset mixup (especially with localisation)
if( !GEngine->GetSubtitleFont() )
{
UE_LOG(LogSubtitle, Warning, TEXT( "NULL GEngine->GetSubtitleFont() - subtitles not rendering!" ) );
return;
}
float FontHeight = GEngine->GetSubtitleFont()->GetMaxCharHeight();
float HeightTest = Canvas->GetRenderTarget()->GetSizeXY().Y;
int32 SubtitleHeight = FMath::TruncToInt( ( FontHeight * MULTILINE_SPACING_SCALING ) );
FIntRect BackgroundBoxOffset = DrawStringOutlineBoxOffset;
// Needed to add a drop shadow and doing all 4 sides was the only way to make them look correct. If this shows up as a framerate hit we'll have to think of a different way of dealing with this.
if( Subtitle->bSingleLine )
{
if ( !( Subtitle->Subtitles[Subtitle->Index].Text.IsEmpty() ) )
{
// Display lines up from the bottom of the region
Parms.Max.Y -= SUBTITLE_CHAR_HEIGHT;
FCanvasTextItem TextItem( FVector2D( Parms.Min.X + ( Parms.Width() / 2 ), Parms.Max.Y ), Subtitle->Subtitles[ Subtitle->Index ].Text , GEngine->GetSubtitleFont(), Color );
TextItem.Depth = SUBTITLE_SCREEN_DEPTH_FOR_3D;
TextItem.bOutlined = true;
TextItem.bCentreX = true;
TextItem.OutlineColor = FLinearColor::Black;
Canvas->DrawItem( TextItem );
CurrentSubtitleHeight += SubtitleHeight;
}
}
else
{
for( int32 Idx = Subtitle->Subtitles.Num() - 1; Idx >= 0; Idx-- )
{
// Display lines up from the bottom of the region
if ( !( Subtitle->Subtitles[Idx].Text.IsEmpty() ) )
{
FCanvasTextItem TextItem( FVector2D( Parms.Min.X + ( Parms.Width() / 2 ), Parms.Max.Y ), Subtitle->Subtitles[ Subtitle->Index ].Text, GEngine->GetSubtitleFont(), Color );
TextItem.Depth = SUBTITLE_SCREEN_DEPTH_FOR_3D;
TextItem.bOutlined = true;
TextItem.bCentreX = true;
TextItem.OutlineColor = FLinearColor::Black;
Canvas->DrawItem( TextItem );
Parms.Max.Y -= SubtitleHeight;
CurrentSubtitleHeight += SubtitleHeight;
// Don't overlap subsequent boxes...
BackgroundBoxOffset.Max.Y = BackgroundBoxOffset.Min.Y;
}
}
}
}
示例4: Process
void FRCPassPostProcessMaterial::Process(FRenderingCompositePassContext& Context)
{
FMaterialRenderProxy* Proxy = MaterialInterface->GetRenderProxy(false);
check(Proxy);
const FMaterial* Material = Proxy->GetMaterial(Context.View.GetFeatureLevel());
check(Material);
SCOPED_DRAW_EVENTF(Context.RHICmdList, PostProcessMaterial, TEXT("PostProcessMaterial Material=%s"), *Material->GetFriendlyName());
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
// hacky cast
FRenderingCompositePassContext RenderingCompositePassContext(Context.RHICmdList, (FViewInfo&)View);
RenderingCompositePassContext.Pass = this;
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.ViewRect;
FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIParamRef());
if( ViewFamily.RenderTarget->GetRenderTargetTexture() != DestRenderTarget.TargetableTexture )
{
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, View.ViewRect);
}
Context.SetViewportAndCallRHI(View.ViewRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
float ScaleX = 1.0f / InputDesc->Extent.X;
float ScaleY = 1.0f / InputDesc->Extent.Y;
const FMaterialShaderMap* MaterialShaderMap = Material->GetRenderingThreadShaderMap();
FPostProcessMaterialPS* PixelShader = MaterialShaderMap->GetShader<FPostProcessMaterialPS>();
FPostProcessMaterialVS* VertexShader = MaterialShaderMap->GetShader<FPostProcessMaterialVS>();
Context.RHICmdList.SetLocalBoundShaderState(Context.RHICmdList.BuildLocalBoundShaderState(GetVertexDeclarationFVector4(), VertexShader->GetVertexShader(), FHullShaderRHIRef(), FDomainShaderRHIRef(), PixelShader->GetPixelShader(), FGeometryShaderRHIRef()));
VertexShader->SetParameters(Context.RHICmdList, Context);
PixelShader->SetParameters(Context.RHICmdList, Context, MaterialInterface->GetRenderProxy(false));
DrawRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
if(Material->NeedsGBuffer())
{
GSceneRenderTargets.AdjustGBufferRefCount(-1);
}
}
示例5: Process
void FRCPassPostProcessDOFRecombine::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, DOFRecombine);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input1);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const auto FeatureLevel = Context.GetFeatureLevel();
auto ShaderMap = Context.GetShaderMap();
FIntPoint TexSize = InputDesc->Extent;
// usually 1, 2, 4 or 8
uint32 ScaleToFullRes = GSceneRenderTargets.GetBufferSizeXY().X / TexSize.X;
FIntRect HalfResViewRect = View.ViewRect / ScaleToFullRes;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, View.ViewRect);
Context.SetViewportAndCallRHI(View.ViewRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(ShaderMap);
if (bNearBlurEnabled)
{
static FGlobalBoundShaderState BoundShaderState;
TShaderMapRef< FPostProcessDOFRecombinePS<1> > PixelShader(ShaderMap);
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
}
else
{
static FGlobalBoundShaderState BoundShaderState;
TShaderMapRef< FPostProcessDOFRecombinePS<0> > PixelShader(ShaderMap);
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
}
VertexShader->SetParameters(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
View.ViewRect.Width(), View.ViewRect.Height(),
HalfResViewRect.Min.X, HalfResViewRect.Min.Y,
HalfResViewRect.Width(), HalfResViewRect.Height(),
View.ViewRect.Size(),
TexSize,
*VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
示例6: Process
void FRCPassPostProcessNoiseBlur::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(NoiseBlur, DEC_SCENE_ITEMS);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = GSceneRenderTargets.GetBufferSizeXY().X / SrcSize.X;
FIntRect SrcRect = View.ViewRect / ScaleFactor;
FIntRect DestRect = SrcRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
RHISetRenderTarget(DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
RHIClear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, DestRect);
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
// set the state
RHISetBlendState(TStaticBlendState<>::GetRHI());
RHISetRasterizerState(TStaticRasterizerState<>::GetRHI());
RHISetDepthStencilState(TStaticDepthStencilState<false,CF_Always>::GetRHI());
if(Quality == 0)
{
SetNoiseBlurShader<0>(Context, Radius);
}
else if(Quality == 1)
{
SetNoiseBlurShader<1>(Context, Radius);
}
else
{
SetNoiseBlurShader<2>(Context, Radius);
}
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestSize,
SrcSize,
EDRF_UseTriangleOptimization);
RHICopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
示例7: Process
void FRCPassPostProcessMotionBlur::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, MotionBlur);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
FIntPoint TexSize = InputDesc->Extent;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = GSceneRenderTargets.GetBufferSizeXY().X / SrcSize.X;
FIntRect SrcRect = FIntRect::DivideAndRoundUp(View.ViewRect, ScaleFactor);
FIntRect DestRect = SrcRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, SrcRect);
Context.SetViewportAndCallRHI(SrcRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
if(Quality == 1)
{
SetMotionBlurShaderTempl<1>(Context);
}
else if(Quality == 2)
{
SetMotionBlurShaderTempl<2>(Context);
}
else if(Quality == 3)
{
SetMotionBlurShaderTempl<3>(Context);
}
else
{
check(Quality == 4);
SetMotionBlurShaderTempl<4>(Context);
}
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
SrcRect.Width(), SrcRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
SrcRect.Size(),
SrcSize,
*VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
示例8: Process
void FRCPassPostProcessTestImage::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, TestImage);
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.ViewRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessTestImagePS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetPS(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
FSceneRenderTargets::Get(Context.RHICmdList).GetBufferSizeXY(),
*VertexShader,
EDRF_UseTriangleOptimization);
{
// this is a helper class for FCanvas to be able to get screen size
class FRenderTargetTemp : public FRenderTarget
{
public:
const FSceneView& View;
const FTexture2DRHIRef Texture;
FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)
: View(InView), Texture(InTexture)
{
}
virtual FIntPoint GetSizeXY() const
{
return View.ViewRect.Size();
};
virtual const FTexture2DRHIRef& GetRenderTargetTexture() const
{
return Texture;
}
} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, Context.GetFeatureLevel());
float X = 30;
float Y = 8;
const float YStep = 14;
const float ColumnWidth = 250;
FString Line;
Line = FString::Printf(TEXT("Top bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Moving bars using FrameTime"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Black and white raster, Pixel sized, Watch for Moire pattern"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Black and white raster, 2x2 block sized"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Bottom bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" 8 bars near white, 4 right bars should appear as one (HDTV)"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" 8 bars near black, 4 left bars should appear as one (HDTV)"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Linear Greyscale in sRGB from 0 to 255"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Color bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Red, Green, Blue"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Outside:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Moving bars using FrameNumber, Tearing without VSync"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Circles:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
//.........这里部分代码省略.........
示例9: Process
void FRCPassPostProcessDOFSetup::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, DOFSetup);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
uint32 NumRenderTargets = bNearBlurEnabled ? 2 : 1;
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
const auto FeatureLevel = Context.GetFeatureLevel();
auto ShaderMap = Context.GetShaderMap();
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = FSceneRenderTargets::Get(Context.RHICmdList).GetBufferSizeXY().X / SrcSize.X;
FIntRect SrcRect = View.ViewRect / ScaleFactor;
FIntRect DestRect = SrcRect / 2;
const FSceneRenderTargetItem& DestRenderTarget0 = PassOutputs[0].RequestSurface(Context);
const FSceneRenderTargetItem& DestRenderTarget1 = bNearBlurEnabled ? PassOutputs[1].RequestSurface(Context) : FSceneRenderTargetItem();
// Set the view family's render target/viewport.
FTextureRHIParamRef RenderTargets[2] =
{
DestRenderTarget0.TargetableTexture,
DestRenderTarget1.TargetableTexture
};
SetRenderTargets(Context.RHICmdList, NumRenderTargets, RenderTargets, FTextureRHIParamRef(), 0, NULL);
FLinearColor ClearColors[2] =
{
FLinearColor(0, 0, 0, 0),
FLinearColor(0, 0, 0, 0)
};
// is optimized away if possible (RT size=view size, )
Context.RHICmdList.ClearMRT(true, NumRenderTargets, ClearColors, false, 1.0f, false, 0, DestRect);
Context.SetViewportAndCallRHI(DestRect.Min.X, DestRect.Min.Y, 0.0f, DestRect.Max.X + 1, DestRect.Max.Y + 1, 1.0f );
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(ShaderMap);
if (bNearBlurEnabled)
{
const float DOFVignetteSize = FMath::Max(0.0f, View.FinalPostProcessSettings.DepthOfFieldVignetteSize);
// todo: test is conservative, with bad content we would waste a bit of performance
const bool bDOFVignette = DOFVignetteSize < 200.0f;
if(bDOFVignette)
{
static FGlobalBoundShaderState BoundShaderState;
TShaderMapRef< FPostProcessDOFSetupPS<2> > PixelShader(ShaderMap);
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
}
else
{
static FGlobalBoundShaderState BoundShaderState;
TShaderMapRef< FPostProcessDOFSetupPS<1> > PixelShader(ShaderMap);
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
}
}
else
{
static FGlobalBoundShaderState BoundShaderState;
TShaderMapRef< FPostProcessDOFSetupPS<0> > PixelShader(ShaderMap);
SetGlobalBoundShaderState(Context.RHICmdList, FeatureLevel, BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
}
VertexShader->SetParameters(Context);
DrawPostProcessPass(
Context.RHICmdList,
0, 0,
DestRect.Width() + 1, DestRect.Height() + 1,
SrcRect.Min.X, SrcRect.Min.Y,
//.........这里部分代码省略.........
示例10: Draw
void FTileSetEditorViewportClient::Draw(FViewport* Viewport, FCanvas* Canvas)
{
// Clear the viewport
Canvas->Clear(GetBackgroundColor());
// Can only proceed if we have a valid tile set
UPaperTileSet* TileSet = TileSetBeingEdited.Get();
if (TileSet == nullptr)
{
return;
}
if (UTexture2D* Texture = TileSet->GetTileSheetTexture())
{
const bool bUseTranslucentBlend = Texture->HasAlphaChannel();
// Fully stream in the texture before drawing it.
Texture->SetForceMipLevelsToBeResident(30.0f);
Texture->WaitForStreaming();
FLinearColor TextureDrawColor = FLinearColor::White;
{
// Draw the tile sheet texture
const float XPos = -ZoomPos.X * ZoomAmount;
const float YPos = -ZoomPos.Y * ZoomAmount;
const float Width = Texture->GetSurfaceWidth() * ZoomAmount;
const float Height = Texture->GetSurfaceHeight() * ZoomAmount;
Canvas->DrawTile(XPos, YPos, Width, Height, 0.0f, 0.0f, 1.0f, 1.0f, TextureDrawColor, Texture->Resource, bUseTranslucentBlend);
}
const FLinearColor BorderRectangleColor(0.3f, 0.3f, 0.3f, 1.0f);
{
const FIntPoint TextureSize = Texture->GetImportedSize();
const FIntMargin BorderSize = TileSet->GetMargin();
const FIntRect TileSetRegion(BorderSize.Left, BorderSize.Top, TextureSize.X - BorderSize.Right, TextureSize.Y - BorderSize.Bottom);
const float X = (TileSetRegion.Min.X - ZoomPos.X) * ZoomAmount;
const float Y = (TileSetRegion.Min.Y - ZoomPos.Y) * ZoomAmount;
const float W = TileSetRegion.Width() * ZoomAmount;
const float H = TileSetRegion.Height() * ZoomAmount;
FCanvasBoxItem BoxItem(FVector2D(X, Y), FVector2D(W, H));
BoxItem.SetColor(BorderRectangleColor);
Canvas->DrawItem(BoxItem);
}
if (bShowTilesWithCollision || bShowTilesWithMetaData)
{
// Draw an overlay rectangle on top of any tiles that have collision or metadata geometry
const int32 NumTiles = TileSet->GetTileCount();
const FLinearColor CollisionOverlayColor(0.0f, 0.7f, 1.0f, 0.5f);
const FLinearColor MetaDataOverlayColor(1.0f, 0.2f, 0.0f, 0.5f);
const FLinearColor InfoOverlayColor = bShowTilesWithCollision ? CollisionOverlayColor : MetaDataOverlayColor;
const FIntPoint TileSetTileSize(TileSet->GetTileSize());
const float Width = (TileSetTileSize.X - 2) * ZoomAmount;
const float Height = (TileSetTileSize.Y - 2) * ZoomAmount;
for (int32 TileIndex = 0; TileIndex < NumTiles; ++TileIndex)
{
if (const FPaperTileMetadata* TileMetadata = TileSet->GetTileMetadata(TileIndex))
{
const bool bShowDueToCollision = TileMetadata->HasCollision() && bShowTilesWithCollision;
const bool bShowDueToMetaData = TileMetadata->HasMetaData() && bShowTilesWithMetaData;
if (bShowDueToCollision || bShowDueToMetaData)
{
FVector2D TileUV;
TileSet->GetTileUV(TileIndex, /*out*/ TileUV);
const float XPos = (TileUV.X + 1 - ZoomPos.X) * ZoomAmount;
const float YPos = (TileUV.Y + 1 - ZoomPos.Y) * ZoomAmount;
Canvas->DrawTile(XPos, YPos, Width, Height, 0.0f, 0.0f, 1.0f, 1.0f, InfoOverlayColor, GWhiteTexture, /*bUseTranslucentBlend=*/ true);
}
}
}
}
}
// Overlay the selection rectangles
DrawSelectionRectangles(Viewport, Canvas);
if (bHasValidPaintRectangle)
{
const FViewportSelectionRectangle& Rect = ValidPaintRectangle;
const float X = (Rect.TopLeft.X - ZoomPos.X) * ZoomAmount;
const float Y = (Rect.TopLeft.Y - ZoomPos.Y) * ZoomAmount;
const float W = Rect.Dimensions.X * ZoomAmount;
const float H = Rect.Dimensions.Y * ZoomAmount;
FCanvasBoxItem BoxItem(FVector2D(X, Y), FVector2D(W, H));
BoxItem.SetColor(Rect.Color);
Canvas->DrawItem(BoxItem);
}
//.........这里部分代码省略.........
示例11: Process
void FRCPassPostProcessDownsample::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, Downsample);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = FSceneRenderTargets::Get(Context.RHICmdList).GetBufferSizeXY().X / SrcSize.X;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
// InflateSize increases the size of the source/dest rectangle to compensate for bilinear reads and UIBlur pass requirements.
int32 InflateSize;
// if second input is hooked up
if (IsDepthInputAvailable())
{
// also put depth in alpha
InflateSize = 2;
SetShader<2>(Context);
}
else
{
if (Quality == 0)
{
SetShader<0>(Context);
InflateSize = 1;
}
else
{
SetShader<1>(Context);
InflateSize = 2;
}
}
bool bHasCleared = false;
// check if we have to clear the whole surface.
// Otherwise perform the clear when the dest rectangle has been computed.
auto FeatureLevel = Context.View.GetFeatureLevel();
if (FeatureLevel == ERHIFeatureLevel::ES2 || FeatureLevel == ERHIFeatureLevel::ES3_1)
{
Context.RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, FIntRect());
bHasCleared = true;
}
TShaderMapRef<FPostProcessDownsampleVS> VertexShader(Context.GetShaderMap());
FIntRect SrcRect = View.ViewRect / ScaleFactor;
FIntRect DestRect = FIntRect::DivideAndRoundUp(SrcRect, 2);
SrcRect = DestRect * 2;
if (!bHasCleared)
{
Context.RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, DestRect);
}
DrawPostProcessPass(
Context.RHICmdList,
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestSize,
SrcSize,
*VertexShader,
View.StereoPass,
Context.HasHmdMesh(),
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
示例12: Process
void FRCPassPostProcessWeightedSampleSum::Process(FRenderingCompositePassContext& Context)
{
const FSceneView& View = Context.View;
FRenderingCompositeOutput *Input = GetInput(ePId_Input0)->GetOutput();
// input is not hooked up correctly
check(Input);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
// input is not hooked up correctly
check(InputDesc);
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
// e.g. 4 means the input texture is 4x smaller than the buffer size
FIntPoint SrcScaleFactor = SceneContext.GetBufferSizeXY() / SrcSize;
FIntPoint DstScaleFactor = SceneContext.GetBufferSizeXY() / DestSize;
TRefCountPtr<IPooledRenderTarget> InputPooledElement = Input->RequestInput();
check(!InputPooledElement->IsFree());
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
bool bDoFastBlur = DoFastBlur();
FVector2D InvSrcSize(1.0f / SrcSize.X, 1.0f / SrcSize.Y);
// we scale by width because FOV is defined horizontally
float SrcSizeForThisAxis = View.ViewRect.Width() / (float)SrcScaleFactor.X;
if(bDoFastBlur && FilterShape == EFS_Vert)
{
SrcSizeForThisAxis *= 2.0f;
}
// in texel (input resolution), /2 as we use the diameter, 100 as we use percent
float EffectiveBlurRadius = SizeScale * SrcSizeForThisAxis / 2 / 100.0f;
FVector2D BlurOffsets[MAX_FILTER_SAMPLES];
FLinearColor BlurWeights[MAX_FILTER_SAMPLES];
FVector2D OffsetAndWeight[MAX_FILTER_SAMPLES];
const auto FeatureLevel = Context.View.GetFeatureLevel();
// compute 1D filtered samples
uint32 MaxNumSamples = GetMaxNumSamples(FeatureLevel);
uint32 NumSamples = Compute1DGaussianFilterKernel(FeatureLevel, EffectiveBlurRadius, OffsetAndWeight, MaxNumSamples, FilterShape, CrossCenterWeight);
FIntRect DestRect = FIntRect::DivideAndRoundUp(View.ViewRect, DstScaleFactor);
SCOPED_DRAW_EVENTF(Context.RHICmdList, PostProcessWeightedSampleSum, TEXT("PostProcessWeightedSampleSum#%d %dx%d in %dx%d"),
NumSamples, DestRect.Width(), DestRect.Height(), DestSize.X, DestSize.Y);
// compute weights as weighted contributions of the TintValue
for(uint32 i = 0; i < NumSamples; ++i)
{
BlurWeights[i] = TintValue * OffsetAndWeight[i].Y;
}
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef(), ESimpleRenderTargetMode::EExistingColorAndDepth);
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f);
bool bRequiresClear = true;
// check if we have to clear the whole surface.
// Otherwise perform the clear when the dest rectangle has been computed.
if (FeatureLevel == ERHIFeatureLevel::ES2 || FeatureLevel == ERHIFeatureLevel::ES3_1)
{
Context.RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, FIntRect());
bRequiresClear = false;
}
FIntRect SrcRect = FIntRect::DivideAndRoundUp(View.ViewRect, SrcScaleFactor);
if (bRequiresClear)
{
DrawClear(Context.RHICmdList, FeatureLevel, bDoFastBlur, SrcRect, DestRect, DestSize);
}
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
const FTextureRHIRef& FilterTexture = InputPooledElement->GetRenderTargetItem().ShaderResourceTexture;
FRenderingCompositeOutputRef* NodeInput1 = GetInput(ePId_Input1);
FRenderingCompositeOutput *Input1 = NodeInput1 ? NodeInput1->GetOutput() : 0;
uint32 CombineMethodInt = 0;
if(CombineMethod == EFCM_MaxMagnitude)
{
//.........这里部分代码省略.........
示例13: ComputeDiffuseIrradiance
void ComputeDiffuseIrradiance(FRHICommandListImmediate& RHICmdList, ERHIFeatureLevel::Type FeatureLevel, FTextureRHIRef LightingSource, int32 LightingSourceMipIndex, FSHVectorRGB3* OutIrradianceEnvironmentMap)
{
auto ShaderMap = GetGlobalShaderMap(FeatureLevel);
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
for (int32 CoefficientIndex = 0; CoefficientIndex < FSHVector3::MaxSHBasis; CoefficientIndex++)
{
// Copy the starting mip from the lighting texture, apply texel area weighting and appropriate SH coefficient
{
const int32 MipIndex = 0;
const int32 MipSize = GDiffuseIrradianceCubemapSize;
FSceneRenderTargetItem& EffectiveRT = GetEffectiveDiffuseIrradianceRenderTarget(SceneContext, MipIndex);
for (int32 CubeFace = 0; CubeFace < CubeFace_MAX; CubeFace++)
{
SetRenderTarget(RHICmdList, EffectiveRT.TargetableTexture, 0, CubeFace, NULL);
const FIntRect ViewRect(0, 0, MipSize, MipSize);
RHICmdList.SetViewport(0, 0, 0.0f, MipSize, MipSize, 1.0f);
RHICmdList.SetRasterizerState(TStaticRasterizerState<FM_Solid, CM_None>::GetRHI());
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
TShaderMapRef<FCopyDiffuseIrradiancePS> PixelShader(ShaderMap);
TShaderMapRef<FScreenVS> VertexShader(GetGlobalShaderMap(FeatureLevel));
SetGlobalBoundShaderState(RHICmdList, FeatureLevel, CopyDiffuseIrradianceShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, CubeFace, LightingSourceMipIndex, CoefficientIndex, MipSize, LightingSource);
DrawRectangle(
RHICmdList,
ViewRect.Min.X, ViewRect.Min.Y,
ViewRect.Width(), ViewRect.Height(),
ViewRect.Min.X, ViewRect.Min.Y,
ViewRect.Width(), ViewRect.Height(),
FIntPoint(ViewRect.Width(), ViewRect.Height()),
FIntPoint(MipSize, MipSize),
*VertexShader);
RHICmdList.CopyToResolveTarget(EffectiveRT.TargetableTexture, EffectiveRT.ShaderResourceTexture, true, FResolveParams(FResolveRect(), (ECubeFace)CubeFace, MipIndex));
}
}
const int32 NumMips = FMath::CeilLogTwo(GDiffuseIrradianceCubemapSize) + 1;
{
// Accumulate all the texel values through downsampling to 1x1 mip
for (int32 MipIndex = 1; MipIndex < NumMips; MipIndex++)
{
const int32 SourceMipIndex = FMath::Max(MipIndex - 1, 0);
const int32 MipSize = 1 << (NumMips - MipIndex - 1);
FSceneRenderTargetItem& EffectiveRT = GetEffectiveDiffuseIrradianceRenderTarget(SceneContext, MipIndex);
FSceneRenderTargetItem& EffectiveSource = GetEffectiveDiffuseIrradianceSourceTexture(SceneContext, MipIndex);
check(EffectiveRT.TargetableTexture != EffectiveSource.ShaderResourceTexture);
for (int32 CubeFace = 0; CubeFace < CubeFace_MAX; CubeFace++)
{
SetRenderTarget(RHICmdList, EffectiveRT.TargetableTexture, MipIndex, CubeFace, NULL);
const FIntRect ViewRect(0, 0, MipSize, MipSize);
RHICmdList.SetViewport(0, 0, 0.0f, MipSize, MipSize, 1.0f);
RHICmdList.SetRasterizerState(TStaticRasterizerState<FM_Solid, CM_None>::GetRHI());
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
TShaderMapRef<FAccumulateDiffuseIrradiancePS> PixelShader(ShaderMap);
TShaderMapRef<FScreenVS> VertexShader(GetGlobalShaderMap(FeatureLevel));
SetGlobalBoundShaderState(RHICmdList, FeatureLevel, DiffuseIrradianceAccumulateShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, CubeFace, NumMips, SourceMipIndex, CoefficientIndex, EffectiveSource.ShaderResourceTexture);
DrawRectangle(
RHICmdList,
ViewRect.Min.X, ViewRect.Min.Y,
ViewRect.Width(), ViewRect.Height(),
ViewRect.Min.X, ViewRect.Min.Y,
ViewRect.Width(), ViewRect.Height(),
FIntPoint(ViewRect.Width(), ViewRect.Height()),
FIntPoint(MipSize, MipSize),
*VertexShader);
RHICmdList.CopyToResolveTarget(EffectiveRT.TargetableTexture, EffectiveRT.ShaderResourceTexture, true, FResolveParams(FResolveRect(), (ECubeFace)CubeFace, MipIndex));
}
}
}
{
// Gather the cubemap face results and normalize, copy this coefficient to FSceneRenderTargets::Get(RHICmdList).SkySHIrradianceMap
FSceneRenderTargetItem& EffectiveRT = FSceneRenderTargets::Get(RHICmdList).SkySHIrradianceMap->GetRenderTargetItem();
//load/store actions so we don't lose results as we render one pixel at a time on tile renderers.
FRHIRenderTargetView RTV(EffectiveRT.TargetableTexture, 0, -1, ERenderTargetLoadAction::ELoad, ERenderTargetStoreAction::EStore);
RHICmdList.SetRenderTargets(1, &RTV, nullptr, 0, nullptr);
const FIntRect ViewRect(CoefficientIndex, 0, CoefficientIndex + 1, 1);
RHICmdList.SetViewport(0, 0, 0.0f, FSHVector3::MaxSHBasis, 1, 1.0f);
RHICmdList.SetRasterizerState(TStaticRasterizerState<FM_Solid, CM_None>::GetRHI());
//.........这里部分代码省略.........
示例14: StartBroadcastingEditor
void FEditorLiveStreaming::StartBroadcastingEditor()
{
if( !IsBroadcastingEditor() && IsLiveStreamingAvailable() )
{
// Select a live streaming service
{
static const FName LiveStreamingFeatureName( "LiveStreaming" );
LiveStreamer = &IModularFeatures::Get().GetModularFeature<ILiveStreamingService>( LiveStreamingFeatureName );
}
// Register to find out about status changes
LiveStreamer->OnStatusChanged().AddRaw( this, &FEditorLiveStreaming::BroadcastStatusCallback );
// @todo livestream: Allow connection to chat independently from broadcasting? (see removing delegate too)
LiveStreamer->OnChatMessage().AddRaw( this, &FEditorLiveStreaming::OnChatMessage );
// Tell our live streaming plugin to start broadcasting
{
const auto& Settings = *GetDefault< UEditorLiveStreamingSettings >();
FSlateRenderer* SlateRenderer = FSlateApplication::Get().GetRenderer().Get();
const FIntRect VirtualScreen = SlateRenderer->SetupVirtualScreenBuffer( Settings.bPrimaryMonitorOnly, Settings.ScreenScaling, LiveStreamer );
bIsBroadcasting = true;
SubmittedVideoFrameCount = 0;
// @todo livestream: What about if virtual screen size changes while we are still broadcasting? For example, if the user changes their
// desktop resolution while the editor is running. We'd need to stop and restart the broadcast.
FBroadcastConfig BroadcastConfig;
BroadcastConfig.VideoBufferWidth = VirtualScreen.Width();
BroadcastConfig.VideoBufferHeight = VirtualScreen.Height();
BroadcastConfig.FramesPerSecond = Settings.FrameRate;
BroadcastConfig.PixelFormat = FBroadcastConfig::EBroadcastPixelFormat::R8G8B8A8;
BroadcastConfig.bCaptureAudioFromComputer = Settings.bCaptureAudioFromComputer;
BroadcastConfig.bCaptureAudioFromMicrophone = Settings.bCaptureAudioFromMicrophone;
LiveStreamer->StartBroadcasting( BroadcastConfig );
if( Settings.bEnableWebCam )
{
FWebCamConfig WebCamConfig;
switch( Settings.WebCamResolution )
{
case EEditorLiveStreamingWebCamResolution::Normal_320x240:
WebCamConfig.DesiredWebCamWidth = 320;
WebCamConfig.DesiredWebCamHeight = 240;
break;
case EEditorLiveStreamingWebCamResolution::Wide_320x180:
WebCamConfig.DesiredWebCamWidth = 320;
WebCamConfig.DesiredWebCamHeight = 180;
break;
case EEditorLiveStreamingWebCamResolution::Normal_640x480:
WebCamConfig.DesiredWebCamWidth = 640;
WebCamConfig.DesiredWebCamHeight = 480;
break;
case EEditorLiveStreamingWebCamResolution::Wide_640x360:
WebCamConfig.DesiredWebCamWidth = 640;
WebCamConfig.DesiredWebCamHeight = 360;
break;
case EEditorLiveStreamingWebCamResolution::Normal_800x600:
WebCamConfig.DesiredWebCamWidth = 800;
WebCamConfig.DesiredWebCamHeight = 600;
break;
case EEditorLiveStreamingWebCamResolution::Wide_800x450:
WebCamConfig.DesiredWebCamWidth = 800;
WebCamConfig.DesiredWebCamHeight = 450;
break;
case EEditorLiveStreamingWebCamResolution::Normal_1024x768:
WebCamConfig.DesiredWebCamWidth = 1024;
WebCamConfig.DesiredWebCamHeight = 768;
break;
case EEditorLiveStreamingWebCamResolution::Wide_1024x576:
WebCamConfig.DesiredWebCamWidth = 1024;
WebCamConfig.DesiredWebCamHeight = 576;
break;
case EEditorLiveStreamingWebCamResolution::Normal_1080x810:
WebCamConfig.DesiredWebCamWidth = 1080;
WebCamConfig.DesiredWebCamHeight = 810;
break;
case EEditorLiveStreamingWebCamResolution::Wide_1080x720:
WebCamConfig.DesiredWebCamWidth = 1080;
WebCamConfig.DesiredWebCamHeight = 720;
break;
case EEditorLiveStreamingWebCamResolution::Normal_1280x960:
WebCamConfig.DesiredWebCamWidth = 1280;
WebCamConfig.DesiredWebCamHeight = 960;
break;
case EEditorLiveStreamingWebCamResolution::Wide_1280x720:
WebCamConfig.DesiredWebCamWidth = 1280;
WebCamConfig.DesiredWebCamHeight = 720;
break;
case EEditorLiveStreamingWebCamResolution::Normal_1920x1440:
WebCamConfig.DesiredWebCamWidth = 1920;
WebCamConfig.DesiredWebCamHeight = 1440;
break;
case EEditorLiveStreamingWebCamResolution::Wide_1920x1080:
WebCamConfig.DesiredWebCamWidth = 1920;
WebCamConfig.DesiredWebCamHeight = 1080;
break;
default:
//.........这里部分代码省略.........
示例15: Process
void FRCPassPostProcessUpscale::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessUpscale);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.UnscaledViewRect;
FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
bool bTessellatedQuad = PaniniConfig.D >= 0.01f;
// with distortion (bTessellatedQuad) we need to clear the background
FIntRect ExcludeRect = bTessellatedQuad ? FIntRect() : DestRect;
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, ExcludeRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
FShader* VertexShader = 0;
if(bTessellatedQuad)
{
switch (UpscaleQuality)
{
case 0:
VertexShader = SetShader<0, 1>(Context, PaniniConfig);
break;
case 1:
VertexShader = SetShader<1, 1>(Context, PaniniConfig);
break;
case 2:
VertexShader = SetShader<2, 1>(Context, PaniniConfig);
break;
case 3:
VertexShader = SetShader<3, 1>(Context, PaniniConfig);
break;
default:
checkNoEntry();
break;
}
}
else
{
switch (UpscaleQuality)
{
case 0:
VertexShader = SetShader<0, 0>(Context, PaniniParams::Default);
break;
case 1:
VertexShader = SetShader<1, 0>(Context, PaniniParams::Default);
break;
case 2:
VertexShader = SetShader<2, 0>(Context, PaniniParams::Default);
break;
case 3:
VertexShader = SetShader<3, 0>(Context, PaniniParams::Default);
break;
default:
checkNoEntry();
break;
}
}
// Draw a quad, a triangle or a tessellated quad
DrawRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
VertexShader,
bTessellatedQuad ? EDRF_UseTesselatedIndexBuffer: EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}