Skip to content

The Megascans LiveLink for UE4 lets you easily integrate Megascans into your pipeline by providing out-of-the-box material setups, automatic imports, custom blend materials, and more.

Notifications You must be signed in to change notification settings

ShadowFactory/Megascans-UE4LiveLink

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Megascans - Unreal Engine LiveLink

The Megascans LiveLink for Unreal Engine 4 is an open-source, python-written integration for Megascans inside unreal engine 4. The plugin is written with UnrealEnginePython and is available for UE4 versions 4.15 and above.

UnrealEnginePython is developed by Roberto De Ioris (20Tab S.r.l, 20tab.com) with sponsorship from Accademia Italiana Videogiochi (aiv01.it), Kite & Lightning (kiteandlightning.la), GOODTH.INC (goodthinc.com) and QUIXEL AB (Quixel.se).

Windows binaries are currently provided, and OSX and Linux coming soon.

If you're facing issues and this documentation isn't helping you please let us know : [email protected] . We'll help you get things fixed ASAP.

Installing the LiveLink with Megascans Bridge

Megascans is an ecosystem consisting of a huge scan library and a set of tools to help you work with that library, and Bridge is one of those tools. Megascans Bridge lets you Instantly access the entire Megascans library, batch export straight to your game engine or 3D software, and unleash your imagination without having to waste time on importing assets.

Before we keep on with the instructions, keep in mind that we have a series of small videos that help you get up to speed with the LiveLink : LiveLink Quick Video Guide

How to install the LiveLink with Bridge :

One minute video guide (Recommended) : Video Installation Tutorial

Manual instructions :

  • go to https://megascans.se/apps/bridge and download it.

  • Click on the export icon of any asset in your downloaded library, this will open the export options pop-up. set the "Application" drop-down to "Unreal Engine" and click on "Download Plugin".

  • Once the plugin is downloaded you'll need to select which version of unreal you want to install the LiveLink on with the "Engine Version" drop-down. If your using an official unreal engine version just select which version (4.18, 4.19, 4.0, etc...) you want to install the LiveLink on. If on the other hand you're trying to install the LiveLink on a custom unreal engine build then pick up the "Custom Build" option in that drop-down.

  • Now set the "Engine Version Path" option to where your engine's plugins are installed, like this for instance: C:\Program Files\Epic Games\UE_4.20\Engine\Plugins. The path should basically be where your engine's plugins are installed.

  • As soon as you've picked the version and the path in the previous step, Bridge will notify you that it's currently installing the plugin, and once it's done it will tell you in a pop-up.

  • Once the installation is done, simply start or restart unreal and click on the green "Export" button in the export dialog of any asset you want to export in Bridge in Bridge.

    • Optional for building the plugin on an OS other than Windows : If you're looking into building the Megascans LiveLink plugin on a non-windows platform, you'll need to build PySide2 with a python installation on your system ( pip install PySide2), then copy the PySide2 folder from the python/lib/site-packages folder to the UnrealEnginePython/Binaries/Win64 folder. You can confirm to replace if it's asking you to remove an existing installation.

This is what your installation settings for unreal engine 4.19 would look like :

This is what your installation settings for a custom build would look like :

The LiveLink currently relies on a hard-coded port to receive data from Megascans Bridge : 13428. It can only work with one engine open on your system at a time.

 -

User Interface and Functionalities

This window is expected to receive many updates during the next few months, as we keep adding more features to give you the best Unreal Engine integration possible. With that said, let’s dig in:

The top-most bar has a close and minimize button. By clicking the Megascans icon you will access a context menu including an always on top toggle, access to help documentation, a one-click jump to megascans.se, and more information about the plugin.

The Blend Material Workflow

Quick Video Guide - Blend Materials Workflow

The LiveLink comes with a really neat blend-based master material that has support for up to three different texture sets, world-aligned blend, fuzzy shading, per-layer attribute editing and much, much more.

To create a the assets you wanblend material simply select 2 or 3 material instances of t to import in the content browser, then click “Create Material Blend”:

In this specific screenshot we’ve selected three assets in the content browser: the first selection is the moss, which will be the topmost layer, second is the forest ground, which is the middle layer, and third is a generic mud soil, which is the bottom layer.

You can control the middle and bottom layers with the R and G vertex channels by vertex painting on your mesh, and the topmost layer can be controlled with the World-Aligned Blend feature that you can enable in your material instance.

You can use the B vertex channel to paint water puddles.

This workflow may seem a little daunting at first, but with a little experience you’ll find yourself creating and modifying these blend materials really fast. You can also use your own custom blend master material, just make sure all texture parameters inside the master material use the following naming conventions:

  • Base Albedo, Base Normal, Base Roughness and so on for the base layer.

  • R Albedo, R Normal, R Roughness and so on for the Red vertex channel.

  • G Albedo, G Normal, G Roughness and so on for the Green vertex channel.

  • B Albedo, B Normal, B Roughness and so on for the Blue vertex channel.

  • A Albedo, A Normal, A Roughness and so on for the Alpha vertex channel.

