码迷,mamicode.com
首页 > 其他好文 > 详细

17032002(动态AO DOF)

时间:2018-06-25 15:19:30      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:weight   front   rar   编辑器   lam   oca   初始   9.png   中间   

【目标】

摄像机相关的AO DOF

【思路】

1 方案1: 

  • 想添加一个相机节点放入后期链中


2 方案2:

  • 在Uber节点属性中添加是否镜头相关属性

3 问题:
  • 远近的两套参数在哪配置



4 整个后期数据流程:

技术分享图片

技术分享图片

 

 

 


5 主要的数据控制在ULocalPlayer中


6 Blend计算

技术分享图片


7 后期链
技术分享图片
 
后期需求:

  • 地图可以单独配置出来特效后期链
  • 系统设置高中低可以配置后期链的参数或者在后期链的节点上处理(添加等级节点)
  • 跟相机相关的后期(DOF、AO)



9 后期编辑器
  • PostProcessEditor.h PostProcessEditor.cpp

 

10 高中低配置方案:

  • UPostProcessChain 中添加高中的Effect列表
  • 技术分享图片
  • 在后期中编辑器连接不同首节点,下图概念图
  • 技术分享图片 

  •  


11 相机相关后期方案:

  • 在UberPostProcess节点添加最近参数PostProcessSettings结构
  • 新建一个结构,包括Settings和Camera相关参数
  • 在根据CameraPitch生成Setting后,再使用ULocalPlayer.OverridePostProcessSettings 去覆盖


12 问题:在平视角 但是需要远景时怎么办(如Matineee中)?

  • 所以对话时,打开主角界面时,用的是一个配置PPSettings
  • 退出时恢复
  • 开启相机相关的,对话等优先级要比相机相关的优先级高

13 在ULocalPlayer 中有个后期链列表

  • ULocalPlayer.PlayerPostProcessChains
  • 更新这个列表后要Rebuild一次,将列表中所有后期链的Effect加到ULocalPlayer.PlayerPostProcess 中
  • 后面统一处理


14 问题:对话 主角界面这种使用PPSettings还是后期链?








【步骤】

1 修改\ue3\Development\Src\Engine\Classes\UberPostProcessEffect.uc 添加

struct native   NearCameraPostProcessSettings
{
    var PostProcessSettings Settings;
    var INT DestCameraPitch;
};
var (Camera) NearCameraPostProcessSettings NearCameraSettings

技术分享图片

 
初始值 
pitchMax=64626
pitchMin=58800


2 修改 添加开关、Max Min

struct native NearCameraPostProcessSettings
{
    var() PostProcessSettings Settings;
    var() INT CameraPitchMin;
    var() INT CameraPitchMax;
    
structcpptext
{
    FNearCameraPostProcessSettings():
    CameraPitchMin(64626),
    CameraPitchMax(58800)
    {
        
    }
}
};
var (Camera) bool bUseNearCameraSettings;
var (Camera) NearCameraPostProcessSettings NearCameraSettings;




3 包一个函UPostProcessChain* GetActivePostProccessChain()

UPostProcessChain* ULocalPlayer::GetActivePostProccessChain(const FVector& ViewLocation)
{
    // Find the post-process settings for the view.
    FPostProcessSettings NewSettings;
    APostProcessVolume *NewVolume;
    //    LEVEL
    NewVolume = GWorld->GetWorldInfo()->GetPostProcessSettings(ViewLocation, TRUE, NewSettings);
    bForceDefaultPostProcessChain = FALSE;
    if (NewVolume && NewVolume->bOverrideWorldPostProcessChain)
    {
        bForceDefaultPostProcessChain = TRUE;
    }
    if (GEngine->bForceUseDefaultPostProcess && GWorld->GetWorldInfo()->bDefaultPostProcessPriority)
    {
        bForceDefaultPostProcessChain = TRUE;
    }
    // Use the default post process instead of the players if it been requested (usually when entering a pp volume)
    return (bForceDefaultPostProcessChain) ? GEngine->GetDefaultPostProcessChain() : PlayerPostProcess;
}


在ULocalPlayer.UpdatePostProcessSettings 之前 调用他,为了获取最终后期链的相机相关开关

    UPostProcessChain *ActivePostProccessChain = GetActivePostProccessChain(ViewLocation);
    // Update the player‘s post process settings.
    UpdatePostProcessSettings(ViewLocation);


