/** * Sets all the constant parameters for this shader * * @param Texture - 2d tile texture * @param Gamma - if gamma != 1.0 then a pow(color,Gamma) is applied * @param ClipRef - reference value to compare with alpha for killing pixels * @param SmoothWidth - The width to smooth the edge the texture * @param EnableShadow - Toggles drop shadow rendering * @param ShadowDirection - 2D vector specifying the direction of shadow * @param ShadowColor - Color of the shadowed pixels * @param ShadowSmoothWidth - The width to smooth the edge the shadow of the texture * @param BlendMode - current batched element blend mode being rendered */ void FSimpleElementDistanceFieldGammaPS::SetParameters( const FTexture* Texture, float Gamma, float ClipRef, float SmoothWidthValue, bool EnableShadowValue, const FVector2D& ShadowDirectionValue, const FLinearColor& ShadowColorValue, float ShadowSmoothWidthValue, const FDepthFieldGlowInfo& GlowInfo, ESimpleElementBlendMode BlendMode ) { FSimpleElementMaskedGammaPS::SetParameters(Texture,Gamma,ClipRef,BlendMode); SetShaderValue(GetPixelShader(),SmoothWidth,SmoothWidthValue); SetPixelShaderBool(GetPixelShader(),EnableShadow,EnableShadowValue); if (EnableShadowValue) { SetShaderValue(GetPixelShader(),ShadowDirection,ShadowDirectionValue); SetShaderValue(GetPixelShader(),ShadowColor,ShadowColorValue); SetShaderValue(GetPixelShader(),ShadowSmoothWidth,ShadowSmoothWidthValue); } SetPixelShaderBool(GetPixelShader(),EnableGlow,GlowInfo.bEnableGlow); if (GlowInfo.bEnableGlow) { SetShaderValue(GetPixelShader(),GlowColor,GlowInfo.GlowColor); SetShaderValue(GetPixelShader(),GlowOuterRadius,GlowInfo.GlowOuterRadius); SetShaderValue(GetPixelShader(),GlowInnerRadius,GlowInfo.GlowInnerRadius); } // This shader does not use editor compositing SetEditorCompositingParameters( NULL, FTexture2DRHIRef() ); }
void FTranslucentPrimSet::DrawPrimitivesForForwardShading(FRHICommandListImmediate& RHICmdList, const FViewInfo& View, FSceneRenderer& Renderer) const { // Draw sorted scene prims for (int32 PrimIdx = 0; PrimIdx < SortedPrims.Num(); PrimIdx++) { FPrimitiveSceneInfo* PrimitiveSceneInfo = SortedPrims[PrimIdx].PrimitiveSceneInfo; int32 PrimitiveId = PrimitiveSceneInfo->GetIndex(); const FPrimitiveViewRelevance& ViewRelevance = View.PrimitiveViewRelevanceMap[PrimitiveId]; checkSlow(ViewRelevance.HasTranslucency()); if(ViewRelevance.bDrawRelevance) { FTranslucencyForwardShadingDrawingPolicyFactory::ContextType Context; //@todo parallelrendering - come up with a better way to filter these by primitive for (int32 MeshBatchIndex = 0; MeshBatchIndex < View.DynamicMeshElements.Num(); MeshBatchIndex++) { const FMeshBatchAndRelevance& MeshBatchAndRelevance = View.DynamicMeshElements[MeshBatchIndex]; if (MeshBatchAndRelevance.PrimitiveSceneProxy == PrimitiveSceneInfo->Proxy) { const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh; FTranslucencyForwardShadingDrawingPolicyFactory::DrawDynamicMesh(RHICmdList, View, Context, MeshBatch, false, false, MeshBatchAndRelevance.PrimitiveSceneProxy, MeshBatch.BatchHitProxyId); } } // Render static scene prim if( ViewRelevance.bStaticRelevance ) { // Render static meshes from static scene prim for( int32 StaticMeshIdx=0; StaticMeshIdx < PrimitiveSceneInfo->StaticMeshes.Num(); StaticMeshIdx++ ) { FStaticMesh& StaticMesh = PrimitiveSceneInfo->StaticMeshes[StaticMeshIdx]; if (View.StaticMeshVisibilityMap[StaticMesh.Id] // Only render static mesh elements using translucent materials && StaticMesh.IsTranslucent(View.GetFeatureLevel()) ) { FTranslucencyForwardShadingDrawingPolicyFactory::DrawStaticMesh( RHICmdList, View, FTranslucencyForwardShadingDrawingPolicyFactory::ContextType(), StaticMesh, false, PrimitiveSceneInfo->Proxy, StaticMesh.BatchHitProxyId ); } } } } } View.SimpleElementCollector.DrawBatchedElements(RHICmdList, View, FTexture2DRHIRef(), EBlendModeFilter::Translucent); }
void URadiantCanvasRenderTarget::BeginPaint(float InRealTime, float InWorldTime, float InWorldDeltaTime, ERHIFeatureLevel::Type FeatureLevel) { check(Canvas == nullptr); // Setup the viewport ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER ( SetupRenderTargetViewport, FTextureRenderTarget2DResource*, RenderTarget, (FTextureRenderTarget2DResource*)RenderTargetTexture->GameThread_GetRenderTargetResource(), { SetRenderTarget(RHICmdList, RenderTarget->GetRenderTargetTexture(), FTexture2DRHIRef()); RHICmdList.SetViewport(0, 0, 0.0f, RenderTarget->GetSizeXY().X, RenderTarget->GetSizeXY().Y, 1.0f); }
void UCanvasRenderTarget2D::UpdateResource() { // Call parent implementation Super::UpdateResource(); // Don't allocate canvas object for CRT2D CDO if(IsTemplate()) { return; } // Create or find the canvas object to use to render onto the texture. Multiple canvas render target textures can share the same canvas. static const FName CanvasName( TEXT( "CanvasRenderTarget2DCanvas" ) ); UCanvas* Canvas = (UCanvas*)StaticFindObjectFast(UCanvas::StaticClass(), GetTransientPackage(), CanvasName ); if (Canvas == nullptr) { Canvas = ConstructObject<UCanvas>(UCanvas::StaticClass(), GetTransientPackage(), CanvasName ); Canvas->AddToRoot(); } Canvas->Init(GetSurfaceWidth(), GetSurfaceHeight(), nullptr); Canvas->Update(); // Update the resource immediately to remove it from the deferred resource update list. This prevents the texture // from being cleared each frame. UpdateResourceImmediate(); // Enqueue the rendering command to set up the rendering canvas. ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER ( CanvasRenderTargetMakeCurrentCommand, FTextureRenderTarget2DResource*, TextureRenderTarget, (FTextureRenderTarget2DResource*)GameThread_GetRenderTargetResource(), { SetRenderTarget(RHICmdList, TextureRenderTarget->GetRenderTargetTexture(), FTexture2DRHIRef()); RHICmdList.SetViewport(0, 0, 0.0f, TextureRenderTarget->GetSizeXY().X, TextureRenderTarget->GetSizeXY().Y, 1.0f); }
FTexture2DRHIRef FEmptyDynamicRHI::RHIGetViewportBackBuffer(FViewportRHIParamRef ViewportRHI) { DYNAMIC_CAST_EMPTYRESOURCE(Viewport,Viewport); return FTexture2DRHIRef(); }
void UKUISubContainerRenderCache::UpdateRenderCache( UKUIInterfaceElement* oElement ) { if ( oElement == NULL ) { KUIErrorUO( "Null element" ); return; } KUILogUO( "Updating Render Cache" ); UKUISubContainer* const ctSub = Cast<UKUISubContainer>( oElement ); const FVector2D v2ElemSize = ctSub->GetTotalSize(); if ( v2ElemSize.X < 1.f || v2ElemSize.Y < 1.f ) { KUIErrorUO( "Element is zero size" ); return; } bool bRebuildTexture = false; if ( GetTexture() == NULL ) bRebuildTexture = true; else if ( v2ElemSize.X != GetTexture()->GetSurfaceWidth() || v2ElemSize.Y != GetTexture()->GetSurfaceHeight() ) bRebuildTexture = true; if ( bRebuildTexture ) CreateRenderCache( v2ElemSize ); if ( GetTexture() == NULL ) { KUIErrorUO( "Texture is null" ); return; } if ( !GetTexture()->IsA<UTextureRenderTarget2D>() ) { KUIErrorUO( "Texture is not a render target" ); return; } UTextureRenderTarget2D* const tRenderTarget = Cast<UTextureRenderTarget2D>( GetTexture() ); tRenderTarget->UpdateResource(); tRenderTarget->UpdateResourceImmediate(); UCanvas* uoCanvas = Cast<UCanvas>( StaticFindObjectFast( UCanvas::StaticClass(), GetTransientPackage(), FName( TEXT( "Sub Container Render Cache Canvas" ) ) ) ); if ( uoCanvas == NULL ) { uoCanvas = NewObject<UCanvas>( GetTransientPackage(), FName( TEXT( "Sub Container Render Cache Canvas" ) ) ); uoCanvas->AddToRoot(); } uoCanvas->Init( floor( v2ElemSize.X ), floor( v2ElemSize.Y ), NULL ); uoCanvas->Update(); ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER( CanvasRenderTargetMakeCurrentCommand, FTextureRenderTarget2DResource*, TextureRenderTarget, static_cast<FTextureRenderTarget2DResource*>( tRenderTarget->GameThread_GetRenderTargetResource() ), { SetRenderTarget( RHICmdList, TextureRenderTarget->GetRenderTargetTexture(), FTexture2DRHIRef() ); RHICmdList.SetViewport( 0, 0, 0.0f, TextureRenderTarget->GetSizeXY().X, TextureRenderTarget->GetSizeXY().Y, 1.0f ); }
FTexture2DRHIRef FEmptyDynamicRHI::RHIAsyncCreateTexture2D(uint32 SizeX,uint32 SizeY,uint8 Format,uint32 NumMips,uint32 Flags,void** InitialMipData,uint32 NumInitialMips) { UE_LOG(LogEmpty, Fatal, TEXT("RHIAsyncCreateTexture2D is not supported")); return FTexture2DRHIRef(); }
FTexture2DRHIRef FEmptyDynamicRHI::RHIGetViewportBackBuffer(FViewportRHIParamRef ViewportRHI) { FEmptyViewport* Viewport = ResourceCast(ViewportRHI); return FTexture2DRHIRef(); }