This is how a base albedo is set up in the default master material, for instance:

If you follow this naming convention the LiveLink will auto-detect all textures that need to be connected and do its job accordingly.

Using Custom Master Materials

Quick Video Guide - Custom Master Materials Workflow

The LiveLink comes with all the master materials needed to use the library, but using your own master materials is also possible and very easy to set up.

After following the naming conventions discussed in the previous section, save your master material and click on the arrow icon on the LiveLink window while your master material is selected in the content browser. It will now be used as the default master material for a specific category.

You can change the categories by clicking the “Surface” dropdown button at the top-left of the LiveLink window, there you have a list of all the different asset types, each one having their own master material that you can change.

Working with Foliage and Scatter assets

Quick Video Guide - Scatter and Foliage Workflow

One of the aspects of the LiveLink we’ve worked on the most was the scatter/foliage system. Unreal already has a robust foliage editor and with the Megascans LiveLink you can scatter your assets in a click or two.

If you want to automatically populate your foliage editor’s asset list with the latest imported assets, check the “Auto-Populate Foliage Painter” checkbox in the LiveLink window and then click on export in Bridge to immediately start painting inside UE4.

 -

Extending the LiveLink with Python Scripting

Having the plugin work 100% with python comes with a lot of advantages if you're looking into extending it. First, the entire source code is completely open, and you can find all the LiveLink script files in the LiveLink folder, where they all have the .py format. UnrealEnginePython also has it's code open-source for you to modify as you want.

The LiveLink gives you access to a set of useful commands, like this one to import a mesh for instance :

ms_import_mesh('C:/Meshes/MyMesh.fbx', '/Game/Mesh_Folder')

Or this one to apply a texture map to a material instance :

ms_apply_tex2d_to_inst(inst_uobject, '/Game/Textures/bark_Albedo', 'Albedo')

You could push this a lot further and write a relatively small file that automatically imports and sets up your assets :

# We start off by initializing the unreal_engine module, then we execute the Megascans LiveLink's ms_main.
import unreal_engine as ue
ue.exec('ms_main.py')
 
folderpath_ = "/Game/Wood_Tree"
 
# QFileDialog is a PySide2.QtGui class. We use it to open a file browser for the texture maps and another one for the mesh files.
Textures_Path = QFileDialog.getOpenFileNames(None, str("Select your texture maps"), "", str("Image Files (*.png *.jpg)"))
Mesh_Path = QFileDialog.getOpenFileNames(None, str("Select your geometry files"), "", str("Image Files (*.fbx *.obj)"))

texture_paths = Textures_Path[0]
meshes_ = Mesh_Path[0]

# ms_import_mesh is a ms_main function that imports a given mesh to the input path folderpath_.
for mesh_ in meshes_:
    ms_import_mesh(mesh_, folderpath_)


# ms_import_texture_list imports an array of textures to the input path folderpath_.
ms_import_texture_list(texture_paths, folderpath_)

# Now we create our material instance, which is based on the material Basic_Master.
parent_mat = ue.load_object(Material, "/Game/Basic_Master")
ms_create_material_instance(parent_mat, "Wood_Tree_inst", folderpath_)

# Then we load it.
inst_uobj = ue.load_object(MaterialInstance, folderpath_ + "/" + "Wood_Tree_inst")

# This will return a list of all the meshes available in the folderpath_ folder.
static_mesh_array = [[item, (folderpath_ + "/" + item.get_name())] for item in ue.get_assets(folderpath_) if item.is_a(StaticMesh)]

# Assigning a material instance to our geometry is done by calling ms_main's ms_inst_2_mesh function.
if mesh_path != None:
    ms_inst_2_mesh(inst_uobj, static_mesh_array)

# Once you have our material instance applied to the geometry, we can start applying the textures from texture_paths to the material instance.
for texture in [item for item in ue.get_assets(folderpath_) if item.is_a(Texture2D)]:
    try:
        text_input = ms_get_map(texture.get_name())
        text_input = "metallic" if text_input.lower() == "metalness" else text_input
        # This ms_main function takes the material instance's UObject, the texture's name and an str of the map type (albedo, normal, etc...).
        ms_apply_tex2d_to_inst(inst_uobj, texture.get_path_name(), text_input)
    except:
        pass
 
# Finally we sync the content browser to the folderpath_'s content.
ue.sync_browser_to_assets(ue.get_assets(folderpath_))

That file should give you an idea on how to interact with the Megascans LiveLink and UnrealEnginePython in general. If you have any questions feel free to check the UnrealEnginePython GitHub page or send a, email to adnan at quixel.se !

About

The Megascans LiveLink for UE4 lets you easily integrate Megascans into your pipeline by providing out-of-the-box material setups, automatic imports, custom blend materials, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 51.8%
  • Python 32.4%
  • C 8.9%
  • HTML 3.7%
  • JavaScript 2.1%
  • CSS 0.6%
  • Other 0.5%