此时需要去遍历后期链的Effect,每个调用一个更新相机相关的函数

需要添加虚函数


4 \ue3\Development\Src\Engine\Classes\PostProcessEffect.uc

    virtual UBOOL GetPPSettingsForCamera(const FRotator& ViewRotation,FPostProcessSettings& PPS)
    {
    }


ue3\Development\Src\Engine\Classes\UberPostProcessEffect.uc中重载

UBOOL UUberPostProcessEffect::GetPPSettingsForCamera(const FRotator& ViewRotation,FPostProcessSettings& PPS)
{
    if (bUseNearCameraSettings)
    {
        FLOAT Alpha = (FLOAT)(NearCameraSettings.CameraPitchMax - ViewRotation.Pitch) / 
            (FLOAT)(NearCameraSettings.CameraPitchMax -NearCameraSettings.CameraPitchMin);
        NearCameraSettings.Settings.OverrideSettingsFor(PPS,Alpha);
    }
    return bUseNearCameraSettings;
}




UUberPostProcessEffect::GetPPSettingsForCamera

UBOOL UUberPostProcessEffect::GetPPSettingsForCamera(const FRotator& ViewRotation,FPostProcessSettings& PPS)
{
    if (bUseNearCameraSettings)
    {
        FLOAT Alpha = (FLOAT)(NearCameraSettings.CameraPitchMax - ViewRotation.Pitch) / 
            (FLOAT)(NearCameraSettings.CameraPitchMax -NearCameraSettings.CameraPitchMin);
        NearCameraSettings.Settings.OverrideSettingsFor(PPS,Alpha);
    }
    return bUseNearCameraSettings;
}


6 ULocalPlayer.UpdateNearCamPP 

void ULocalPlayer::UpdateNearCamPP(UPostProcessChain* PPC, const FRotator& ViewRotation)
{
    if (PPC)
    {
        for (INT EffectIndex = 0; EffectIndex < PPC->Effects.Num(); EffectIndex++)
        {
            UPostProcessEffect* PPEffect = PPC->Effects(EffectIndex);
            FPostProcessSettings NewPPS;
            if (PPEffect && PPEffect->GetPPSettingsForCamera(ViewRotation,NewPPS))
            {
                OverridePostProcessSettings(NewPPS);
                break;
            }
        }
    }
}


ULocalPlayer.CalcSceneView 调用

    UPostProcessChain *ActivePostProccessChain = GetActivePostProccessChain(ViewLocation);
    UpdateNearCamPP(ActivePostProccessChain,ViewRotation);
    // Update the player‘s post process settings.
    UpdatePostProcessSettings(ViewLocation);


  • 只能修改UpdatePostProcessSettings函数了 添加参数
  • 需要在函数中间去取PPsetinggs,中途再去用NearCamPPS去override


ULocalPlayer.UpdatePostProcessSettings 修改为

    //    CAMERA OVERRIDE
    //    NOTE: Matinee works through this channel
    if(Actor && Actor->PlayerCamera && Actor->PlayerCamera->CamOverridePostProcessAlpha > 0.f)
    {
        //Blend the currently computed level settings with the camera‘s settings at the camera‘s alpha level
        Actor->PlayerCamera->CamPostProcessSettings.OverrideSettingsFor(CurrentPPInfo.LastSettings, Actor->PlayerCamera->CamOverridePostProcessAlpha);
    }
    //    END CAMERA OVERRIDE
    // Near Camera PPS Blend
    OverridePPSettingsForCamera(PPC,ViewRotation,CurrentPPInfo.LastSettings);
    


技术分享图片

 



7 在FViewInfo.FViewInfo中处理PPSettings的方式
技术分享图片
  • 必须开启UesWorldSettings开关才能使用,
  • 也就是说不能依赖这个开关去应用Settings
  • 后面如果需要程序直接控制DOF之类的还需要应用一套Settings

目前的流程是
技术分享图片
 

 
如果新思路,每个步骤添加镜头参数

技术分享图片


