EpicGamesExt / BlenderTools

Blender addons that improve the game development workflow between Blender and Unreal.
https://epicgamesext.github.io/BlenderTools/
MIT License
2.83k stars 64 forks source link

Send to Unreal - Texture export fails with "Automatically add affixes" option #372

Closed Dprasni closed 2 years ago

Dprasni commented 2 years ago

I have noticed that when exporting ie. Pipeline send to unreal, the materials get transferred over however the textures do not, i am unsure if this is normal or not ?!

In blender its set up as a normal PBR texture (BSDF connected with external textures in the PBR channels), so i'm confused if this should or should not work ? I'm aware that procedural stuff wont work, that's a given, but simple texture with assigned UV could/should work. I couldn't find any documentation regarding texture exporting to unreal if this works or not, so if anyone could tell more on this topic i would be grateful

james-baber commented 2 years ago

The addon uses FBX to import your meshes, and if that mesh has an assigned material with a texture on either color and/or normal inputs on your principled shader FBX should import it. Provided you didn't turn off any of those import options in send to unreal https://epicgames.github.io/BlenderTools/send2ue/preferences/import.html#textures

Dprasni commented 2 years ago

This link covers importing in to Blender, i am trying to Export from Blender to Unreal through the Pipeline > Export > Send to Unreal Advanced and there is no option or mention of materials. No material option image

In blender the material is asigned to a object image

james-baber commented 2 years ago

This is the import settings for unreal. Send to Unreal does a export then an import. The settings for both of those are in the respective export import tabs https://epicgames.github.io/BlenderTools/send2ue/preferences/import.html#textures

Dprasni commented 2 years ago

After importing both the mesh and the material (which apperantly has 'import textures' set to true by default when importing materials) i must say that the material is blank when it gets imported in to unreal.

So in essence the textures do not get imported in to unreal for some reason, is this a bug or does do the nodes in blender have to be set up in a particular way ?

james-baber commented 2 years ago

Can you screen shot your material nodes and also ensure that the material is actually assigned to the geometry and not just in a slot. Also make sure that the texture path is valid on disk, ultimately that path to where the texture is on disk needs to be valid in order for the texture to get baked into the FBX.

We run a few tests on materials with textures. Check out this file. It might help serve as a reference. https://github.com/EpicGames/BlenderTools/blob/master/test/blends/static_meshes.blend

image

This cube comes in with its material and texture when using Send to Unreal. Let me know if that helps

Dprasni commented 2 years ago

This is my setup, basic node wrangler PBR setup image

This path happens/changes when i export with the addon and it "renames" textures with generic prefix, C:\Users\User\AppData\Local\Temp\Send2Unreal_4yajxq20\ (Otherwise the path is on D:_Blender_Assets\Textures),

But since that didnt really work i then decided to rename and put the textures on the D:_Blender_Assets\Textures\ and after that the Material got imported with assigned textures.

So i would conclude that renaming the material/textures through the addon /prefix kind of screws things up, hmmm.

Also small sidenote, from the 5 textures that make up the material only 3 got imported, so metallic and displacement did not get imported, on top of that, the roughness map got incorrectly assigned to metallic as seen in the picture image

james-baber commented 2 years ago

Ok so when using the default options it works correct? The issue arises when you enable the Affix option Automatically add affixes on export correct?

Also yes that is correct only color and normal come in correctly. For Materials the addon doesn't do anything other then import the FBX, which doesn't reliably translate anything other than color and normal input.

Currently the tool is meant to support Skeletal Mesh, Static Mesh and Animation workflows since unreal you cant create those in Unreal at the moment. I would do all your shader creation in unreal and use Blender as a means of assigning materials to vertex groups rather then to creating shaders.

james-baber commented 2 years ago

But circling back, the issue arises when using the Affix option correct?

Dprasni commented 2 years ago

Fore some reason i cant use 'create Prefix' anymore in blender addon, as i get a bunch of code errors and nothing happens.

If my file is normally set up, it does transfer over to unreal but the only issue is that from 5 textures that are assigned in blender, only 3 get imported (color,roughness,normal) except for displacement(which is assigned to the output instead of the BSDF node) and metallness, another thing is that the roughness texture gets automatically assigned to the 'Metallic' socket instead of 'Roughness' socket in unreal.

I also am unaware if there is the option to transfer over the Ambient occlusion texture/socket as that is a multiply setup in blender and the displacement texture that is not attached to the BSDF.

james-baber commented 2 years ago

Ok gotcha yea Ill need to take a look at the affix code, then. @zaha for visibilty.

As far as your missing/swapped texture inputs, like I said that is just how the FBX importer imports materials. Send to Unreal does not map any of blenders material nodes to unreal. So all you can rely on working is color and normal coming in at the moment. All other shader creation should be done in Unreal not Blender. The intent is that Blender should be used to do things that Unreal can't like modeling, skinning, rigging, animation etc.

james-baber commented 2 years ago

@Dprasni can you post the blend in the state where it is reproducing the error/unintended result when using the Affix option?

Dprasni commented 2 years ago

This is the error i get, image

And here is a stripped down file castle_ruins_assets_01_stripped.zip

Dprasni commented 2 years ago

Small sidenote, i use the Blender MS store latest version, if that is of any help

zaha commented 2 years ago

Hi everyone,

Finally had some time to have a look into the stripped down file and I noticed that the texture images are of type generated: image

There is no image file, neither packed into the blend file nor external, and that's why it says "File not found" in the error screenshot above. Not quite sure why, though, as @Dprasni stated he had external image files. Maybe this got messed up in the stripped down version? Can you provide an example with the texture files included in the zip as external files?

@james-baber Should images of type "Generated" be supported?

james-baber commented 2 years ago

Good point. Yea IMO I don't think it needs to. I think the user should save there images somewhere. I am not a super fan of forcing the tool to modify the blend file, but I realize we already have to do that in a few other places. But I think there would need to be a compelling argument for it.

@zaha FYI I refactored the affixes logic and test cases for the new release so about to create a PR and Ill add you to that review hopefully by end of week.

Dprasni commented 2 years ago

@Zaha Trying it out with a PBR texture seems to work now, except for one thing, using the Change affixes option it moves and renames my SOURCE texture files

Pre export image

Post export image

Looking back in blender PBR nodes, opening the file location i get the following address image

james-baber commented 2 years ago

Hey @Dprasni the new release should fix this issue with the affix texture unpacking https://github.com/EpicGames/BlenderTools/releases/tag/20220329235337

Re-open if this doesn't address your issue