void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View, FLightShaftsOutput LightShaftsOutput) { FGlobalShader::SetParameters(RHICmdList, GetPixelShader(), View); SceneTextureParameters.Set(RHICmdList, GetPixelShader(), View); ExponentialParameters.Set(RHICmdList, GetPixelShader(), &View); if (LightShaftsOutput.bRendered) { SetTextureParameter( RHICmdList, GetPixelShader(), OcclusionTexture, OcclusionSampler, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), LightShaftsOutput.LightShaftOcclusion->GetRenderTargetItem().ShaderResourceTexture ); } else { SetTextureParameter( RHICmdList, GetPixelShader(), OcclusionTexture, OcclusionSampler, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), GWhiteTexture->TextureRHI ); } }
void FSimpleElementPS::SetParameters(const FTexture* TextureValue) { SetTextureParameter(GetPixelShader(),InTexture,InTextureSampler,TextureValue); SetShaderValue(GetPixelShader(),TextureComponentReplicate,TextureValue->bGreyScaleFormat ? FLinearColor(1,0,0,0) : FLinearColor(0,0,0,0)); SetShaderValue(GetPixelShader(),TextureComponentReplicateAlpha,TextureValue->bGreyScaleFormat ? FLinearColor(1,0,0,0) : FLinearColor(0,0,0,1)); }
/** Sets shader parameter values */ void SetParameters(FRHICommandList& RHICmdList, const FLightSceneInfo* LightSceneInfo, const FViewInfo& View, int32 PassIndex, TRefCountPtr<IPooledRenderTarget>& PassSource) { FGlobalShader::SetParameters(RHICmdList, GetPixelShader(), View); LightShaftParameters.SetParameters(RHICmdList, GetPixelShader(), LightSceneInfo, View, PassSource); const FVector4 Parameters(GLightShaftBlurNumSamples, GLightShaftFirstPassDistance, PassIndex); SetShaderValue(RHICmdList, GetPixelShader(), RadialBlurParameters, Parameters); }
void FCubemapTexturePropertiesPS<bHDROutput>::SetParameters( FRHICommandList& RHICmdList, const FTexture* Texture, const FMatrix& ColorWeightsValue, float MipLevel, float GammaValue ) { SetTextureParameter(RHICmdList, GetPixelShader(),CubeTexture,CubeTextureSampler,Texture); FVector4 PackedProperties0Value(MipLevel, 0, 0, 0); SetShaderValue(RHICmdList, GetPixelShader(), PackedProperties0, PackedProperties0Value); SetShaderValue(RHICmdList, GetPixelShader(), ColorWeights, ColorWeightsValue); SetShaderValue(RHICmdList, GetPixelShader(), Gamma, GammaValue); }
/** Sets shader parameter values */ void SetParameters(FRHICommandList& RHICmdList, const FLightSceneInfo* LightSceneInfo, const FViewInfo& View, TRefCountPtr<IPooledRenderTarget>& PassSource) { FGlobalShader::SetParameters(RHICmdList, GetPixelShader(), View); LightShaftParameters.SetParameters(RHICmdList, GetPixelShader(), LightSceneInfo, View, PassSource); const FIntPoint BufferSize = FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY(); FVector2D SampleOffsets(1.0f / BufferSize.X, 1.0f / BufferSize.Y); SetShaderValue(RHICmdList, GetPixelShader(),SampleOffsetsParameter,SampleOffsets); SceneTextureParams.Set(RHICmdList, GetPixelShader(), View); }
/** * 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() ); }
/** Sets shader parameter values */ void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View, TRefCountPtr<IPooledRenderTarget>& LightShaftOcclusion) { FGlobalShader::SetParameters(RHICmdList, GetPixelShader(), View); SetTextureParameter( RHICmdList, GetPixelShader(), SourceTextureParameter, SourceTextureSamplerParameter, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), LightShaftOcclusion->GetRenderTargetItem().ShaderResourceTexture ); }
void SetParameters(FRHICommandList& RHICmdList, int32 SourceMipIndexValue, FTextureRHIRef& SourceTextureValue) { SetShaderValue(RHICmdList, GetPixelShader(), SourceMipIndex, SourceMipIndexValue); SetTextureParameter( RHICmdList, GetPixelShader(), SourceTexture, SourceTextureSampler, TStaticSamplerState<SF_Point, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI(), SourceTextureValue); }
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); }
void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(RHICmdList, ShaderRHI, View ); FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList); const FIntPoint GBufferSize = SceneContext.GetBufferSizeXY(); const FVector2D InvSize( 1.0f / float(GBufferSize.X), 1.0f / float(GBufferSize.Y) ); const FVector4 InputUvFactorAndOffset ( float(2 * View.HZBMipmap0Size.X) / float(GBufferSize.X), float(2 * View.HZBMipmap0Size.Y) / float(GBufferSize.Y), float(View.ViewRect.Min.X) / float(GBufferSize.X), float(View.ViewRect.Min.Y) / float(GBufferSize.Y) ); const FVector2D InputViewportMaxBound ( float(View.ViewRect.Max.X) / float(GBufferSize.X) - 0.5f * InvSize.X, float(View.ViewRect.Max.Y) / float(GBufferSize.Y) - 0.5f * InvSize.Y ); SetShaderValue(RHICmdList, ShaderRHI, InvSizeParameter, InvSize ); SetShaderValue(RHICmdList, ShaderRHI, InputUvFactorAndOffsetParameter, InputUvFactorAndOffset ); SetShaderValue(RHICmdList, ShaderRHI, InputViewportMaxBoundParameter, InputViewportMaxBound ); SceneTextureParameters.Set(RHICmdList, ShaderRHI, View ); }
void SetParameters( #if LPV_VOLUME_TEXTURE FTextureRHIParamRef* LpvBufferSRVsIn, #else FShaderResourceViewRHIParamRef LpvBufferSRVIn, #endif FLpvReadUniformBufferRef LpvUniformBuffer, const FRenderingCompositePassContext& Context ) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); SetUniformBufferParameter( ShaderRHI, GetUniformBufferParameter<FLpvReadUniformBufferParameters>(), LpvUniformBuffer ); #if LPV_VOLUME_TEXTURE for ( int i=0; i<7; i++ ) { if ( LpvBufferSRVParameters[i].IsBound() ) { RHISetShaderTexture( ShaderRHI, LpvBufferSRVParameters[i].GetBaseIndex(), LpvBufferSRVsIn[i] ); SetTextureParameter( ShaderRHI, LpvBufferSRVParameters[i], LpvVolumeTextureSampler, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), LpvBufferSRVsIn[i] ); } } #else if ( LpvBufferSRV.IsBound() ) { RHISetShaderResourceViewParameter( ShaderRHI, LpvBufferSRV.GetBaseIndex(), LpvBufferSRVIn ); } #endif FGlobalShader::SetParameters(ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); DeferredParameters.Set(ShaderRHI, Context.View); SetTextureParameter( ShaderRHI, PreIntegratedGF, PreIntegratedGFSampler, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), GSystemTextures.PreintegratedGF->GetRenderTargetItem().ShaderResourceTexture ); }
void SetParameters(FRHICommandList& RHICmdList, const FViewInfo& View, FTextureRHIParamRef BoundsCenter, FTextureRHIParamRef BoundsExtent ) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(RHICmdList, ShaderRHI, View ); /* * Defines the maximum number of mipmaps the HZB test is considering * to avoid memory cache trashing when rendering on high resolution. */ const float kHZBTestMaxMipmap = 9.0f; const float HZBMipmapCounts = FMath::Log2(FMath::Max(View.HZBMipmap0Size.X, View.HZBMipmap0Size.Y)); const FVector HZBUvFactorValue( float(View.ViewRect.Width()) / float(2 * View.HZBMipmap0Size.X), float(View.ViewRect.Height()) / float(2 * View.HZBMipmap0Size.Y), FMath::Max(HZBMipmapCounts - kHZBTestMaxMipmap, 0.0f) ); const FVector4 HZBSizeValue( View.HZBMipmap0Size.X, View.HZBMipmap0Size.Y, 1.0f / float(View.HZBMipmap0Size.X), 1.0f / float(View.HZBMipmap0Size.Y) ); SetShaderValue(RHICmdList, ShaderRHI, HZBUvFactor, HZBUvFactorValue); SetShaderValue(RHICmdList, ShaderRHI, HZBSize, HZBSizeValue); SetTextureParameter(RHICmdList, ShaderRHI, HZBTexture, HZBSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), View.HZB->GetRenderTargetItem().ShaderResourceTexture ); SetTextureParameter(RHICmdList, ShaderRHI, BoundsCenterTexture, BoundsCenterSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), BoundsCenter ); SetTextureParameter(RHICmdList, ShaderRHI, BoundsExtentTexture, BoundsExtentSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), BoundsExtent ); }
void SetParameters( FTextureRHIParamRef* LpvBufferSRVsIn, FTextureRHIParamRef AOVolumeTextureSRVIn, FLpvReadUniformBufferRef LpvUniformBuffer, const FRenderingCompositePassContext& Context ) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); SetUniformBufferParameter(Context.RHICmdList, ShaderRHI, GetUniformBufferParameter<FLpvReadUniformBufferParameters>(), LpvUniformBuffer); for ( int i=0; i<7; i++ ) { if ( LpvBufferSRVParameters[i].IsBound() ) { Context.RHICmdList.SetShaderTexture(ShaderRHI, LpvBufferSRVParameters[i].GetBaseIndex(), LpvBufferSRVsIn[i]); SetTextureParameter(Context.RHICmdList, ShaderRHI, LpvBufferSRVParameters[i], LpvVolumeTextureSampler, TStaticSamplerState<SF_Bilinear, AM_Border, AM_Border, AM_Border>::GetRHI(), LpvBufferSRVsIn[i]); } } if ( AOVolumeTextureSRVParameter.IsBound() ) { Context.RHICmdList.SetShaderTexture(ShaderRHI, AOVolumeTextureSRVParameter.GetBaseIndex(), AOVolumeTextureSRVIn ); } FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI()); DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View); SetTextureParameter(Context.RHICmdList, ShaderRHI, PreIntegratedGF, PreIntegratedGFSampler, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI(), GSystemTextures.PreintegratedGF->GetRenderTargetItem().ShaderResourceTexture); }
void FSlateMaterialShaderPS::SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const FMaterialRenderProxy* MaterialRenderProxy, const FMaterial* Material, float InDisplayGamma, const FVector4& InShaderParams ) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); EBlendMode BlendMode = Material->GetBlendMode(); switch (BlendMode) { default: case BLEND_Opaque: RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI()); break; case BLEND_Masked: RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI()); break; case BLEND_Translucent: RHICmdList.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI()); break; case BLEND_Additive: // Add to the existing scene color RHICmdList.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI()); break; case BLEND_Modulate: // Modulate with the existing scene color RHICmdList.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_DestColor, BF_Zero>::GetRHI()); break; }; SetShaderValue( RHICmdList, ShaderRHI, DisplayGamma, InDisplayGamma ); SetShaderValue( RHICmdList, ShaderRHI, ShaderParams, InShaderParams ); const bool bDeferredPass = false; FMaterialShader::SetParameters<FPixelShaderRHIParamRef>(RHICmdList, ShaderRHI, MaterialRenderProxy, *Material, View, bDeferredPass, ESceneRenderTargetsMode::SetTextures); }
void FIESLightProfilePS::SetParameters( FRHICommandList& RHICmdList, const FTexture* Texture, float InBrightnessInLumens ) { FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); SetTextureParameter(RHICmdList, ShaderRHI, IESTexture, IESTextureSampler, Texture); SetShaderValue(RHICmdList, ShaderRHI, BrightnessInLumens, InBrightnessInLumens); }
void SetParameters(const FRenderingCompositePassContext& Context) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Border,AM_Border,AM_Border>::GetRHI()); }
void SetParameters(const FSceneView& View) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(ShaderRHI, View); DeferredParameters.Set(ShaderRHI, View); }
void SetParameters(FRHICommandList& RHICmdList, const FRenderingCompositePassContext& Context, const FMaterialRenderProxy* Material ) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FMaterialShader::SetParameters(RHICmdList, ShaderRHI, Material, *Material->GetMaterial(Context.View.GetFeatureLevel()), Context.View, true, ESceneRenderTargetsMode::SetTextures); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); }
void SetPS(const FRenderingCompositePassContext& Context, FIntRect SrcRect, FIntPoint SrcBufferSize, EStereoscopicPass StereoPass, FMatrix& QuadTexTransform) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View); { check(GEngine->HMDDevice.IsValid()); TSharedPtr< class IHeadMountedDisplay > HMDDevice = GEngine->HMDDevice; check (StereoPass != eSSP_FULL); if (StereoPass == eSSP_LEFT_EYE) { FTexture* TextureLeft = HMDDevice->GetDistortionTextureLeft(); SetTextureParameter(Context.RHICmdList, ShaderRHI, DistortionTextureParam, DistortionTextureSampler, TextureLeft->SamplerStateRHI, TextureLeft->TextureRHI); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureScale, HMDDevice->GetTextureScaleLeft()); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureOffset, HMDDevice->GetTextureOffsetLeft()); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureUVOffset, 0.0f); } else { FTexture* TextureRight = HMDDevice->GetDistortionTextureRight(); SetTextureParameter(Context.RHICmdList, ShaderRHI, DistortionTextureParam, DistortionTextureSampler, TextureRight->SamplerStateRHI, TextureRight->TextureRHI); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureScale, HMDDevice->GetTextureScaleRight()); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureOffset, HMDDevice->GetTextureOffsetRight()); SetShaderValue(Context.RHICmdList, ShaderRHI, TextureUVOffset, -0.5f); } QuadTexTransform = FMatrix::Identity; } }
void SetPS(const FRenderingCompositePassContext& Context, uint32 LoopSizeValue) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); SetShaderValue(Context.RHICmdList, ShaderRHI, LoopSize, LoopSizeValue); if(EyeAdaptationTexture.IsBound()) { if (Context.View.HasValidEyeAdaptation()) { IPooledRenderTarget* EyeAdaptationRT = Context.View.GetEyeAdaptation(); SetTextureParameter(Context.RHICmdList, ShaderRHI, EyeAdaptationTexture, EyeAdaptationRT->GetRenderTargetItem().TargetableTexture); } else { // some views don't have a state, thumbnail rendering? SetTextureParameter(Context.RHICmdList, ShaderRHI, EyeAdaptationTexture, GWhiteTexture->TextureRHI); } } // todo FVector4 EyeAdapationTemporalParamsValue(0, 0, 0, 0); SetShaderValue(Context.RHICmdList, ShaderRHI, EyeAdapationTemporalParams, EyeAdapationTemporalParamsValue); }
void SetParameters(const FRenderingCompositePassContext& Context) { const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings; const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI()); DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View); { float MaxRoughness = FMath::Clamp(Context.View.FinalPostProcessSettings.ScreenSpaceReflectionMaxRoughness, 0.01f, 1.0f); // f(x) = x * Scale + Bias // f(MaxRoughness) = 0 // f(MaxRoughness/2) = 1 float RoughnessMaskScale = -2.0f / MaxRoughness; RoughnessMaskScale *= SSRQuality < 3 ? 2.0f : 1.0f; FLinearColor Value( FMath::Clamp(Context.View.FinalPostProcessSettings.ScreenSpaceReflectionIntensity * 0.01f, 0.0f, 1.0f), RoughnessMaskScale, 0, 0); SetShaderValue(Context.RHICmdList, ShaderRHI, SSRParams, Value); } }
void SetParameters(const FRenderingCompositePassContext& Context) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); { const float SizeX = Context.View.ViewRect.Width(); const float SizeY = Context.View.ViewRect.Height(); const float InvAspectRatio = SizeY / SizeX; const FSceneViewState* ViewState = (FSceneViewState*) Context.View.State; const float MotionBlurTimeScale = ViewState ? ViewState->MotionBlurTimeScale : 1.0f; const float ViewMotionBlurScale = 0.5f * MotionBlurTimeScale * Context.View.FinalPostProcessSettings.MotionBlurAmount; // 0:no 1:full screen width float MaxVelocity = Context.View.FinalPostProcessSettings.MotionBlurMax / 100.0f; float InvMaxVelocity = 1.0f / MaxVelocity; float ObjectScaleX = ViewMotionBlurScale * InvMaxVelocity; float ObjectScaleY = ViewMotionBlurScale * InvMaxVelocity * InvAspectRatio; SetShaderValue( ShaderRHI, VelocityScale, FVector4( ObjectScaleX, -ObjectScaleY, 0, 0 ) ); } }
void SetPS(const FRenderingCompositePassContext& Context) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) { static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.GPUBusyWait")); uint32 PixelCount = Context.View.ViewRect.Size().X * Context.View.ViewRect.Size().Y; float CVarValue = FMath::Clamp(CVar->GetValueOnRenderThread(), 0.0f, 500.0f); // multiply with large number to get more human friendly number range // calibrated on a NV580 to be roughly a millisecond // divide by viewport pixel count uint32 Value = (uint32)(CVarValue * 1000000000.0 / 6.12 / PixelCount); SetShaderValue(ShaderRHI, GPUBusyWait, Value); } #endif }
void SetParameters(const FRenderingCompositePassContext& Context, float PixelKernelSize) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI()); { FTextureRHIParamRef TextureRHI = GWhiteTexture->TextureRHI; if(GEngine->DefaultBokehTexture) { FTextureResource* Resource = GEngine->DefaultBokehTexture->Resource; if(Resource && Resource->TextureRHI) { TextureRHI = Resource->TextureRHI; } } if(Context.View.FinalPostProcessSettings.LensFlareBokehShape) { FTextureResource* Resource = Context.View.FinalPostProcessSettings.LensFlareBokehShape->Resource; if(Resource && Resource->TextureRHI) { TextureRHI = Resource->TextureRHI; } } SetTextureParameter(Context.RHICmdList, ShaderRHI, LensTexture, LensTextureSampler, TStaticSamplerState<SF_Bilinear, AM_Border, AM_Border, AM_Clamp>::GetRHI(), TextureRHI); } }
/** Sets shader parameter values */ void SetParameters( FRHICommandList& RHICmdList, FSamplerStateRHIParamRef SamplerStateRHI, FTextureRHIParamRef FilterTextureRHI, FTextureRHIParamRef AdditiveTextureRHI, const FLinearColor* SampleWeightValues, const FVector2D* SampleOffsetValues, uint32 NumSamples ) { check(CompileTimeNumSamples == 0 && NumSamples > 0 && NumSamples <= MAX_FILTER_SAMPLES || CompileTimeNumSamples == NumSamples); const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); SetTextureParameter(RHICmdList, ShaderRHI, FilterTexture, FilterTextureSampler, SamplerStateRHI, FilterTextureRHI); SetTextureParameter(RHICmdList, ShaderRHI, AdditiveTexture, AdditiveTextureSampler, SamplerStateRHI, AdditiveTextureRHI); SetShaderValueArray(RHICmdList, ShaderRHI, SampleWeights, SampleWeightValues, NumSamples); if (CompileTimeNumSamples == 0) { // we needs additional setups for the dynamic loop FVector4 PackedSampleOffsetsValues[MAX_PACKED_SAMPLES_OFFSET]; for(uint32 SampleIndex = 0;SampleIndex < NumSamples;SampleIndex += 2) { PackedSampleOffsetsValues[SampleIndex / 2].X = SampleOffsetValues[SampleIndex + 0].X; PackedSampleOffsetsValues[SampleIndex / 2].Y = SampleOffsetValues[SampleIndex + 0].Y; if(SampleIndex + 1 < NumSamples) { PackedSampleOffsetsValues[SampleIndex / 2].W = SampleOffsetValues[SampleIndex + 1].X; PackedSampleOffsetsValues[SampleIndex / 2].Z = SampleOffsetValues[SampleIndex + 1].Y; } } SetShaderValueArray(RHICmdList, ShaderRHI, SampleOffsets, PackedSampleOffsetsValues, MAX_PACKED_SAMPLES_OFFSET); SetShaderValue(RHICmdList, ShaderRHI, SampleCount, NumSamples); } }
void SetPS(const FRenderingCompositePassContext& Context, uint16 InShadingModelMaskInView) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); DeferredParameters.Set(Context.RHICmdList, ShaderRHI, Context.View); static FLinearColor SoftBits[sizeof(InShadingModelMaskInView) * 8] = {}; // init with 0.0f for(uint32 i = 0; i < sizeof(InShadingModelMaskInView) * 8; ++i) { float& ref = SoftBits[i].R; ref -= Context.View.Family->DeltaWorldTime; ref = FMath::Max(0.0f, ref); if(InShadingModelMaskInView & (1 << i)) { ref = 1.0f; } } SetShaderValueArray(Context.RHICmdList, ShaderRHI, ShadingModelMaskInView, SoftBits, sizeof(InShadingModelMaskInView) * 8); }
void UnbindBuffers(FRHICommandList& RHICmdList) { // TODO: Is this necessary here? FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); #if LPV_VOLUME_TEXTURE for ( int i=0; i<7; i++ ) { if ( LpvBufferSRVParameters[i].IsBound() ) { RHICmdList.SetShaderTexture(ShaderRHI, LpvBufferSRVParameters[i].GetBaseIndex(), FTextureRHIParamRef()); } } #else if ( InLpvBuffer.IsBound() ) RHICmdList.SetShaderResourceViewParameter( ShaderRHI, InLpvBuffer.GetBaseIndex(), FShaderResourceViewRHIParamRef() ); #endif #if LPV_GV_VOLUME_TEXTURE for ( int i=0; i<3; i++ ) { if ( GvBufferSRVParameters[i].IsBound() ) { RHICmdList.SetShaderTexture(ShaderRHI, GvBufferSRVParameters[i].GetBaseIndex(), FTextureRHIParamRef()); } } #else if ( InGvBuffer.IsBound() ) RHICmdList.SetShaderResourceViewParameter( ShaderRHI, InGvBuffer.GetBaseIndex(), FShaderResourceViewRHIParamRef() ); #endif }
void SetParameters(const FRenderingCompositePassContext& Context, IPooledRenderTarget& DistortionRT) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FTextureRHIParamRef DistortionTextureValue = DistortionRT.GetRenderTargetItem().ShaderResourceTexture; FTextureRHIParamRef SceneColorTextureValue = GSceneRenderTargets.GetSceneColor()->GetRenderTargetItem().ShaderResourceTexture; // Here we use SF_Point as in fullscreen the pixels are 1:1 mapped. SetTextureParameter( Context.RHICmdList, ShaderRHI, DistortionTexture, DistortionTextureSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), DistortionTextureValue ); SetTextureParameter( Context.RHICmdList, ShaderRHI, SceneColorTexture, SceneColorTextureSampler, TStaticSamplerState<SF_Bilinear,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), SceneColorTextureValue ); FIntPoint SceneBufferSize = GSceneRenderTargets.GetBufferSizeXY(); FIntRect ViewportRect = Context.GetViewport(); FVector4 SceneColorRectValue = FVector4((float)ViewportRect.Min.X/SceneBufferSize.X, (float)ViewportRect.Min.Y/SceneBufferSize.Y, (float)ViewportRect.Max.X/SceneBufferSize.X, (float)ViewportRect.Max.Y/SceneBufferSize.Y); SetShaderValue(Context.RHICmdList, ShaderRHI, SceneColorRect, SceneColorRectValue); }
void SetParameters(const FRenderingCompositePassContext& Context) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); FGlobalShader::SetParameters(ShaderRHI, Context.View); PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI()); }
/** Sets shader parameter values */ void SetParameters(FRHICommandList& RHICmdList, FSamplerStateRHIParamRef SamplerStateRHI, FTextureRHIParamRef FilterTextureRHI, FTextureRHIParamRef AdditiveTextureRHI, const FLinearColor* SampleWeightValues) { const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader(); SetTextureParameter(RHICmdList, ShaderRHI, FilterTexture, FilterTextureSampler, SamplerStateRHI, FilterTextureRHI); SetTextureParameter(RHICmdList, ShaderRHI, AdditiveTexture, AdditiveTextureSampler, SamplerStateRHI, AdditiveTextureRHI); SetShaderValueArray(RHICmdList, ShaderRHI, SampleWeights, SampleWeightValues, NumSamples); }