方案:
  • ACamera.CamPostProcessSettings 还需存一套参数用于镜头的
  • AWorldInfo.DefaultPostProcessSettings 也需要添加一套参数用于镜头的
  • APostProcessVolume.Settings 还需存一套参数用于镜头的
  • 如果没应用PPSettings,如何启用镜头相关?答:必须启用PPSettings
  • 修改FViewInfo.FViewInfo中处理PPSettings的方式


 

 8 在PostProcess基类中添加Camera的属性,
新建一个结构体用于Camera的Settings,不需要那么多
PPSettings没有AO相关的配置参数,
节点上有
技术分享图片

但是有绘制用结构体FAmbientOcclusionSettings 
技术分享图片
在Render时,将UAmbientOcclusionEffect 转成这个AOSettings
问题:怎么将镜头相关的计算结果传递到FAmbientOcclusionSceneProxy.AOSettings ?
答:每帧构造FSceneRenderer ->创建   
.CreateSceneProxy -> 传递一个AOSettings到
FAmbientOcclusionSceneProxy

同理看下DOF传递
UDOFEffect.FocusInnerRadius -> FSceneView.DepthOfFieldParams -> 
创建好 FDOFAndBloomPostProcessSceneProxy.CalcDoFParams 计算出DOF参数,传入Shader -> 
FDOFShaderParameters.SetPS - >
FDepthOfFieldParams.FocusInnerRadius 


  • 要将FAmbientOcclusionSettings 声明到uc中
  • AO节点用FAmbientOcclusionSettings 
  • DOF节点用FDOFSettings 
  • 各自的CreateSceneProxy去计算相机相关,传递Setttings

 
9 添加\ue3\Development\Src\Engine\Classes\AmbientOcclusionEffect.uc添加结构体
struct native AOSettings
{
    var    bool            bOverride_LinearColor;
    var    bool            bOverride_OcclusionPower;
    var    bool            bOverride_OcclusionScale;
    var    bool            bOverride_OcclusionBias;
    var    bool            bOverride_MinOcclusion;
    var    bool            bOverride_OcclusionRadius;
    var    bool            bOverride_OcclusionQuality;
    var    bool            bOverride_OcclusionFadeoutMinDistance;
    var    bool            bOverride_OcclusionFadeoutMaxDistance;
    var    bool            bOverride_HaloDistanceThreshold;
    var    bool            bOverride_HaloDistanceScale;
    var    bool            bOverride_HaloOcclusion;
    var    bool            bOverride_EdgeDistanceThreshold;
    var    bool            bOverride_EdgeDistanceScale;
    var    bool            bOverride_FilterDistanceScale;
    var    bool            bOverride_HistoryOcclusionConvergenceTime;
    var    bool            bOverride_HistoryWeightConvergenceTime;
    var    bool            bOverride_bAngleBasedSSAO;
    //See AmbientOcclusionEffect.uc for descriptions
    var() LinearColor OcclusionColor<editcondition=bOverride_OcclusionColor>;
    var() float OcclusionPower<editcondition=bOverride_OcclusionPower>;
    var() float OcclusionScale<editcondition=OcclusionScale>;
    var() float OcclusionBias<editcondition=bOverride_OcclusionBias>;
    var() float MinOcclusion<editcondition=bOverride_MinOcclusion>;
    var() float OcclusionRadius<editcondition=bOverride_OcclusionRadius>;
    var() EAmbientOcclusionQuality OcclusionQuality<editcondition=bOverride_OcclusionQuality>;
    var() float OcclusionFadeoutMinDistance<editcondition=bOverride_OcclusionFadeoutMinDistance>;
    var() float OcclusionFadeoutMaxDistance<editcondition=bOverride_OcclusionFadeoutMaxDistance>;
    var() float HaloDistanceThreshold<editcondition=bOverride_HaloDistanceThreshold>;
    var() float HaloDistanceScale<editcondition=bOverride_HaloDistanceScale>;
    var() float HaloOcclusion<editcondition=bOverride_HaloOcclusion>;
    var() float EdgeDistanceThreshold<editcondition=bOverride_EdgeDistanceThreshold>;
    var() float EdgeDistanceScale<editcondition=bOverride_EdgeDistanceScale>;
    var() float FilterDistanceScale<editcondition=bOverride_FilterDistanceScale>;
    var() float HistoryOcclusionConvergenceTime<editcondition=bOverride_HistoryOcclusionConvergenceTime>;
    var() float HistoryWeightConvergenceTime<editcondition=bOverride_HistoryWeightConvergenceTime>;
    var() bool bAngleBasedSSAO<editcondition=bOverride_bAngleBasedSSAO>;
structcpptext
{
}
};
struct native NearCameraAOSettings
{
    var() AOSettings Settings;
    var() INT CameraPitchMin;
    var() INT CameraPitchMax;
    
structcpptext
{
    FNearCameraAOSettings():
    CameraPitchMin(64626),
    CameraPitchMax(58800)
    {
        appMemzero(&Settings, sizeof(FPostProcessSettings));
    }
}
};
...
var(Camera) bool bUseCamAOSettings;
var(Camera) NearCameraAOSettings CamAOSettings<editcondition=bUseCamAOSettings>;


 


