本文整理汇总了C++中FSceneView::GetFeatureLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ FSceneView::GetFeatureLevel方法的具体用法?C++ FSceneView::GetFeatureLevel怎么用?C++ FSceneView::GetFeatureLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSceneView
的用法示例。
在下文中一共展示了FSceneView::GetFeatureLevel方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMesh
virtual void SetMesh(FRHICommandList& RHICmdList, FShader* Shader,const FVertexFactory* VertexFactory,const FSceneView& View,const FMeshBatchElement& BatchElement,uint32 DataFlags) const override
{
const bool bInstanced = View.GetFeatureLevel() >= ERHIFeatureLevel::SM4;
FMeshParticleVertexFactory* MeshParticleVF = (FMeshParticleVertexFactory*)VertexFactory;
FVertexShaderRHIParamRef VertexShaderRHI = Shader->GetVertexShader();
SetUniformBufferParameter(RHICmdList, VertexShaderRHI, Shader->GetUniformBufferParameter<FMeshParticleUniformParameters>(), MeshParticleVF->GetUniformBuffer() );
if (!bInstanced)
{
const FMeshParticleVertexFactory::FBatchParametersCPU* BatchParameters = (const FMeshParticleVertexFactory::FBatchParametersCPU*)BatchElement.UserData;
const FMeshParticleInstanceVertex* Vertex = BatchParameters->InstanceBuffer + BatchElement.UserIndex;
const FMeshParticleInstanceVertexDynamicParameter* DynamicVertex = BatchParameters->DynamicParameterBuffer + BatchElement.UserIndex;
SetShaderValue(RHICmdList, VertexShaderRHI, Transform1, Vertex->Transform[0]);
SetShaderValue(RHICmdList, VertexShaderRHI, Transform2, Vertex->Transform[1]);
SetShaderValue(RHICmdList, VertexShaderRHI, Transform3, Vertex->Transform[2]);
SetShaderValue(RHICmdList, VertexShaderRHI, SubUVParams, FVector4((float)Vertex->SubUVParams[0], (float)Vertex->SubUVParams[1], (float)Vertex->SubUVParams[2], (float)Vertex->SubUVParams[3]));
SetShaderValue(RHICmdList, VertexShaderRHI, SubUVLerp, Vertex->SubUVLerp);
SetShaderValue(RHICmdList, VertexShaderRHI, ParticleDirection, Vertex->Velocity);
SetShaderValue(RHICmdList, VertexShaderRHI, RelativeTime, Vertex->RelativeTime);
if (BatchParameters->DynamicParameterBuffer)
{
SetShaderValue(RHICmdList, VertexShaderRHI, DynamicParameter, FVector4(DynamicVertex->DynamicValue[0], DynamicVertex->DynamicValue[1], DynamicVertex->DynamicValue[2], DynamicVertex->DynamicValue[3]));
}
SetShaderValue(RHICmdList, VertexShaderRHI, ParticleColor, FVector4(Vertex->Color.Component(0), Vertex->Color.Component(1), Vertex->Color.Component(2), Vertex->Color.Component(3)));
}
}
示例2: DrawingPolicy
bool TDistortionMeshDrawingPolicyFactory<DistortMeshPolicy>::DrawDynamicMesh(
FRHICommandList& RHICmdList,
const FSceneView& View,
ContextType bInitializeOffsets,
const FMeshBatch& Mesh,
bool bBackFace,
bool bPreFog,
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
FHitProxyId HitProxyId
)
{
const auto FeatureLevel = View.GetFeatureLevel();
bool bDistorted = Mesh.MaterialRenderProxy && Mesh.MaterialRenderProxy->GetMaterial(FeatureLevel)->IsDistorted();
if(bDistorted && !bBackFace)
{
// draw dynamic mesh element using distortion mesh policy
TDistortionMeshDrawingPolicy<DistortMeshPolicy> DrawingPolicy(
Mesh.VertexFactory,
Mesh.MaterialRenderProxy,
*Mesh.MaterialRenderProxy->GetMaterial(FeatureLevel),
bInitializeOffsets,
View.Family->EngineShowFlags.ShaderComplexity,
FeatureLevel
);
RHICmdList.BuildAndSetLocalBoundShaderState(DrawingPolicy.GetBoundShaderStateInput(View.GetFeatureLevel()));
DrawingPolicy.SetSharedState(RHICmdList, &View, typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ContextDataType());
for (int32 BatchElementIndex = 0; BatchElementIndex < Mesh.Elements.Num(); BatchElementIndex++)
{
DrawingPolicy.SetMeshRenderState(RHICmdList, View,PrimitiveSceneProxy,Mesh,BatchElementIndex,bBackFace,typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ElementDataType(), typename TDistortionMeshDrawingPolicy<DistortMeshPolicy>::ContextDataType());
DrawingPolicy.DrawMesh(RHICmdList, Mesh,BatchElementIndex);
}
return true;
}
else
{
return false;
}
}
示例3: RunBenchmarkShader
void RunBenchmarkShader(FRHICommandList& RHICmdList, const FSceneView& View, TRefCountPtr<IPooledRenderTarget>& Src, float WorkScale)
{
auto ShaderMap = GetGlobalShaderMap(View.GetFeatureLevel());
TShaderMapRef<FPostProcessBenchmarkVS> VertexShader(ShaderMap);
TShaderMapRef<FPostProcessBenchmarkPS<Method> > PixelShader(ShaderMap);
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(RHICmdList, View.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, View, Src);
VertexShader->SetParameters(RHICmdList, View);
// single pass was not fine grained enough so we reduce the pass size based on the fractional part of WorkScale
float TotalHeight = GBenchmarkResolution * WorkScale;
// rounds up
uint32 PassCount = (uint32)FMath::CeilToFloat(TotalHeight / GBenchmarkResolution);
for(uint32 i = 0; i < PassCount; ++i)
{
float Top = i * GBenchmarkResolution;
float Bottom = FMath::Min(Top + GBenchmarkResolution, TotalHeight);
float LocalHeight = Bottom - Top;
DrawRectangle(
RHICmdList,
0, 0,
GBenchmarkResolution, LocalHeight,
0, 0,
GBenchmarkResolution, LocalHeight,
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
*VertexShader,
EDRF_Default);
}
}
示例4: DrawBatchedElements
void FSimpleElementCollector::DrawBatchedElements(FRHICommandList& RHICmdList, const FSceneView& View, FTexture2DRHIRef DepthTexture, EBlendModeFilter::Type Filter) const
{
// Mobile HDR does not execute post process, so does not need to render flipped
const bool bNeedToSwitchVerticalAxis = RHINeedsToSwitchVerticalAxis(View.GetShaderPlatform()) && !bIsMobileHDR;
// Draw the batched elements.
BatchedElements.Draw(
RHICmdList,
View.GetFeatureLevel(),
bNeedToSwitchVerticalAxis,
View.ViewProjectionMatrix,
View.ViewRect.Width(),
View.ViewRect.Height(),
View.Family->EngineShowFlags.HitProxies,
1.0f,
&View,
DepthTexture,
Filter
);
}
示例5: AddMesh
void FMeshElementCollector::AddMesh(int32 ViewIndex, FMeshBatch& MeshBatch)
{
checkSlow(MeshBatch.GetNumPrimitives() > 0);
checkSlow(MeshBatch.VertexFactory && MeshBatch.MaterialRenderProxy);
checkSlow(PrimitiveSceneProxy);
if (MeshBatch.bCanApplyViewModeOverrides)
{
FSceneView* View = Views[ViewIndex];
ApplyViewModeOverrides(
ViewIndex,
View->Family->EngineShowFlags,
View->GetFeatureLevel(),
PrimitiveSceneProxy,
MeshBatch.bUseWireframeSelectionColoring,
MeshBatch,
*this);
}
TArray<FMeshBatchAndRelevance,SceneRenderingAllocator>& ViewMeshBatches = *MeshBatches[ViewIndex];
new (ViewMeshBatches) FMeshBatchAndRelevance(MeshBatch, PrimitiveSceneProxy, FeatureLevel);
}
示例6: SetParameters
void SetParameters(
FRHICommandList& RHICmdList,
const FMaterialRenderProxy* MaterialRenderProxy,
const FSceneView& View
)
{
FMeshMaterialShader::SetParameters(RHICmdList, GetPixelShader(), MaterialRenderProxy, *MaterialRenderProxy->GetMaterial(View.GetFeatureLevel()), View, ESceneRenderTargetsMode::SetTextures);
float Ratio = View.UnscaledViewRect.Width() / (float)View.UnscaledViewRect.Height();
float Params[4];
Params[0] = View.ViewMatrices.ProjMatrix.M[0][0];
Params[1] = Ratio;
Params[2] = (float)View.UnscaledViewRect.Width();
Params[3] = (float)View.UnscaledViewRect.Height();
SetShaderValue(RHICmdList, GetPixelShader(), DistortionParams, Params);
}
示例7: SetParameters
void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const FMaterialRenderProxy* MaterialProxy, const FDeferredDecalProxy& DecalProxy, const float FadeAlphaValue=1.0f)
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
FMaterialShader::SetParameters(RHICmdList, ShaderRHI, MaterialProxy, *MaterialProxy->GetMaterial(View.GetFeatureLevel()), View, View.ViewUniformBuffer, true, ESceneRenderTargetsMode::SetTextures);
FTransform ComponentTrans = DecalProxy.ComponentTrans;
FMatrix WorldToComponent = ComponentTrans.ToInverseMatrixWithScale();
// Set the transform from screen space to light space.
if(SvPositionToDecal.IsBound())
{
FVector2D InvViewSize = FVector2D(1.0f / View.ViewRect.Width(), 1.0f / View.ViewRect.Height());
// setup a matrix to transform float4(SvPosition.xyz,1) directly to Decal (quality, performance as we don't need to convert or use interpolator)
// new_xy = (xy - ViewRectMin.xy) * ViewSizeAndInvSize.zw * float2(2,-2) + float2(-1, 1);
// transformed into one MAD: new_xy = xy * ViewSizeAndInvSize.zw * float2(2,-2) + (-ViewRectMin.xy) * ViewSizeAndInvSize.zw * float2(2,-2) + float2(-1, 1);
float Mx = 2.0f * InvViewSize.X;
float My = -2.0f * InvViewSize.Y;
float Ax = -1.0f - 2.0f * View.ViewRect.Min.X * InvViewSize.X;
float Ay = 1.0f + 2.0f * View.ViewRect.Min.Y * InvViewSize.Y;
// todo: we could use InvTranslatedViewProjectionMatrix and TranslatedWorldToComponent for better quality
const FMatrix SvPositionToDecalValue =
FMatrix(
FPlane(Mx, 0, 0, 0),
FPlane( 0, My, 0, 0),
FPlane( 0, 0, 1, 0),
FPlane(Ax, Ay, 0, 1)
) * View.InvViewProjectionMatrix * WorldToComponent;
SetShaderValue(RHICmdList, ShaderRHI, SvPositionToDecal, SvPositionToDecalValue);
}
// Set the transform from light space to world space
if(DecalToWorld.IsBound())
{
const FMatrix DecalToWorldValue = ComponentTrans.ToMatrixWithScale();
SetShaderValue(RHICmdList, ShaderRHI, DecalToWorld, DecalToWorldValue);
}
SetShaderValue(RHICmdList, ShaderRHI, WorldToDecal, WorldToComponent);
float LifetimeAlpha = FMath::Clamp(View.Family->CurrentWorldTime * -DecalProxy.InvFadeDuration + DecalProxy.FadeStartDelayNormalized, 0.0f, 1.0f);
SetShaderValue(RHICmdList, ShaderRHI, DecalParams, FVector2D(FadeAlphaValue, LifetimeAlpha));
}
示例8: SetParameters
void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const FMaterialRenderProxy* MaterialProxy, const FDeferredDecalProxy& DecalProxy, const float FadeAlphaValue=1.0f)
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
FMaterialShader::SetParameters(RHICmdList, ShaderRHI, MaterialProxy, *MaterialProxy->GetMaterial(View.GetFeatureLevel()), View, true, ESceneRenderTargetsMode::SetTextures);
FTransform ComponentTrans = DecalProxy.ComponentTrans;
FMatrix WorldToComponent = ComponentTrans.ToInverseMatrixWithScale();
// Set the transform from screen space to light space.
if(ScreenToDecal.IsBound())
{
const FMatrix ScreenToDecalValue =
FMatrix(
FPlane(1,0,0,0),
FPlane(0,1,0,0),
FPlane(0,0,View.ViewMatrices.ProjMatrix.M[2][2],1),
FPlane(0,0,View.ViewMatrices.ProjMatrix.M[3][2],0)
) * View.InvViewProjectionMatrix * WorldToComponent;
SetShaderValue(RHICmdList, ShaderRHI, ScreenToDecal, ScreenToDecalValue);
}
// Set the transform from light space to world space
if(DecalToWorld.IsBound())
{
const FMatrix DecalToWorldValue = ComponentTrans.ToMatrixWithScale();
SetShaderValue(RHICmdList, ShaderRHI, DecalToWorld, DecalToWorldValue);
}
SetShaderValue(RHICmdList, ShaderRHI, FadeAlpha, FadeAlphaValue);
SetShaderValue(RHICmdList, ShaderRHI, WorldToDecal, WorldToComponent);
}
示例9: RunBenchmarkShader
void RunBenchmarkShader(FRHICommandList& RHICmdList, FVertexBufferRHIParamRef VertexThroughputBuffer, const FSceneView& View, TRefCountPtr<IPooledRenderTarget>& Src, float WorkScale)
{
auto ShaderMap = GetGlobalShaderMap(View.GetFeatureLevel());
TShaderMapRef<FPostProcessBenchmarkVS<VsMethod>> VertexShader(ShaderMap);
TShaderMapRef<FPostProcessBenchmarkPS<PsMethod>> PixelShader(ShaderMap);
bool bVertexTest = VsMethod == 1;
FVertexDeclarationRHIParamRef VertexDeclaration = bVertexTest
? GVertexThroughputDeclaration.DeclRHI
: GFilterVertexDeclaration.VertexDeclarationRHI;
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(RHICmdList, View.GetFeatureLevel(), BoundShaderState, VertexDeclaration, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, View, Src);
VertexShader->SetParameters(RHICmdList, View);
if (bVertexTest)
{
// Vertex Tests
uint32 TotalNumPrimitives = FMath::CeilToInt(GBenchmarkPrimitives * WorkScale);
uint32 TotalNumVertices = TotalNumPrimitives * 3;
while (TotalNumVertices != 0)
{
uint32 VerticesThisPass = FMath::Min(TotalNumVertices, GBenchmarkVertices);
uint32 PrimitivesThisPass = VerticesThisPass / 3;
RHICmdList.SetStreamSource(0, VertexThroughputBuffer, sizeof(FBenchmarkVertex), 0);
RHICmdList.DrawPrimitive(PT_TriangleList, 0, PrimitivesThisPass, 1);
TotalNumVertices -= VerticesThisPass;
}
}
else
{
// Pixel Tests
// single pass was not fine grained enough so we reduce the pass size based on the fractional part of WorkScale
float TotalHeight = GBenchmarkResolution * WorkScale;
// rounds up
uint32 PassCount = (uint32)FMath::CeilToFloat(TotalHeight / GBenchmarkResolution);
for (uint32 i = 0; i < PassCount; ++i)
{
float Top = i * GBenchmarkResolution;
float Bottom = FMath::Min(Top + GBenchmarkResolution, TotalHeight);
float LocalHeight = Bottom - Top;
DrawRectangle(
RHICmdList,
0, 0,
GBenchmarkResolution, LocalHeight,
0, 0,
GBenchmarkResolution, LocalHeight,
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
FIntPoint(GBenchmarkResolution, GBenchmarkResolution),
*VertexShader,
EDRF_Default);
}
}
}
示例10: DrawElements
//.........这里部分代码省略.........
SamplerState = TStaticSamplerState<SF_Bilinear, AM_Wrap, AM_Clamp, AM_Wrap>::GetRHI();
}
else if (DrawFlags & ESlateBatchDrawFlag::TileV)
{
SamplerState = TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Wrap, AM_Wrap>::GetRHI();
}
else
{
SamplerState = BilinearClamp;
}
PixelShader->SetTexture(RHICmdList, TextureRHI, SamplerState);
}
else
{
PixelShader->SetTexture(RHICmdList, GWhiteTexture->TextureRHI, BilinearClamp);
}
PixelShader->SetShaderParams(RHICmdList, ShaderParams.PixelParams);
PixelShader->SetDisplayGamma(RHICmdList, (DrawFlags & ESlateBatchDrawFlag::NoGamma) ? 1.0f : 1.0f/DisplayGamma);
check(RenderBatch.NumIndices > 0);
uint32 PrimitiveCount = RenderBatch.DrawPrimitiveType == ESlateDrawPrimitive::LineList ? RenderBatch.NumIndices / 2 : RenderBatch.NumIndices / 3;
// for RHIs that can't handle VertexOffset, we need to offset the stream source each time
if (!GRHISupportsBaseVertexIndex)
{
RHICmdList.SetStreamSource(0, VertexBuffer.VertexBufferRHI, sizeof(FSlateVertex), RenderBatch.VertexOffset * sizeof(FSlateVertex));
RHICmdList.DrawIndexedPrimitive(IndexBuffer.IndexBufferRHI, GetRHIPrimitiveType(RenderBatch.DrawPrimitiveType), 0, 0, RenderBatch.NumVertices, RenderBatch.IndexOffset, PrimitiveCount, 1);
}
else
{
RHICmdList.DrawIndexedPrimitive(IndexBuffer.IndexBufferRHI, GetRHIPrimitiveType(RenderBatch.DrawPrimitiveType), RenderBatch.VertexOffset, 0, RenderBatch.NumVertices, RenderBatch.IndexOffset, PrimitiveCount, 1);
}
}
else if (ShaderResource && ShaderResource->GetType() == ESlateShaderResource::Material)
{
if (!SceneView)
{
SceneView = &CreateSceneView(SceneViewContext, BackBuffer, ViewProjectionMatrix);
}
FMaterialRenderProxy* MaterialRenderProxy = ((FSlateMaterialResource*)ShaderResource)->GetRenderProxy();
const FMaterial* Material = MaterialRenderProxy->GetMaterial(SceneView->GetFeatureLevel());
FSlateMaterialShaderPS* PixelShader = GetMaterialPixelShader( Material, ShaderType, DrawEffects );
if( PixelShader )
{
RHICmdList.SetLocalBoundShaderState(RHICmdList.BuildLocalBoundShaderState(
GSlateVertexDeclaration.VertexDeclarationRHI,
VertexShader->GetVertexShader(),
nullptr,
nullptr,
PixelShader->GetPixelShader(),
FGeometryShaderRHIRef()));
PixelShader->SetParameters(RHICmdList, *SceneView, MaterialRenderProxy, Material, 1.0f / DisplayGamma, ShaderParams.PixelParams);
VertexShader->SetViewProjection( RHICmdList, ViewProjectionMatrix );
check(RenderBatch.NumIndices > 0);
uint32 PrimitiveCount = RenderBatch.DrawPrimitiveType == ESlateDrawPrimitive::LineList ? RenderBatch.NumIndices / 2 : RenderBatch.NumIndices / 3;
// for RHIs that can't handle VertexOffset, we need to offset the stream source each time
if (!GRHISupportsBaseVertexIndex)
{
RHICmdList.SetStreamSource(0, VertexBuffer.VertexBufferRHI, sizeof(FSlateVertex), RenderBatch.VertexOffset * sizeof(FSlateVertex));
RHICmdList.DrawIndexedPrimitive(IndexBuffer.IndexBufferRHI, GetRHIPrimitiveType(RenderBatch.DrawPrimitiveType), 0, 0, RenderBatch.NumVertices, RenderBatch.IndexOffset, PrimitiveCount, 1);
}
else
{
RHICmdList.DrawIndexedPrimitive(IndexBuffer.IndexBufferRHI, GetRHIPrimitiveType(RenderBatch.DrawPrimitiveType), RenderBatch.VertexOffset, 0, RenderBatch.NumVertices, RenderBatch.IndexOffset, PrimitiveCount, 1);
}
}
}
}
else
{
TSharedPtr<ICustomSlateElement, ESPMode::ThreadSafe> CustomDrawer = RenderBatch.CustomDrawer.Pin();
if (CustomDrawer.IsValid())
{
// This element is custom and has no Slate geometry. Tell it to render itself now
CustomDrawer->DrawRenderThread(RHICmdList, &BackBuffer.GetRenderTargetTexture());
// Something may have messed with the viewport size so set it back to the full target.
RHICmdList.SetViewport( 0,0,0,BackBuffer.GetSizeXY().X, BackBuffer.GetSizeXY().Y, 0.0f );
RHICmdList.SetStreamSource(0, VertexBuffer.VertexBufferRHI, sizeof(FSlateVertex), 0);
}
}
}
CurrentBufferIndex = (CurrentBufferIndex + 1) % 2;
}
示例11: SetParameters
void FMaterialShader::SetParameters(
FRHICommandList& RHICmdList,
const ShaderRHIParamRef ShaderRHI,
const FMaterialRenderProxy* MaterialRenderProxy,
const FMaterial& Material,
const FSceneView& View,
bool bDeferredPass,
ESceneRenderTargetsMode::Type TextureMode)
{
ERHIFeatureLevel::Type FeatureLevel = View.GetFeatureLevel();
FUniformExpressionCache TempUniformExpressionCache;
const FUniformExpressionCache* UniformExpressionCache = &MaterialRenderProxy->UniformExpressionCache[FeatureLevel];
SetParameters(RHICmdList, ShaderRHI, View);
// If the material has cached uniform expressions for selection or hover
// and that is being overridden by show flags in the editor, recache
// expressions for this draw call.
const bool bOverrideSelection =
GIsEditor &&
!View.Family->EngineShowFlags.Selection &&
(MaterialRenderProxy->IsSelected() || MaterialRenderProxy->IsHovered());
if (!bAllowCachedUniformExpressions || !UniformExpressionCache->bUpToDate || bOverrideSelection)
{
FMaterialRenderContext MaterialRenderContext(MaterialRenderProxy, Material, &View);
MaterialRenderProxy->EvaluateUniformExpressions(TempUniformExpressionCache, MaterialRenderContext, &RHICmdList);
UniformExpressionCache = &TempUniformExpressionCache;
}
check(Material.GetRenderingThreadShaderMap());
check(Material.GetRenderingThreadShaderMap()->IsValidForRendering());
check(Material.GetFeatureLevel() == FeatureLevel);
// Validate that the shader is being used for a material that matches the uniform expression set the shader was compiled for.
const FUniformExpressionSet& MaterialUniformExpressionSet = Material.GetRenderingThreadShaderMap()->GetUniformExpressionSet();
#if NO_LOGGING == 0
const bool bUniformExpressionSetMismatch = !DebugUniformExpressionSet.Matches(MaterialUniformExpressionSet)
|| UniformExpressionCache->CachedUniformExpressionShaderMap != Material.GetRenderingThreadShaderMap();
if (bUniformExpressionSetMismatch)
{
UE_LOG(
LogShaders,
Fatal,
TEXT("%s shader uniform expression set mismatch for material %s/%s.\n")
TEXT("Shader compilation info: %s\n")
TEXT("Material render proxy compilation info: %s\n")
TEXT("Shader uniform expression set: %u vectors, %u scalars, %u 2D textures, %u cube textures, %u scalars/frame, %u vectors/frame, shader map %p\n")
TEXT("Material uniform expression set: %u vectors, %u scalars, %u 2D textures, %u cube textures, %u scalars/frame, %u vectors/frame, shader map %p\n"),
GetType()->GetName(),
*MaterialRenderProxy->GetFriendlyName(),
*Material.GetFriendlyName(),
*DebugDescription,
*Material.GetRenderingThreadShaderMap()->GetDebugDescription(),
DebugUniformExpressionSet.NumVectorExpressions,
DebugUniformExpressionSet.NumScalarExpressions,
DebugUniformExpressionSet.Num2DTextureExpressions,
DebugUniformExpressionSet.NumCubeTextureExpressions,
DebugUniformExpressionSet.NumPerFrameScalarExpressions,
DebugUniformExpressionSet.NumPerFrameVectorExpressions,
UniformExpressionCache->CachedUniformExpressionShaderMap,
MaterialUniformExpressionSet.UniformVectorExpressions.Num(),
MaterialUniformExpressionSet.UniformScalarExpressions.Num(),
MaterialUniformExpressionSet.Uniform2DTextureExpressions.Num(),
MaterialUniformExpressionSet.UniformCubeTextureExpressions.Num(),
MaterialUniformExpressionSet.PerFrameUniformScalarExpressions.Num(),
MaterialUniformExpressionSet.PerFrameUniformVectorExpressions.Num(),
Material.GetRenderingThreadShaderMap()
);
}
#endif
if (UniformExpressionCache->LocalUniformBuffer.IsValid())
{
// Set the material uniform buffer.
SetLocalUniformBufferParameter(RHICmdList, ShaderRHI, MaterialUniformBuffer, UniformExpressionCache->LocalUniformBuffer);
}
else
{
// Set the material uniform buffer.
SetUniformBufferParameter(RHICmdList, ShaderRHI, MaterialUniformBuffer, UniformExpressionCache->UniformBuffer);
}
{
const TArray<FGuid>& ParameterCollections = UniformExpressionCache->ParameterCollections;
const int32 ParameterCollectionsNum = ParameterCollections.Num();
check(ParameterCollectionUniformBuffers.Num() >= ParameterCollectionsNum);
// Find each referenced parameter collection's uniform buffer in the scene and set the parameter
for (int32 CollectionIndex = 0; CollectionIndex < ParameterCollectionsNum; CollectionIndex++)
{
FUniformBufferRHIParamRef UniformBuffer = GetParameterCollectionBuffer(ParameterCollections[CollectionIndex], View.Family->Scene);
SetUniformBufferParameter(RHICmdList, ShaderRHI,ParameterCollectionUniformBuffers[CollectionIndex],UniformBuffer);
}
}
//.........这里部分代码省略.........
示例12: SetMesh
/**
* Set any shader data specific to this vertex factory
*/
virtual void SetMesh(FRHICommandList& RHICmdList, FShader* Shader, const FVertexFactory* VertexFactory, const FSceneView& View, const FMeshBatchElement& BatchElement, uint32 DataFlags) const override
{
if(Shader->GetVertexShader())
{
const auto FeatureLevel = View.GetFeatureLevel();
const FGPUBaseSkinVertexFactory::ShaderDataType& ShaderData = ((const FGPUBaseSkinVertexFactory*)VertexFactory)->GetShaderData();
SetShaderValue(
RHICmdList,
Shader->GetVertexShader(),
MeshOriginParameter,
ShaderData.MeshOrigin
);
SetShaderValue(
RHICmdList,
Shader->GetVertexShader(),
MeshExtensionParameter,
ShaderData.MeshExtension
);
if (FeatureLevel >= ERHIFeatureLevel::SM4)
{
if(BoneMatrices.IsBound())
{
RHICmdList.SetShaderResourceViewParameter(Shader->GetVertexShader(), BoneMatrices.GetBaseIndex(), ShaderData.GetBoneBuffer().VertexBufferSRV);
}
}
else
{
SetUniformBufferParameter(RHICmdList, Shader->GetVertexShader(), Shader->GetUniformBufferParameter<FBoneMatricesUniformShaderParameters>(), ShaderData.GetUniformBuffer());
}
bool bLocalPerBoneMotionBlur = false;
if (FeatureLevel >= ERHIFeatureLevel::SM4 && GPrevPerBoneMotionBlur.IsLocked())
{
// we are in the velocity rendering pass
// 0xffffffff or valid index
uint32 OldBoneDataIndex = ShaderData.GetOldBoneData(View.FrameNumber);
// Read old data if it was written last frame (normal data) or this frame (e.g. split screen)
bLocalPerBoneMotionBlur = (OldBoneDataIndex != 0xffffffff);
// we tell the shader where to pickup the data (always, even if we don't have bone data, to avoid false binding)
if(PreviousBoneMatrices.IsBound())
{
RHICmdList.SetShaderResourceViewParameter(Shader->GetVertexShader(), PreviousBoneMatrices.GetBaseIndex(), GPrevPerBoneMotionBlur.GetReadData()->BoneBuffer.VertexBufferSRV);
}
if(bLocalPerBoneMotionBlur)
{
uint32 BoneIndexOffsetValue[4];
BoneIndexOffsetValue[0] = OldBoneDataIndex;
BoneIndexOffsetValue[1] = OldBoneDataIndex + 1;
BoneIndexOffsetValue[2] = OldBoneDataIndex + 2;
BoneIndexOffsetValue[3] = 0;
SetShaderValue(
RHICmdList,
Shader->GetVertexShader(),
BoneIndexOffset,
BoneIndexOffsetValue
);
}
FScopeLock Lock(&ShaderData.OldBoneDataLock);
// if we haven't copied the data yet we skip the update (e.g. split screen)
if(ShaderData.IsOldBoneDataUpdateNeeded(View.FrameNumber))
{
const FGPUBaseSkinVertexFactory* GPUVertexFactory = (const FGPUBaseSkinVertexFactory*)VertexFactory;
// copy the bone data and tell the instance where it can pick it up next frame
// append data to a buffer we bind next frame to read old matrix data for motion blur
uint32 OldBoneDataStartIndex = GPrevPerBoneMotionBlur.AppendData(ShaderData.BoneMatrices.GetData(), ShaderData.BoneMatrices.Num());
GPUVertexFactory->SetOldBoneDataStartIndex(View.FrameNumber, OldBoneDataStartIndex);
}
}
SetShaderValue(RHICmdList, Shader->GetVertexShader(), PerBoneMotionBlur, bLocalPerBoneMotionBlur);
}
}
示例13: SetParameters
void SetParameters(
FRHICommandList& RHICmdList,
const FSceneView& View,
int32 SurfelStartIndexValue,
int32 NumSurfelsToGenerateValue,
const FMaterialRenderProxy* MaterialProxy,
FUniformBufferRHIParamRef PrimitiveUniformBuffer,
const FMatrix& Instance0Transform
)
{
FComputeShaderRHIParamRef ShaderRHI = GetComputeShader();
FMaterialShader::SetParameters(RHICmdList, ShaderRHI, MaterialProxy, *MaterialProxy->GetMaterial(View.GetFeatureLevel()), View, View.ViewUniformBuffer, true, ESceneRenderTargetsMode::SetTextures);
SetUniformBufferParameter(RHICmdList, ShaderRHI,GetUniformBufferParameter<FPrimitiveUniformShaderParameters>(),PrimitiveUniformBuffer);
const FScene* Scene = (const FScene*)View.Family->Scene;
FUnorderedAccessViewRHIParamRef UniformMeshUAVs[1];
UniformMeshUAVs[0] = Scene->DistanceFieldSceneData.SurfelBuffers->Surfels.UAV;
RHICmdList.TransitionResources(EResourceTransitionAccess::ERWBarrier, EResourceTransitionPipeline::EComputeToCompute, UniformMeshUAVs, ARRAY_COUNT(UniformMeshUAVs));
SurfelBufferParameters.Set(RHICmdList, ShaderRHI, *Scene->DistanceFieldSceneData.SurfelBuffers, *Scene->DistanceFieldSceneData.InstancedSurfelBuffers);
SetShaderValue(RHICmdList, ShaderRHI, SurfelStartIndex, SurfelStartIndexValue);
SetShaderValue(RHICmdList, ShaderRHI, NumSurfelsToGenerate, NumSurfelsToGenerateValue);
SetShaderValue(RHICmdList, ShaderRHI, Instance0InverseTransform, Instance0Transform.Inverse());
}
示例14: SetParameters
void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const FMaterialRenderProxy* MaterialProxy, const FDeferredDecalProxy& DecalProxy)
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
FMaterialShader::SetParameters(RHICmdList, ShaderRHI, MaterialProxy, *MaterialProxy->GetMaterial(View.GetFeatureLevel()), View, true, ESceneRenderTargetsMode::SetTextures);
FTransform ComponentTrans = DecalProxy.ComponentTrans;
// 1,1,1 requires no scale
// ComponentTrans = ComponentTrans.GetScaled(GDefaultDecalSize);
FMatrix WorldToComponent = ComponentTrans.ToMatrixWithScale().InverseFast();
// Set the transform from screen space to light space.
if(ScreenToDecal.IsBound())
{
const FMatrix ScreenToDecalValue =
FMatrix(
FPlane(1,0,0,0),
FPlane(0,1,0,0),
FPlane(0,0,View.ViewMatrices.ProjMatrix.M[2][2],1),
FPlane(0,0,View.ViewMatrices.ProjMatrix.M[3][2],0)
) * View.InvViewProjectionMatrix * WorldToComponent;
SetShaderValue(RHICmdList, ShaderRHI, ScreenToDecal, ScreenToDecalValue);
}
// Set the transform from light space to world space (only for normals)
if(DecalToWorld.IsBound())
{
const FMatrix DecalToWorldValue = ComponentTrans.ToMatrixNoScale();
// 1,1,1 requires no scale
// DecalToWorldValue = DecalToWorldValue.GetScaled(GDefaultDecalSize);
SetShaderValue(RHICmdList, ShaderRHI, DecalToWorld, DecalToWorldValue);
}
}