├── Config ├── DefaultEditor.ini ├── DefaultEngine.ini ├── DefaultGame.ini └── DefaultInput.ini ├── Content ├── BP_DepthPeeling.uasset ├── Cube.uasset ├── Depth_Peel.uasset ├── Geometry │ └── Meshes │ │ ├── 1M_Cube.uasset │ │ ├── 1M_Cube_Chamfer.uasset │ │ ├── CubeMaterial.uasset │ │ └── TemplateFloor.uasset ├── M_Actor_ColorDepth.uasset ├── M_Cube_ColorDepth.uasset ├── M_Cube_Opaque.uasset ├── M_Cube_Translucent.uasset ├── M_Cube_Translucent_CustomDepth.uasset ├── M_PP_Compose.uasset ├── M_UE4Man_ColorDepth.uasset ├── Mannequin │ ├── Animations │ │ ├── ThirdPersonIdle.uasset │ │ ├── ThirdPersonJump_End.uasset │ │ ├── ThirdPersonJump_Loop.uasset │ │ ├── ThirdPersonJump_Start.uasset │ │ ├── ThirdPersonRun.uasset │ │ ├── ThirdPersonWalk.uasset │ │ ├── ThirdPerson_AnimBP.uasset │ │ ├── ThirdPerson_IdleRun_2D.uasset │ │ └── ThirdPerson_Jump.uasset │ └── Character │ │ ├── Materials │ │ ├── M_UE4Man_Body.uasset │ │ ├── M_UE4Man_ChestLogo.uasset │ │ └── MaterialLayers │ │ │ ├── ML_GlossyBlack_Latex_UE4.uasset │ │ │ ├── ML_Plastic_Shiny_Beige.uasset │ │ │ ├── ML_Plastic_Shiny_Beige_LOGO.uasset │ │ │ ├── ML_SoftMetal_UE4.uasset │ │ │ ├── T_ML_Aluminum01.uasset │ │ │ ├── T_ML_Aluminum01_N.uasset │ │ │ ├── T_ML_Rubber_Blue_01_D.uasset │ │ │ └── T_ML_Rubber_Blue_01_N.uasset │ │ ├── Mesh │ │ ├── SK_Mannequin.uasset │ │ ├── SK_Mannequin_PhysicsAsset.uasset │ │ └── UE4_Mannequin_Skeleton.uasset │ │ └── Textures │ │ ├── UE4Man_Logo_N.uasset │ │ ├── UE4_LOGO_CARD.uasset │ │ ├── UE4_Mannequin_MAT_MASKA.uasset │ │ └── UE4_Mannequin__normals.uasset ├── Materials │ ├── M_UE4Man_Body.uasset │ ├── M_UE4Man_ChestLogo.uasset │ └── MaterialLayers │ │ ├── ML_GlossyBlack_Latex_UE4.uasset │ │ ├── ML_Plastic_Shiny_Beige.uasset │ │ ├── ML_Plastic_Shiny_Beige_LOGO.uasset │ │ ├── ML_SoftMetal_UE4.uasset │ │ ├── T_ML_Aluminum01.uasset │ │ ├── T_ML_Aluminum01_N.uasset │ │ ├── T_ML_Rubber_Blue_01_D.uasset │ │ └── T_ML_Rubber_Blue_01_N.uasset ├── NewMap.umap ├── NewMap_BuiltData.uasset ├── Peel_Blend.uasset ├── Peel_Blend_2.uasset ├── RT.uasset ├── RT_Black.uasset ├── ThirdPerson │ └── Meshes │ │ ├── Bump_StaticMesh.uasset │ │ ├── LeftArm_StaticMesh.uasset │ │ ├── Linear_Stair_StaticMesh.uasset │ │ ├── RampMaterial.uasset │ │ ├── Ramp_StaticMesh.uasset │ │ └── RightArm_StaticMesh.uasset └── ThirdPersonBP │ ├── Blueprints │ ├── ThirdPersonCharacter.uasset │ └── ThirdPersonGameMode.uasset │ ├── Maps │ ├── ThirdPersonExampleMap.umap │ └── ThirdPersonExampleMap_BuiltData.uasset │ └── ThirdPersonOverview.uasset ├── OITDemo.uproject ├── README.md ├── Screenshots └── 1.jpg ├── Shaders └── PeelBlend.usf └── Source ├── OITDemo.Target.cs ├── OITDemo ├── DepthPeeling.cpp ├── DepthPeeling.h ├── OITDemo.Build.cs ├── OITDemo.cpp └── OITDemo.h └── OITDemoEditor.Target.cs /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/HardwareTargeting.HardwareTargetingSettings] 4 | TargetedHardwareClass=Desktop 5 | AppliedTargetedHardwareClass=Desktop 6 | DefaultGraphicsPerformance=Maximum 7 | AppliedDefaultGraphicsPerformance=Maximum 8 | 9 | [/Script/Engine.Engine] 10 | +ActiveGameNameRedirects=(OldGameName="TP_BlankBP",NewGameName="/Script/OITDemo") 11 | +ActiveGameNameRedirects=(OldGameName="/Script/TP_BlankBP",NewGameName="/Script/OITDemo") 12 | 13 | [/Script/EngineSettings.GameMapsSettings] 14 | EditorStartupMap=/Game/ThirdPersonBP/Maps/ThirdPersonExampleMap.ThirdPersonExampleMap 15 | GameDefaultMap=/Game/ThirdPersonBP/Maps/ThirdPersonExampleMap.ThirdPersonExampleMap 16 | 17 | [/Script/Engine.RendererSettings] 18 | r.EarlyZPass=3 19 | r.CustomDepthTemporalAAJitter=False 20 | r.CustomDepth=2 21 | 22 | -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | 2 | 3 | [/Script/EngineSettings.GeneralProjectSettings] 4 | ProjectID=98BDA0FB424A4C32521A65A061974438 5 | -------------------------------------------------------------------------------- /Config/DefaultInput.ini: -------------------------------------------------------------------------------- 1 | [/Script/Engine.InputSettings] 2 | -AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 3 | -AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 4 | -AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 5 | -AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 6 | -AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 7 | -AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 8 | -AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 9 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 10 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 11 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 12 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 13 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 14 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 15 | +AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 16 | +AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 17 | +AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 18 | +AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 19 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 20 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 21 | +AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 22 | +AxisConfig=(AxisKeyName="Daydream_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 23 | +AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 24 | +AxisConfig=(AxisKeyName="Daydream_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 25 | +AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 26 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 27 | +AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 28 | +AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 29 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 30 | +AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 31 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 32 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 33 | +AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 34 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 35 | +AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 36 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 37 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 38 | +AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 39 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 40 | +AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 41 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 42 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 43 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 44 | +AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 45 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 46 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 47 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 48 | +AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 49 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 50 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 51 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 52 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 53 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 54 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 55 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 56 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 57 | +AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Touch",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 58 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 59 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 60 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 61 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 62 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 63 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 64 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 65 | +AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 66 | bAltEnterTogglesFullscreen=True 67 | bF11TogglesFullscreen=True 68 | bUseMouseForTouch=False 69 | bEnableMouseSmoothing=True 70 | bEnableFOVScaling=True 71 | bCaptureMouseOnLaunch=True 72 | bAlwaysShowTouchInterface=False 73 | bShowConsoleOnFourFingerTap=True 74 | bEnableGestureRecognizer=False 75 | bUseAutocorrect=False 76 | DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown 77 | DefaultViewportMouseLockMode=LockOnCapture 78 | FOVScale=0.011110 79 | DoubleClickTime=0.200000 80 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom) 81 | +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) 82 | +ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R) 83 | +AxisMappings=(AxisName="LookUp",Scale=-1.000000,Key=MouseY) 84 | +AxisMappings=(AxisName="LookUpRate",Scale=1.000000,Key=Gamepad_RightY) 85 | +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=Down) 86 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Gamepad_LeftY) 87 | +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S) 88 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Up) 89 | +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) 90 | +AxisMappings=(AxisName="MoveRight",Scale=-1.000000,Key=A) 91 | +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D) 92 | +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=Gamepad_LeftX) 93 | +AxisMappings=(AxisName="Turn",Scale=1.000000,Key=MouseX) 94 | +AxisMappings=(AxisName="TurnRate",Scale=1.000000,Key=Gamepad_RightX) 95 | +AxisMappings=(AxisName="TurnRate",Scale=-1.000000,Key=Left) 96 | +AxisMappings=(AxisName="TurnRate",Scale=1.000000,Key=Right) 97 | DefaultPlayerInputClass=/Script/Engine.PlayerInput 98 | DefaultInputComponentClass=/Script/Engine.InputComponent 99 | DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks 100 | -ConsoleKeys=Tilde 101 | +ConsoleKeys=Tilde 102 | 103 | -------------------------------------------------------------------------------- /Content/BP_DepthPeeling.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/BP_DepthPeeling.uasset -------------------------------------------------------------------------------- /Content/Cube.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Cube.uasset -------------------------------------------------------------------------------- /Content/Depth_Peel.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Depth_Peel.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Geometry/Meshes/1M_Cube.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/1M_Cube_Chamfer.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Geometry/Meshes/1M_Cube_Chamfer.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/CubeMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Geometry/Meshes/CubeMaterial.uasset -------------------------------------------------------------------------------- /Content/Geometry/Meshes/TemplateFloor.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Geometry/Meshes/TemplateFloor.uasset -------------------------------------------------------------------------------- /Content/M_Actor_ColorDepth.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_Actor_ColorDepth.uasset -------------------------------------------------------------------------------- /Content/M_Cube_ColorDepth.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_Cube_ColorDepth.uasset -------------------------------------------------------------------------------- /Content/M_Cube_Opaque.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_Cube_Opaque.uasset -------------------------------------------------------------------------------- /Content/M_Cube_Translucent.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_Cube_Translucent.uasset -------------------------------------------------------------------------------- /Content/M_Cube_Translucent_CustomDepth.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_Cube_Translucent_CustomDepth.uasset -------------------------------------------------------------------------------- /Content/M_PP_Compose.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_PP_Compose.uasset -------------------------------------------------------------------------------- /Content/M_UE4Man_ColorDepth.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/M_UE4Man_ColorDepth.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonIdle.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonIdle.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_End.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonJump_End.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_Loop.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonJump_Loop.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonJump_Start.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonJump_Start.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonRun.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonRun.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPersonWalk.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPersonWalk.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_AnimBP.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPerson_AnimBP.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_IdleRun_2D.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPerson_IdleRun_2D.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Animations/ThirdPerson_Jump.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Animations/ThirdPerson_Jump.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/M_UE4Man_Body.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/M_UE4Man_Body.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/M_UE4Man_ChestLogo.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/M_UE4Man_ChestLogo.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/SK_Mannequin.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Mesh/SK_Mannequin.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/SK_Mannequin_PhysicsAsset.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Mesh/SK_Mannequin_PhysicsAsset.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Mesh/UE4_Mannequin_Skeleton.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Mesh/UE4_Mannequin_Skeleton.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4Man_Logo_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Textures/UE4Man_Logo_N.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_LOGO_CARD.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Textures/UE4_LOGO_CARD.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_Mannequin_MAT_MASKA.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Textures/UE4_Mannequin_MAT_MASKA.uasset -------------------------------------------------------------------------------- /Content/Mannequin/Character/Textures/UE4_Mannequin__normals.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Mannequin/Character/Textures/UE4_Mannequin__normals.uasset -------------------------------------------------------------------------------- /Content/Materials/M_UE4Man_Body.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/M_UE4Man_Body.uasset -------------------------------------------------------------------------------- /Content/Materials/M_UE4Man_ChestLogo.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/M_UE4Man_ChestLogo.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/ML_GlossyBlack_Latex_UE4.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/ML_Plastic_Shiny_Beige.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/ML_Plastic_Shiny_Beige_LOGO.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/ML_SoftMetal_UE4.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/T_ML_Aluminum01.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/T_ML_Aluminum01.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/T_ML_Aluminum01_N.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/T_ML_Rubber_Blue_01_D.uasset -------------------------------------------------------------------------------- /Content/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Materials/MaterialLayers/T_ML_Rubber_Blue_01_N.uasset -------------------------------------------------------------------------------- /Content/NewMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/NewMap.umap -------------------------------------------------------------------------------- /Content/NewMap_BuiltData.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/NewMap_BuiltData.uasset -------------------------------------------------------------------------------- /Content/Peel_Blend.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Peel_Blend.uasset -------------------------------------------------------------------------------- /Content/Peel_Blend_2.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/Peel_Blend_2.uasset -------------------------------------------------------------------------------- /Content/RT.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/RT.uasset -------------------------------------------------------------------------------- /Content/RT_Black.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/RT_Black.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Bump_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/Bump_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/LeftArm_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/LeftArm_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Linear_Stair_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/Linear_Stair_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/RampMaterial.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/RampMaterial.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/Ramp_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/Ramp_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPerson/Meshes/RightArm_StaticMesh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPerson/Meshes/RightArm_StaticMesh.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPersonBP/Blueprints/ThirdPersonCharacter.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonBP/Blueprints/ThirdPersonGameMode.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPersonBP/Blueprints/ThirdPersonGameMode.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonBP/Maps/ThirdPersonExampleMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPersonBP/Maps/ThirdPersonExampleMap.umap -------------------------------------------------------------------------------- /Content/ThirdPersonBP/Maps/ThirdPersonExampleMap_BuiltData.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPersonBP/Maps/ThirdPersonExampleMap_BuiltData.uasset -------------------------------------------------------------------------------- /Content/ThirdPersonBP/ThirdPersonOverview.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Content/ThirdPersonBP/ThirdPersonOverview.uasset -------------------------------------------------------------------------------- /OITDemo.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.26", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "OITDemo", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default", 11 | "AdditionalDependencies": [ 12 | "Engine" 13 | ] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UE4_OITDemo 2 | Order Independent Translucent Rendering Using Depth Peeling Method In UE4 3 | 4 | https://www.zhihu.com/people/chen-yong-59-86 5 | 6 | Screenshots: 7 | 8 | ![](https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/main/Screenshots/1.jpg) 9 | -------------------------------------------------------------------------------- /Screenshots/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyong2github/UE4_OITDemo/ea61daa476d44255d6aca324de9be5b9f7651510/Screenshots/1.jpg -------------------------------------------------------------------------------- /Shaders/PeelBlend.usf: -------------------------------------------------------------------------------- 1 | // Alpha Blend 2 | half3 Color = lerp(pow(Above, 0.45), Below, 1 - Alpha); 3 | 4 | // Above Only 5 | half3 AboveOnly = step(0.001, Above) * Color; 6 | 7 | // Above Clipped 8 | half3 AboveClipped = step(0.999, 1 - Above) * Below; 9 | 10 | // Add 11 | return AboveOnly + AboveClipped; -------------------------------------------------------------------------------- /Source/OITDemo.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class OITDemoTarget : TargetRules 7 | { 8 | public OITDemoTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Game; 11 | DefaultBuildSettings = BuildSettingsVersion.V2; 12 | 13 | ExtraModuleNames.AddRange( new string[] { "OITDemo" } ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/OITDemo/DepthPeeling.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | 4 | #include "DepthPeeling.h" 5 | 6 | #include "Engine.h" 7 | #include "EngineUtils.h" 8 | #include "DrawDebugHelpers.h" 9 | #include "Engine/SceneCapture2D.h" 10 | #include "Engine/PostProcessVolume.h" 11 | #include "Components/SceneCaptureComponent.h" 12 | #include "Components/SceneCaptureComponent2D.h" 13 | #include "Engine/TextureRenderTarget2D.h" 14 | #include "Materials/MaterialInstanceDynamic.h" 15 | 16 | static int32 s_TickCount = 0; 17 | 18 | // Sets default values 19 | ADepthPeeling::ADepthPeeling() 20 | { 21 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 22 | PrimaryActorTick.bCanEverTick = true; 23 | PrimaryActorTick.TickGroup = ETickingGroup::TG_PostUpdateWork; 24 | } 25 | 26 | // Called when the game starts or when spawned 27 | void ADepthPeeling::BeginPlay() 28 | { 29 | Super::BeginPlay(); 30 | 31 | UWorld* World = GetWorld(); 32 | 33 | if (OITActors.Num() <= 0) 34 | { 35 | return; 36 | } 37 | 38 | for (TActorIterator It(GetWorld()); It; ++It) 39 | { 40 | PlayerCameraManager = (*It)->PlayerCameraManager; 41 | break; 42 | } 43 | 44 | for (TActorIterator It(World); It; ++It) 45 | { 46 | SceneCapture2D = *It; 47 | break; 48 | } 49 | 50 | if (!SceneCapture2D) 51 | { 52 | return; 53 | } 54 | 55 | USceneCaptureComponent2D* SceneCaptureComponent2D = SceneCapture2D->GetCaptureComponent2D(); 56 | SceneCaptureComponent2D->PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList; 57 | SceneCaptureComponent2D->CaptureSource = ESceneCaptureSource::SCS_SceneColorSceneDepth; 58 | SceneCaptureComponent2D->bCaptureEveryFrame = false; 59 | 60 | // Load OITActor's material and create mid 61 | //M_Actor_ColorDepth = LoadObject(GetTransientPackage(), TEXT("/Game/M_UE4Man_ColorDepth.M_UE4Man_ColorDepth")); 62 | //if (M_Actor_ColorDepth) 63 | //{ 64 | // MID_Actor_ColorDepth = UMaterialInstanceDynamic::Create(M_Actor_ColorDepth, this, FName("MID_Actor_ColorDepth")); 65 | //} 66 | 67 | // Set OITActor render only in SceneCaptureComponent2D 68 | for (AActor* OITActor : OITActors) 69 | { 70 | OITActor->SetOwner(PlayerCameraManager->GetViewTarget()); 71 | 72 | TArray MeshComponents; 73 | OITActor->GetComponents(MeshComponents, true); 74 | for (UMeshComponent* MeshComponent : MeshComponents) 75 | { 76 | MeshComponent->bOwnerNoSee = true; 77 | 78 | /* 79 | const TArray MaterialInterfaces = MeshComponent->GetMaterials(); 80 | for (int32 i = 0; i < MaterialInterfaces.Num(); ++i) 81 | { 82 | // Replace the translucent section 83 | UMaterialInterface* MaterialInterface = MaterialInterfaces[i]; 84 | if (MaterialInterface->GetBlendMode() == EBlendMode::BLEND_Translucent) 85 | { 86 | MeshComponent->SetMaterial(i, MID_Actor_ColorDepth); 87 | } 88 | } 89 | */ 90 | } 91 | 92 | // Add OITActor to SceneCaptureComponent2D 93 | SceneCaptureComponent2D->ShowOnlyActors.Add(OITActor); 94 | } 95 | 96 | // Load post process compose material and set to PostProcessVolume 97 | M_PP_Compose = LoadObject(GetTransientPackage(), TEXT("/Game/M_PP_Compose.M_PP_Compose")); 98 | if (M_PP_Compose != nullptr) 99 | { 100 | MID_PP_Compose = UMaterialInstanceDynamic::Create(M_PP_Compose, this, FName("MID_PP_Compose")); 101 | } 102 | 103 | for (TActorIterator It(GetWorld()); It; ++It) 104 | { 105 | PostProcessVolume = (*It); 106 | break; 107 | } 108 | 109 | PostProcessVolume = World->PostProcessVolumes.Num() > 0 ? (APostProcessVolume*)World->PostProcessVolumes[0] : nullptr; 110 | } 111 | 112 | // Called every frame 113 | void ADepthPeeling::Tick(float DeltaTime) 114 | { 115 | Super::Tick(DeltaTime); 116 | 117 | UWorld* World = GetWorld(); 118 | 119 | if (OITActors.Num() <= 0) 120 | { 121 | return; 122 | } 123 | 124 | if (!PlayerCameraManager) 125 | { 126 | return; 127 | } 128 | 129 | /* Draw Debug Line 130 | FVector LineTrace = PlayerCameraManager->GetActorForwardVector() * 10000.0f; 131 | LineTrace -= PlayerCameraManager->GetCameraLocation(); 132 | DrawDebugLine(World, PlayerCameraManager->GetCameraLocation(), LineTrace, FColor::Red); 133 | */ 134 | 135 | if (!SceneCapture2D) 136 | { 137 | return; 138 | } 139 | 140 | FVector2D ViewportSize(1, 1); 141 | if (GEngine && GEngine->GameViewport) 142 | { 143 | GEngine->GameViewport->GetViewportSize(ViewportSize); 144 | } 145 | 146 | // Update SceneCapture2D transform 147 | USceneCaptureComponent2D* SceneCaptureComponent2D = SceneCapture2D->GetCaptureComponent2D(); 148 | SceneCapture2D->SetActorLocationAndRotation(PlayerCameraManager->GetCameraLocation(), PlayerCameraManager->GetCameraRotation()); 149 | SceneCaptureComponent2D->FOVAngle = PlayerCameraManager->GetFOVAngle(); 150 | SceneCaptureComponent2D->OrthoWidth = PlayerCameraManager->GetOrthoWidth(); 151 | 152 | UTextureRenderTarget2D* TextureRenderTarget2D = SceneCaptureComponent2D->TextureTarget; 153 | if (!TextureRenderTarget2D) 154 | { 155 | return; 156 | } 157 | 158 | TextureRenderTarget2D->InitCustomFormat(ViewportSize.X, ViewportSize.Y, PF_FloatRGBA, false); 159 | 160 | // Capture scene PeelingNum times 161 | for (int32 Index = 0; Index < PeelingNum; Index++) 162 | { 163 | if (!RT_ColorDepths.IsValidIndex(Index)) 164 | { 165 | // Create RT_ColorDepth 166 | FName Name = *FString::Format(TEXT("RT_ColorDepth_{0}"), { Index }); 167 | UTextureRenderTarget2D* RT_ColorDepth = NewObject(this, Name); 168 | RT_ColorDepth->ClearColor = FLinearColor::Transparent; 169 | RT_ColorDepths.Add(RT_ColorDepth); 170 | } 171 | 172 | RT_ColorDepths[Index]->InitCustomFormat(ViewportSize.X, ViewportSize.Y, PF_FloatRGBA, false); 173 | 174 | // Set last RT_Color and RT_Depth to MID_Mask_Actor except for the first time 175 | if (Index >= 1) 176 | { 177 | for (AActor* OITActor : OITActors) 178 | { 179 | TArray MeshComponents; 180 | OITActor->GetComponents(MeshComponents, true); 181 | for (UMeshComponent* MeshComponent : MeshComponents) 182 | { 183 | const TArray MaterialInterfaces = MeshComponent->GetMaterials(); 184 | for (int32 i = 0; i < MaterialInterfaces.Num(); ++i) 185 | { 186 | UMaterialInstanceDynamic* MID = Cast(MaterialInterfaces[i]); 187 | if (!MID) 188 | { 189 | MID = UMaterialInstanceDynamic::Create(MaterialInterfaces[i], this); 190 | MeshComponent->SetMaterial(i, MID); 191 | } 192 | 193 | MID->SetTextureParameterValue(TEXT("RT_Depth"), RT_ColorDepths[Index - 1]); 194 | } 195 | } 196 | } 197 | } 198 | 199 | // Capture color and copy to RT_Color 200 | SceneCaptureComponent2D->CaptureScene(); 201 | 202 | UTextureRenderTarget2D* RT_TextureTarget = SceneCaptureComponent2D->TextureTarget; 203 | UTextureRenderTarget2D* RT_ColorDepth = RT_ColorDepths[Index]; 204 | 205 | ENQUEUE_RENDER_COMMAND(FCopyToRT_ColorDepth)( 206 | [RT_TextureTarget, RT_ColorDepth](FRHICommandListImmediate& RHICmdList) 207 | { 208 | check(IsInRenderingThread()); 209 | 210 | RHICmdList.CopyToResolveTarget( 211 | RT_TextureTarget->GetRenderTargetResource()->GetRenderTargetTexture(), 212 | RT_ColorDepth->GetRenderTargetResource()->GetRenderTargetTexture(), 213 | FResolveParams()); 214 | 215 | RHICmdList.ImmediateFlush(EImmediateFlushType::DispatchToRHIThread); 216 | }); 217 | 218 | FlushRenderingCommands(); 219 | } 220 | 221 | // Reset MID_Actor_Color's T_ColorDepth to default black 222 | UTexture* RT_Black = nullptr; 223 | for (AActor* OITActor : OITActors) 224 | { 225 | TArray MeshComponents; 226 | OITActor->GetComponents(MeshComponents, true); 227 | for (UMeshComponent* MeshComponent : MeshComponents) 228 | { 229 | const TArray MaterialInterfaces = MeshComponent->GetMaterials(); 230 | for (int32 i = 0; i < MaterialInterfaces.Num(); ++i) 231 | { 232 | UMaterialInstanceDynamic* MID = Cast(MaterialInterfaces[i]); 233 | if (MID) 234 | { 235 | UMaterial* BaseMaterial = MID->GetBaseMaterial(); 236 | BaseMaterial->GetTextureParameterValue(TEXT("RT_Depth"), RT_Black); 237 | MID->SetTextureParameterValue(TEXT("RT_Depth"), RT_Black); 238 | } 239 | } 240 | } 241 | } 242 | 243 | // Set all RT_Color to MID_PP_Compose for composing 244 | for (int32 Index = 0; Index < RT_ColorDepths.Num(); Index++) 245 | { 246 | FName Name = *FString::Format(TEXT("RT_Color_{0}"), { Index }); 247 | if (Index < PeelingNum) 248 | { 249 | MID_PP_Compose->SetTextureParameterValue(Name, RT_ColorDepths[Index]); 250 | } 251 | else 252 | { 253 | MID_PP_Compose->SetTextureParameterValue(Name, RT_Black); 254 | } 255 | } 256 | 257 | if (PostProcessVolume) 258 | { 259 | PostProcessVolume->AddOrUpdateBlendable(MID_PP_Compose, PP_Compose_Weight_Debug); 260 | } 261 | } -------------------------------------------------------------------------------- /Source/OITDemo/DepthPeeling.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "GameFramework/Actor.h" 7 | #include "DepthPeeling.generated.h" 8 | 9 | class AStaticMeshActor; 10 | class APlayerCameraManager; 11 | class ASceneCapture2D; 12 | class APostProcessVolume; 13 | class UTextureRenderTarget2D; 14 | 15 | UCLASS() 16 | class OITDEMO_API ADepthPeeling : public AActor 17 | { 18 | GENERATED_BODY() 19 | 20 | public: 21 | // Sets default values for this actor's properties 22 | ADepthPeeling(); 23 | 24 | protected: 25 | // Called when the game starts or when spawned 26 | virtual void BeginPlay() override; 27 | 28 | public: 29 | // Called every frame 30 | virtual void Tick(float DeltaTime) override; 31 | 32 | UPROPERTY(EditAnywhere, BlueprintReadOnly) 33 | TArray OITActors; 34 | 35 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 36 | UMaterial* M_Actor_ColorDepth; 37 | 38 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 39 | UMaterialInstanceDynamic* MID_Actor_ColorDepth; 40 | 41 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 42 | APlayerCameraManager* PlayerCameraManager; 43 | 44 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 45 | ASceneCapture2D* SceneCapture2D; 46 | 47 | UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (UIMin = '1', UIMax = '5')) 48 | int32 PeelingNum = 5; 49 | 50 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 51 | TArray RT_ColorDepths; 52 | 53 | UPROPERTY(VisibleAnywhere) 54 | UMaterial* M_PP_Compose; 55 | 56 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 57 | UMaterialInstanceDynamic* MID_PP_Compose; 58 | 59 | UPROPERTY(VisibleAnywhere, BlueprintReadOnly) 60 | APostProcessVolume* PostProcessVolume; 61 | 62 | UPROPERTY(EditAnywhere, BlueprintReadOnly) 63 | int32 PP_Compose_Weight_Debug = 1; 64 | }; 65 | -------------------------------------------------------------------------------- /Source/OITDemo/OITDemo.Build.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class OITDemo : ModuleRules 6 | { 7 | public OITDemo(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | 11 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RenderCore", "RHI" }); 12 | 13 | PrivateDependencyModuleNames.AddRange(new string[] { }); 14 | 15 | // Uncomment if you are using Slate UI 16 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 17 | 18 | // Uncomment if you are using online features 19 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 20 | 21 | // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/OITDemo/OITDemo.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "OITDemo.h" 4 | #include "Modules/ModuleManager.h" 5 | #include "Misc/Paths.h" 6 | #include "ShaderCore.h" 7 | 8 | void FGameModule::StartupModule() 9 | { 10 | FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders")); 11 | AddShaderSourceDirectoryMapping("/Project", ShaderDirectory); 12 | } 13 | 14 | void FGameModule::ShutdownModule() 15 | { 16 | ResetAllShaderSourceDirectoryMappings(); 17 | } 18 | 19 | IMPLEMENT_PRIMARY_GAME_MODULE(FGameModule, OITDemo, "OITDemo"); 20 | -------------------------------------------------------------------------------- /Source/OITDemo/OITDemo.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "Modules/ModuleManager.h" 7 | 8 | class FGameModule : public IModuleInterface 9 | { 10 | public: 11 | virtual void StartupModule() override; 12 | virtual void ShutdownModule() override; 13 | virtual bool IsGameModule() const override 14 | { 15 | return true; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /Source/OITDemoEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class OITDemoEditorTarget : TargetRules 7 | { 8 | public OITDemoEditorTarget(TargetInfo Target) : base(Target) 9 | { 10 | Type = TargetType.Editor; 11 | DefaultBuildSettings = BuildSettingsVersion.V2; 12 | 13 | ExtraModuleNames.AddRange( new string[] { "OITDemo" } ); 14 | } 15 | } 16 | --------------------------------------------------------------------------------