10 DOF也需要添加
struct native DOFSetings
{
/** Determines if DOF_FalloffExponent variable will be overridden. */
var bool bOverride_DOF_FalloffExponent;
/** Determines if DOF_BlurKernelSize variable will be overridden. */
var bool bOverride_DOF_BlurKernelSize;
/** Determines if DOF_BlurBloomKernelSize variable will be overridden. */
var bool bOverride_DOF_BlurBloomKernelSize;
/** Determines if DOF_MaxNearBlurAmount variable will be overridden. */
var bool bOverride_DOF_MaxNearBlurAmount;
/** Determines if DOF_MinBlurAmount variable will be overridden. */
var bool bOverride_DOF_MinBlurAmount;

/** Determines if DOF_MaxFarBlurAmount variable will be overridden. */
var bool bOverride_DOF_MaxFarBlurAmount;
/** Determines if DOF_FocusType variable will be overridden. */
var bool bOverride_DOF_FocusType;
/** Determines if DOF_FocusInnerRadius variable will be overridden. */
var bool bOverride_DOF_FocusInnerRadius;
/** Determines if DOF_FocusDistance variable will be overridden. */
var bool bOverride_DOF_FocusDistance;
/** Determines if DOF_FocusPosition variable will be overridden. */
var bool bOverride_DOF_FocusPosition;
/** Determines if DOF_InterpolationDuration variable will be overridden. */
var bool bOverride_DOF_InterpolationDuration;

/** Determines if DOF_BokehTexture variable will be overridden. */
var bool bOverride_DOF_BokehTexture;

/** Exponent to apply to blur amount after it has been normalized to [0,1]. */
var(DepthOfField) interp float DOF_FalloffExponent<editcondition=bOverride_DOF_FalloffExponent>;
/** affects the radius of the DepthOfField bohek / how blurry the scene gets */
var(DepthOfField) interp float DOF_BlurKernelSize<editcondition=bOverride_DOF_BlurKernelSize>;
/** [0,1] value for clamping how much blur to apply to items in front of the focus plane. */
var(DepthOfField, BlurAmount) interp float DOF_MaxNearBlurAmount<editcondition=bOverride_DOF_MaxNearBlurAmount | DisplayName=MaxNear>;
/** [0,1] value for clamping how much blur to apply. */
var(DepthOfField, BlurAmount) interp float DOF_MinBlurAmount<editcondition=bOverride_DOF_MinBlurAmount | DisplayName=Min>;
/** [0,1] value for clamping how much blur to apply to items behind the focus plane. */
var(DepthOfField, BlurAmount) interp float DOF_MaxFarBlurAmount<editcondition=bOverride_DOF_MaxFarBlurAmount | DisplayName=MaxFar>;
/** Controls how the focus point is determined. */
var(DepthOfField) EFocusType DOF_FocusType<editcondition=bOverride_DOF_FocusType>;
/** Inner focus radius. */
var(DepthOfField) interp float DOF_FocusInnerRadius<editcondition=bOverride_DOF_FocusInnerRadius>;
/** Used when FOCUS_Distance is enabled. */
var(DepthOfField) interp float DOF_FocusDistance<editcondition=bOverride_DOF_FocusDistance>;
/** Used when FOCUS_Position is enabled. */
var(DepthOfField) vector DOF_FocusPosition<editcondition=bOverride_DOF_FocusPosition>;
/** Duration over which to interpolate values to. */
var(DepthOfField) float DOF_InterpolationDuration<editcondition=bOverride_DOF_InterpolationDuration>;
/** Name of the Bokeh texture e.g. EngineMaterial.BokehTexture, empty if not used */
var(DepthOfField) Texture2D DOF_BokehTexture<editcondition=bOverride_DOF_BokehTexture>;


};


