# Unreal ```eval_rst .. _unreal: ``` ## Version and OMS Player Install Unreal Engine version 4.25 is supported for OMS playback. To Install the HoloStream UE4 plugin locate the HoloStream UE4 Plugin 2020.4.zip file in the Tools folder of your HoloSuite 2020.4 file directory. Drag and drop the HoloStreamPlugin folder into your Unreal Engine Plugins folder. By default, this should be: “C:\Program Files\Epic Games\UE_4.25\Engine\Plugins”. See the [Plugins page on the Unreal Engine Documentation](https://docs.unrealengine.com/en-US/ProductionPipelines/Plugins/index.html) (external link) for more information on installing plugins in Unreal Engine 4. To finish installing the plugin, create a new Ue4 project. From the main Unreal Engine interface, click on Settings in the top menu, and select Plugins. In the Plugin editor, a HoloStream Player item will be visible. Check 'Enabled' and click New Plugin. When Unreal opens again, you'll be ready to start configuring the OMS Player. ## HoloStream Plugin Contents ```eval_rst .. _holostream-plugin-contents: ``` The HoloStream Player Plugin provides Blueprints and Material nodes for OMS Playback. OMS Playback uses the Ue4 [Media Player](https://docs.unrealengine.com/en-US/WorkingWithMedia/MediaFramework/index.html) (External Link) for video playback and regular Ue4 materials with a custom Material Function for rendering. To set up an OMS Player, the OMSMeshActor Class, properly configured Media Players, and a material using the Arcturus OMS Material function must all be configured. ### OMSMeshActor Class ```eval_rst .. _oms-mesh-actor-class: ``` The OMSMeshActor class is used to create OMS players in your scene. It drives necessary components of the Arcturus OMS Material function and can be configured to specify an OMS file and enable or disable Retargeting. Used in combination with an **Arcturus OMS** Material Function this class drives OMS playback. The OMSMeshActor class contains the following properties: ### Default: - **Media Player**: Specify a Media Player with a corresponding to the Media Texture. See [Media Player configuration](media-player-configuration) for more information. ### OMS Settings: - **OMS**: Specify an OMS file for playback. - **Media Player Material**: Specify a Material for the Actor’s Media Player. See [Media player configuration](media-player-configuration) for more information. - **Mesh material**: Specify a Material for OMS Playback. This material should include an [ArcturusOms](arcturus-oms) Material Function for proper playback. ### Retargeting: - **Retarget Enabled**: Enable Retargeting. See [Retargeting Configuration](retargeting-configuration) For more information. - **Retarget Skeletal Mesh**: Specify a Skeletal Mesh for Retargeting. See [Retargeting Configuration](retargeting-configuration) For more information. In addition to these Properties, an OMS Mesh Actor’s Event Graph must be configured to drive a corresponding Media Player using the BeginPlay event. To implement this functionality, add an **Open Source** Blueprint Node and connect the BeginPlay event to the Execution Pin. ### On the Open Source node: - The **Target** should be set with a **Get Media Player** node configured with the same Media Player assigned in this class’s Properties. - The **Media Source** property should be configured with the Mp4 file corresponding to this OMS. Configured correctly, your OMSMeshActor should drive the **Arcturus OMS Material** function in an assigned Material for proper OMS Playback. ### Arcturus OMS Material Function ```eval_rst .. _arcturus-oms: ``` The Arcturus OMS Material function is used to animate and texture OMS files for playback. Used in combination with an **OMSMeshActor** Class this Material function drives OMS playback. The **ArcturusOMS** node has three Output Pins: - **Texture**: The Color texture sampled from the Media Player assigned to the object’s OMSMeshActor class. - **Normals**: The Mesh Normals produced from SSDR deformation. - **World Position Offset:** The World Position Offset required to deform the mesh for playback. For a simple OMS Player, these pins should be connected to the Emissive (or base) color, Normal, and World Position Offset outputs, respectively. In your Custom Materials, apply additional nodes as needed between the ArcturusOMS and output nodes. ### Load OMSFromPath blueprint function The LoadOMSFromPath node loads an OMS file from the specified path. This Node is not necessary for standard OMS Player workflows. ### HoloStream Player Class Not Implemented ### OMSMedia Player Not Implemented ### OMS Media Sound Not Implemented ## Configuring a Media Player for OMS Playback ```eval_rst .. _media-player-configuration: ``` Each OMS player requires Media Player assets and a media player material in addition to the Mesh Material and OMSMeshActor class described in the [HoloStream Plugin Contents](holostream-plugin-contents) section. Media Player requirements are as follows: - One **Media Player** configured to control Playback. Enable Loop and Play On Open. - One **Media Texture**. Configure the Media Player property to select the corresponding Media Player you created. - One **Material** to shade the Media Player playback. This Material should be configured with the Unlit shading mode, and contain one Texture Sample node connected to the Emissive Color output pin. In the Texture Sample node, set the Sampler Type to External and the Texture to the Media Texture you created. When this configuration is complete, assign the Material and Media Player to the corresponding properties and nodes in your [OMSMeshActor](oms-mesh-actor-class). ### Retargeting Configuration ```eval_rst .. _retargeting-configuration: ``` Retargeting allows real time animation during playback of an OMS file containing rigging data. To enable retargeting, configure a Skeletal Mesh, Skeleton, and Animation Blueprint. The components of Retargeting are as follows: - **SkeletalMesh**: The SkeletalMesh component can be created automatically from any OMS containing rigging data. To create an OMS Skeletal mesh, right click on an OMS file in the Content Browser and choose “Create Retarget SkeletalMesh” from the OMSActions section. - **Skeleton**: The Skeleton component can be created via right clicking on the SkeletalMesh component and choosing “Create Skeleton” from the “Skeleton” category. - **Retargeting Blueprint**: Retargeting uses an Animation Blueprint to drive animation during playback. To create a Retargeting Blueprint, create a new Animation Blueprint. After configuring the Animation Blueprint as necessary for your project, add an instance of the blueprint to your scene and configure the “Retarget Skeletal Mesh Actor” property on your corresponding OMSMeshActor to point to the Animation Actor. During playback, the Blueprint logic specified by the Animation Blueprint will be applied to the OMS Player. For an example of Head Retargeting, follow the [OMS Player Setup example](oms-player-setup-example). ## OMS Player Setup example ```eval_rst .. _oms-player-setup-example: ``` The following is a walkthrough of a typical OMS Player setup in UE4: With the HoloStream Player for Unreal successfully installed to UE4, you're ready to create an OMS player to use in your project. The HoloStream OMS Player requires a subfolder named 'Movies' for all .mp4 files. Create a Movies folder and add your MP4 file(s). Next, add your OMS file(s) to the Content folder. ```eval_rst .. image:: assets/unreal-folderstructure.png :width: 1200 ```
OMS Player Content in Windows Explorer
In Unreal, Navigate inside the Movies folder, click Import, and add your MP4 files from your file directory location. Similarly, navigate to the main Content folder, click Import, and add your OMS file from your file directory.The operations for setting up an OMS Player in Unreal is split amongst numerous actors, blueprints, and objects, so you will want to keep these contained. We recommend creating a new folder for each OMS Player in your project. There are several components required to set up OMS Playback in UE4. ```eval_rst .. image:: assets/unreal-contentbrowser1.PNG :width: 1200 ``` ```eval_rst .. image:: assets/unreal-contentbrowser2.PNG :width: 1200 ```OMS Player Content in the Content Browser
- **An OMSMeshActor BluePrint**: This Blueprint drives the core of the OMS playback. It reads your prepared Materials and Media Player, and serves as the OMS player in your project’s map. - **An OMS Mesh Material**: You will need to create a material that uses the ‘ArcturusOMS’ node for the material’s texture information and World Position Offset. This is used as the Mesh Material parameter in the OMSMeshActor Blueprint. - **An OMS Texture Material**: You will need to create a material that uses the ‘Texture Sample’ node to playback the information provided by the Media Player Asset in order to apply the textures to your OMS’s meshes. - **An Media Player Asset**: This asset takes the provided MP4 textures and allows for playback of the texture and mesh animation. - **An Media Texture Asset**: This asset provides the Media Player with the mp4 required to provide texture and OMS playback. To set up an OMS player, create the following: ```eval_rst .. image:: assets/unrealrequiredelements.PNG :width: 1200 ``` 1. **A Media Player**: - Double click on the object and ensure that 'Play on Open' and 'Loop' are enabled. 2. **A Media Texture**: - Double click on the object and set the Media Player to the new MediaPlayer object that you just created. 3. **Two new Materials**: - One of these is a mesh material, and the other is a media texture. For the purpose of this doc, we’ll assume you’ve named these OMSMeshMaterial and OMSMediaTexture. The OMSMeshMaterial must be edited in the Material Editor. Add the ArcturusOMS node. From the new ArcturusOMS node: ```eval_rst .. image:: assets/omsmeshmaterialnode.PNG :width: 1200 ``` 1. Connect the world position offset to the material node’s World Position Offset input 2. Connect the Normals output into the material’s normal input. 3. Next, determine whether your project will have a lit or unlit map. - If you plan on having real time lighting, connect the Texture output to the material node's Base Color and set the shading model to Default Lit. - If unlit, connect the Texture output to the material node's Emissive Color and set the Shading Model to Unlit. The OMSTextureMaterial must be edited in the Material Editor. Add a Texture Sample node. From the Texture Sample node: ```eval_rst .. image:: assets/omstexturematerialnode.PNG :width: 1200 ``` 1. Connect the RGBA output into the Emissive input of the OMSTextureMaterial 2. In the Texture Sample details, this node’s Texture should be set to The OMSMediaTexture you just configured. To drive playback, create a Blueprint using the OMSMeshActor class from “all classes”. This is what you will configure to drive your OMS playback. It takes the assorted components required for texture and mesh playback and lets you determine the volumetric clip you intend to play. ```eval_rst .. image:: assets/mediaplayersetupinblueprint.PNG :width: 2000 ``` Three Nodes are necessary for standard OMS playback: 1. **A Media Player Variable**: Setup of the Media Player Variable requires you to: - Create a new variable in the Variables tab of the My BluePrint panel - Change the new variable’s Variable Type to Media Player - Update the Media Player Media Player parameter (in the Default tab) to the MediaPlayer object you created. - Drag the Media Player Variable into the graph from the Blueprint Panel as a Get. 2. **An Open Source Node**: Click on the output of the Media Player node and drag to an empty spot in the Event Graph. Search for ‘Open Source’ and create the node. In the newly created Open Source node, open the Media Source dropdown menu and select the MP4 file companion of the OMS you will be playing. 3. **An Event Node**: The Event BeginPlay node initiates the playback of your OMS on entering play mode or launching an application. The exec pin of the Event BeginPlay node should be connected to the plug into the exec pin of the Open Source node. Select the OMSMeshActor component and update the Default and OMSSettings parameters in the component’s Details panel as follows: ```eval_rst .. image:: assets/UnrealOMSBlueprintsetup.PNG :width: 2000 ``` **Default:** - Media Player: Select the Media Player Object created for OMS playback **OMSSettings:** - OMS: Select the OMS clip you intend for playback - Media Player Material: Select the OMSTextureMaterial you created for your clip to generate the textures for OMS Playback. - Mesh Material: Select the OMSMeshMaterial you created to generate the mesh for your OMS Playback. **OMS Player in the level editor:** ```eval_rst .. image:: assets/unrealblueprintinleveleditor.PNG :width: 2000 ``` Drag the OMSMeshActor BluePrint from the Content Browser into Unreal’s Level Editor Viewport. Once in the Viewport, the mesh of the first frame of your OMS Clip will be visible without textures. To preview the OMS playback select ‘Play’ from the Viewport toolbar. Note: the Blueprint can be transformed as necessary using Translate, Rotate and Scale. ## Adding Head Retargeting To add head retargeting data to your OMS Player, complete the steps you would to set up a standard OMS Player and ensure it's playing correctly in the viewport. From your Content Browser, add your OMS file into your OMS Player folder. You will be generating skeletal information from the OMS file along with several other assets. It's best practice to keep all of these assets together. If you’ve transformed your OMS Player actor in any way, ensure that your animation blueprint has the transforms also applied to match the transforms of your OMS player Blueprint. ### Adding skeletal mesh and bones: ```eval_rst .. image:: assets/UnrealretargetingSkeletonassets.PNG :width: 2000 ``` OMS playback with head retargeting requires a skinned mesh and skeleton data to control your actor’s motions. These are generated from an OMS file containing embedded rigging data. To generate a new SkeletalMesh, right click on your OMS file and select Create Retarget SkeletalMesh. Next, right-click on the newly created SkeletalMesh and under Skeleton, click Create Skeleton. You should rename these appropriately, as both the mesh and skeleton assets require specific configurations. ### Retargeting Blueprint: Adding an Animation Blueprint is what enables head retargeting to lock onto a target object and control your actor’s head motion during playback. For example, you can add a Look At blueprint using the following steps: In your OMS_Player folder, right-click to create a new asset, and select the Animation Blueprint from the Animation dropdown menu. Open the newly created Animation Blueprint to expose the AnimGraph window. Here you will see an empty Output Pose as default. ```eval_rst .. image:: assets/unrealretargetinglookatnodeplacement.PNG :width: 2000 ``` In an empty space in the AnimGraph, right-click and create a Look At node and connect its output to the Result of the Output Pose. With the Look At node selected, update its Details as follows: - Update its Bone to Modify to ‘head’ - Change its Look at Axis values to 0.0, 0.0, 1.0 - Compile and Save the Animation Blueprint With the initial animation configurations made, you can drag your Animation Blueprint into your Level with the OMS_Mesh_Blueprint you created. It’s important you update the Animation Blueprint's position, rotation, and scale values to match your OMS_Mesh_Blueprint. Ensure that Retargeting Enable is selected in your OMS_Mesh_Blueprint’s Details panel. ```eval_rst .. image:: assets/unrealretargetingenableretargeting.PNG :width: 2000 ``` ### Adding a look at object Create an object to direct where your actor's head will look. Place a primitive object in the scene--like a sphere--and position it to where you would like your actor to look. Note that you will want to reduce the size of the object. In the Animation Blueprint, select the **Look At node** and in its Details panel, enable the **Look At Location** in the Target tab. ```eval_rst .. image:: assets/Unrealretargetinglookatnodeparams.PNG :width: 2000 ``` This will expose the **Look At parameters** in the AnimGraph. Next, create a variable to use as the look at location--name this ‘LookAtLocation’--and set its variable type to **Vector**. ```eval_rst .. image:: assets/unreallookattargetgetter.PNG :width: 2000 ``` Drag your LookAtLocation variable in the AnimGraph as a Get and connect it to the Look At Location input of the Look At node. Switch over to the Event Graph of the Animation Blueprint. Add the following assets and connections between the nodes: ```eval_rst .. image:: assets/unreallookateventgraph.PNG :width: 2000 ``` 1. Create a Get All Actors with Tag function; in the node’s Tag field, add LookAtTarget (you will add this tag to your primitive look at object as well) 2. Click on the Get All Actors with Tag Out Actors output and create a Get node 3. Click on the Get node’s output and create a Get Actor node 4. Drag the LookAtLocation variable into the Event Graph and make it a Set 5. Connect the GetActorLocation node’s Return Value output with the LookAtLocation variable’s Look at Location input 6. Connect the Get All Actors with Tag node’s Exec output to the LookAtLocation variable’s Exec input 7. Drag the existing Event Blueprint Update Animation node’s Exec output to the Get All Actors with Tag node’s Exec input 8. Compile and Save your Animation Blueprint Select your primitive ‘look at’ object that you added to your scene. In the object’s Details panel, navigate down to the Actor tab and add a Tag element. In the new field that is created below, add the ‘LookAtTarget’ tag that is shared with the Get All Actors with Tag node. ```eval_rst .. image:: assets/unreallookatmeshdetails.PNG :width: 1600 ``` You can hide your skeletal mesh in the viewport by assigning a custom material to it. In your OMS_Player folder, create a new material. Open the material, set the blending mode in its Details panel to Translucent, create a Constant node in the material editor, and connect it to the material’s Opacity channel. Back in your OMS_Player folder, open your skeletal mesh object and assign the translucent material to the skeletal mesh’s Material Slot.