BlueRose
文章97
标签28
分类7
MultiDraw Document

MultiDraw Document

Introduction

This plugin uses UnrealEngine’s MeshDraw framework to achieve a multi-Pass effect looks like Unity’s, with no post-processing required to achieve strokes and cutoff.

Notice:Because UE5.4 changed the marking of UStaticMeshComponent’s virtual function GetUsedMaterials to final, it caused the plugin not to work properly. In order to avoid the crash problem, the functions of OutlineStaticMeshComponent, MultiDrawStaticMeshComponent are deactivated. It can be solved temporarily by adding another StaticMeshComponent and giving it Outline materials.

MultiDraw UE5.0 ExampleProject
MultiDraw UE5.1~5.3 ExampleProject
MultiDraw UE5.4 ExampleProject
MultiDraw UE5.5 ExampleProject
Usage:Download this project,and put MultiDraw plugin into plugins folder.
Notice:This project only UE5.0 and higher can run.

中文文档

Update Log

2024.5.1

  1. Updated UE5.4 version, deactivated OutlineStaticMeshComponent, MultiDrawStaticMeshComponent to avoid crashes due to engine source code changes.

2023.8.1

  1. Add ProceduralMeshComponent and DynamicMeshComponent MultiDraw version.

2023.7.28

  1. Update CurveWidthControlOutline.
  2. Add ProceduralMeshComponent and DynamicMeshComponent Outline version.

2023.3.29

  1. MultiDraw can control drawing according to the specified material id.

2022.12.19

  1. Update UE5.1 version.
  2. Support UE5.1 OverlayMaterial.
  3. Outline and MultiDraw now support Translucent material.

2022.10.30

  1. Add real-time material change function.

QuickStart

Outline Example:

  1. Create a new Actor Blueprint class and attach a OutlineComponent.
  2. Config OutlineComponent’s Mesh and Material.
  3. Create Outline Material and push in OutlinePassMaterialSet.
  4. Put actor in current scene.

MultiPass Example:

  1. Create a new Actor Blueprint class and attach a MultiDrawComponent.
  2. Config MultiDrawComponent’s Mesh and Material.
  3. Put the materials and parameters to be drawn into the PerPassDrawSettingses as required.
  4. Set the material’s PixelOffset as required to allow the material to be rendered in the desired order.
  5. Put actor in current scene.

Cutoff Example:

  1. Enter Simulation mode.
  2. Rotate Plant mesh.

Reference

OutlineComponent

Component name is OutlineSkeletalMeshComponent and OutlineStaticMeshComponent.Outline materials are in one-to-one mode,This means that the Material Element Slot Index in the Mesh is the same as in the OutlinePassMaterialSet.If you don’t want to draw, you just need to set the corresponding material in the OutlinePassMaterialSet to empty.

Option:

  • CullingMode:all Outline materials’s CullingMode.Have FrontCulling,BackCulling,Double Side three options.
  • bCastShadow:all Outline materials’s CastShadow.It’s mean whether shadows can be cast on other mesh.
  • OutlinePassMaterialSet:Specify the array of Outline materials.

MultiDrawComponent

Component name is MultiDrawSkeletalMeshComponent and MultiDrawStaticMeshComponent.Materials are in one-to-many mode,The specified materials will be rendered per material slot.But because of depth culling,it is necessary to use depth offsets to control rendering order.

Option:

  • CullingMode:Materials’s CullingMode.Have FrontCulling,BackCulling,Double Side three options.
  • bCastShadow:Materials’s CastShadow.It’s mean whether shadows can be cast on other mesh.
  • bDraw:Control whether need rendering.
  • MaterialInterface:Specify the material to be used for rendering.

Character Class

For your convenience, this plugin implements the ThirdPersonChracter class that replaces the Mesh component: AOutlineCharacter and MultiDrawCharacter.

The code is as follows:

class AOutlineCharacter : public ACharacter
{
    GENERATED_BODY()
public:
    AOutlineCharacter(const FObjectInitializer& ObjectInitializer);
};

AOutlineCharacter::AOutlineCharacter(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer.SetDefaultSubobjectClass<UOutlineSkeletalMeshComponent>(ACharacter::MeshComponentName))
{}

Outline Material Instructions

This plug-in provides three outline materials.

  • ExampleContent\Materials\Outline\M_FixedOffsetOutline:Outline material with fixed WorldPositionOffset,for demonstration purposes only.
  • ExampleContent\Materials\Outline\M_ViewFixOffsetOutline:Adjusts the material of the Outline width according to the camera distance. At closer distances, however, the outline becomes very thin.
  • ExampleContent\Materials\Outline\M_PerfectionViewFixOffsetOutline:Fix the material in question above.
  • ExampleContent\Materials\Outline\M_CurveControlOutline.uasset:Use curve control outline width.

If you are not satisfied with the control effect, you can modify the curve to adjust the effect.

  • The R channel of the curve is used to control the effect of the distance between the model and the camera on the outline width.
  • The G channel of the curve is used to control the effect of the camera FOV on the outline width.

The component does not restrict the material type, so you can also use other ShaderModel’s materials to create the effect you want.

Runtime Material Change

Get component and call function.For SkeletalMesh make sure that Use for SkeletalMesh and Use for cloth are checked for the material.

Other Platform Effect

Only test in Editor.