struct native NearCameraDOFSettings
{
var() DOFSetings Settings;
var() INT CameraPitchMin;
var() INT CameraPitchMax;
structcpptext
{
FNearCameraDOFSettings():
CameraPitchMin(64626),
CameraPitchMax(58800)
{
}
}
};

var(Camera) bool bUseCamDOFSettings;
var(Camera) NearCameraDOFSettings CamDOFSettings<editcondition=bUseCamDOFSettings>;



11 添加Settings的Override函数
struct native NearCameraAOSettings
{
...
    void OverrideSettings(const FCameraInfo& CI,FAOSettings& Settings);


structcpptext
{
    /**
        * Blends the settings on this structure marked as override setting onto the given settings
        *
        * @param    ToOverride    The settings that get overridden by the overridable settings on this structure. 
        * @param    Alpha        The opacity of these settings. If Alpha is 1, ToOverride will equal this setting structure.
        */
    void OverrideSettingsFor( FAOSettings& ToOverride, FLOAT Alpha=1.f ) const;
}


12 修改UPostProcessEffect.CreateSceneProxy 参数传入相机Info
FAmbientOcclusionSettings 添加相机Info




13 FDOFAndBloomPostProcessSceneProxy.FDOFAndBloomPostProcessSceneProxy 
需要新建一个DOF相关的Settings用于
\ue3\Development\Src\Engine\Classes\DOFEffect.uc
struct native DepthOfFieldSettings
{
    var float    FalloffExponent;
    var float    BlurKernelSize;
    var float    MaxNearBlurAmount;
    var float    MinBlurAmount;
    var float    MaxFarBlurAmount;
    var    EFocusType        FocusType;
    var float    FocusInnerRadius;
    var float    FocusDistance;
    var    vector    FocusPosition;
    var    float    InterpolationDuration;
};

将FDOFAndBloomPostProcessSceneProxy 类的一些DOF属性归类
    FDepthOfFieldSettings DOFProperty;
//    FLOAT FalloffExponent;
//    FLOAT BlurKernelSize;
    FLOAT BlurBloomKernelSize;
//    FLOAT MaxNearBlurAmount;
//    FLOAT MinBlurAmount;
//    FLOAT MaxFarBlurAmount;
//    BYTE FocusType;
//    FLOAT FocusInnerRadius;
//    FLOAT FocusDistance;
//    FVector FocusPosition;



FDOFAndBloomPostProcessSceneProxy.FDOFAndBloomPostProcessSceneProxy 构造
//     SET_POSTPROCESS_PROPERTY1(DOF, FalloffExponent);
        SET_POSTPROCESS_PROPERTY1(DOF, BlurKernelSize);
//     SET_POSTPROCESS_PROPERTY1(DOF, BlurBloomKernelSize);
//     SET_POSTPROCESS_PROPERTY1(DOF, MaxNearBlurAmount);
//     SET_POSTPROCESS_PROPERTY1(DOF, MinBlurAmount);
//     SET_POSTPROCESS_PROPERTY1(DOF, MaxFarBlurAmount);
//     SET_POSTPROCESS_PROPERTY1(DOF, FocusType);
//     SET_POSTPROCESS_PROPERTY1(DOF, FocusInnerRadius);
//     SET_POSTPROCESS_PROPERTY1(DOF, FocusDistance);
//     SET_POSTPROCESS_PROPERTY1(DOF, FocusPosition);
    SET_POSTPROCESS_PROPERTY1(DOF, BokehTexture);
    SET_POSTPROCESS_DOFPROPERTY(DOF, FalloffExponent);
    SET_POSTPROCESS_DOFPROPERTY(DOF, BlurKernelSize);
    SET_POSTPROCESS_DOFPROPERTY(DOF, BlurBloomKernelSize);
    SET_POSTPROCESS_DOFPROPERTY(DOF, MaxNearBlurAmount);
    SET_POSTPROCESS_DOFPROPERTY(DOF, MinBlurAmount);
    SET_POSTPROCESS_DOFPROPERTY(DOF, MaxFarBlurAmount);
    SET_POSTPROCESS_DOFPROPERTY(DOF, FocusType);
    SET_POSTPROCESS_DOFPROPERTY(DOF, FocusInnerRadius);
    SET_POSTPROCESS_DOFPROPERTY(DOF, FocusDistance);
    SET_POSTPROCESS_DOFPROPERTY(DOF, FocusPosition);
...
    // clamp DOF radius in reasonable bound 
    DOFProperty.BlurKernelSize = Clamp(DOFProperty.BlurKernelSize, 0.0f, 128.0f);


#define SET_POSTPROCESS_DOFPROPERTY(Group, Name) DOFProperty.Name = GET_POSTPROCESS_PROPERTY_X(Group, Name, Name);

FDOFSetings.OverrideSettingsFor 
#define LERP_DOFSETTINGS(Name) \
    if( bOverride_##Name ) \
{ \
    ToOverride.##Name = Lerp(ToOverride.##Name, ##Name, Alpha); \
}
void FDOFSetings::OverrideSettingsFor( FDepthOfFieldSettings& ToOverride, FLOAT Alpha=1.f) const
{
    // TOGGLE OVERRIDES
    if (Alpha <= 0.0f)
    {
        return;
    }
    LERP_DOFSETTINGS(FalloffExponent);
    LERP_DOFSETTINGS(BlurKernelSize);
    LERP_DOFSETTINGS(MaxNearBlurAmount);
    LERP_DOFSETTINGS(MinBlurAmount);
    LERP_DOFSETTINGS(MaxFarBlurAmount);
    LERP_DOFSETTINGS(FocusType);
    LERP_DOFSETTINGS(FocusInnerRadius);
    LERP_DOFSETTINGS(FocusDistance);
    LERP_DOFSETTINGS(FocusPosition);
    LERP_DOFSETTINGS(InterpolationDuration);
}


FNearCameraDOFSettings.OverrideSettings 
void FNearCameraDOFSettings::OverrideSettings(const FCameraInfo& CI,FDepthOfFieldSettings& ToOverride) const
{
    FLOAT DistanceAlpha = 1.f;
    FLOAT PitchAlpha = 1.f;
    UBOOL bOveriride = FALSE;
    if (CameraInfoMin.bEdit_CameraDistance && CameraInfoMax.bEdit_CameraDistance)
    {
        DistanceAlpha = (CameraInfoMax.CameraDistance - CI.CameraDistance) /
            (CameraInfoMax.CameraDistance - CameraInfoMin.CameraDistance);
        bOveriride = TRUE;
    }
    if (CameraInfoMin.bEdit_CameraPitch && CameraInfoMax.bEdit_CameraPitch)
    {
        PitchAlpha = (CameraInfoMax.CameraPitch - CI.CameraPitch) /
            (CameraInfoMax.CameraPitch - CameraInfoMin.CameraPitch);
        bOveriride = TRUE;
    }
    if (bOveriride)
    {
        FLOAT Alpha = Min(DistanceAlpha,PitchAlpha);
        Settings.OverrideSettingsFor(ToOverride,Alpha);
    }
}



FDOFAndBloomPostProcessSceneProxy.ComputeDOFParams 
        Params.FalloffExponent = DOFProperty.FalloffExponent;
        Params.MaxNearBlurAmount = DOFProperty.MaxNearBlurAmount;
        Params.MinBlurAmount = DOFProperty.MinBlurAmount;
        Params.MaxFarBlurAmount = DOFProperty.MaxFarBlurAmount;


FDOFAndBloomPostProcessSceneProxy.CalcDoFParams 
    switch( DOFProperty.FocusType )
    {
    case FOCUS_Position:
        {
            // world space focus point specified projected onto the view direction
            FocusPoint = (((DOFProperty.FocusPosition - View.ViewOrigin) | ViewDir) * ViewDir) + View.ViewOrigin;
        }        
        break;
    case FOCUS_Distance:
    default:
        {
            // focus point based on view distance
            FocusPoint = (DOFProperty.FocusDistance * ViewDir) + View.ViewOrigin;
        }        
        break;
    };
    // transform to projected/clip space in order to get w depth values
    OutFocusDistance = Max<FLOAT>(0.f, View.WorldToScreen(FocusPoint).W);
    // Add radius to get the far focus point
    FVector FocusPointFar = (ViewDir * DOFProperty.FocusInnerRadius) + FocusPoint;    
    FLOAT FocusDistanceFar = Max<FLOAT>(OutFocusDistance, View.WorldToScreen(FocusPointFar).W);
    OutFocusRadius = Max<FLOAT>((FLOAT)KINDA_SMALL_NUMBER, Abs<FLOAT>(FocusDistanceFar - OutFocusDistance));


FDOFAndBloomPostProcessSceneProxy.Render 
    GaussianBlurFilterBuffer(View, View.SizeX, DownsampledSizeX + AntiLeakBorder, DownsampledSizeY + AntiLeakBorder, DOFProperty.BlurKernelSize, 1.0f, SRTI_FilterColor0, SampleMaskMin, SampleMaskMax);
...
    BlendPixelShader->PostProcessParameters.SetPS(*BlendPixelShader, DOFProperty.BlurKernelSize, DOFOcclusionTweak);



修改FUberPostProcessSceneProxy 参数


14 FDOFAndBloomPostProcessSceneProxy.FDOFAndBloomPostProcessSceneProxy中最后去更新一下DOF镜头覆盖参数
    if (InEffect->bUseCamDOFSettings)
        InEffect->CamDOFSettings.OverrideSettings(CI,DOFProperty);

15 FViewInfo.FViewInfo. 传递CameraInfo
                    FCameraInfo CI;
                    CI.bEdit_CameraPitch = TRUE;
                    CI.CameraPitch = GCameraRotation.Pitch;
                    FPostProcessSceneProxy* PostProcessSceneProxy = Effect->CreateSceneProxy(
                        PostProcessSettings && Effect->bUseWorldSettings ? PostProcessSettings : NULL,CI
                        );

16 添加角度处理函数
inline INT ShortestRoute(INT Angle)
{
    Angle = Angle & 65535;
    if(Angle >= 32768)
        Angle -= 65536;
    return Angle;
}

17 FNearCameraAOSettings.OverrideSettings 改为
        INT Max = ShortestRoute(CameraInfoMax.CameraPitch);
        INT Min = ShortestRoute(CameraInfoMin.CameraPitch);
        INT Cur = ShortestRoute(CI.CameraPitch);
        PitchAlpha = (FLOAT)(Max -Cur) / (FLOAT)(Max - Min);




【小结】
  • 上面只是节点上的相机参数融合
  • 还有PPSettings还没有处理

运行





方案: 处理PPSettings
  • 添加一个PostProcessSettings作为相机参数
  • AWorldInfo.GetPostProcessSettings 中处理Override




18 \ue3\Development\Src\Engine\Classes\WorldInfo.uc
var(Camera) bool bUseCamDOFSettings;
var(Camera) NearCameraDOFSettings CamDOFSettings<editcondition=bUseCamDOFSettings>;
var(Camera) bool bUseCamAOSettings;
var(Camera) NearCameraAOSettings CamAOSettings<editcondition=bUseCamAOSettings>;

19 \Development\Src\Engine\Classes\DOFEffect.uc 添加Override支持PPSettings

20 AWorldInfo.GetPostProcessSettings 
        if (CurrentWorldInfo->bUseCamDOFSettings)
        {
            FCameraInfo CI(TRUE,FALSE,ViewRotation.Pitch,0.f);;
            CurrentWorldInfo->CamDOFSettings.OverrideSettings(CI,OutPostProcessSettings);
        }
        if (CurrentWorldInfo->bUseCamAOSettings)
        {
            FCameraInfo CI(TRUE,FALSE,ViewRotation.Pitch,0.f);;
            CurrentWorldInfo->CamAOSettings.OverrideSettings(CI,OutPostProcessSettings);
        }



技术分享图片这个修改TODO
技术分享图片
 

 


18 








【运行】


 

3






17032002(动态AO DOF)

标签:weight   front   rar   编辑器   lam   oca   初始   9.png   中间   

原文地址:https://www.cnblogs.com/username/p/9223927.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!