-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup and README update for first public release
- Loading branch information
Showing
9 changed files
with
142 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
testing/** | ||
!testing/* | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
# Blender Datasmith addon | ||
# Blender Datasmith Export | ||
|
||
This addon lets you export your blender scene to UE4 using the Datasmith | ||
format. | ||
Export your Blender scene to UE4 using the Datasmith format. | ||
|
||
You can see a brief overview of how it works here: | ||
It aims to export all the Datasmith format supports. For now it exports: | ||
|
||
* __Meshes__ with normals, vertex colors and UV coordinates. | ||
* __Hierarchy__ is exported keeping meshes references, transforms, parents and | ||
per-instance material overrides from blender. | ||
* __Textures and materials__ are exported using data from the shader graphs. | ||
Materials are closely approximated and a good amount of nodes are supported | ||
(math, mix, fresnel, vertex color and others) | ||
* __Cameras__ are exported trying to match Blender data, keeping focus | ||
distance, focal length, and aperture | ||
* __Lights__ are exported, keeping their type, power, color and size data. | ||
|
||
Check out an overview of a previous version here: | ||
https://youtu.be/bUUDqerdqAc | ||
|
||
The plugin is currently in preview status, you can try it by [getting the | ||
testing source build](https://github.com/0xafbf/blender-datasmith-export/archive/master.zip) | ||
and install from the blender addons preferences pane. | ||
## Sample: | ||
__Blender Eevee:__ | ||
![Blender Eevee render](docs/blender.jpg) | ||
__UE4 using Datasmith:__ | ||
![UE4 render](docs/unreal.jpg) | ||
|
||
This result relies on the **DatasmithBlenderContent**, which is a UE4 Plugin | ||
that improves material import compatibility. Consider supporting the project by | ||
purchasing it from the Epic Store or Gumroad (more info coming soon) | ||
|
||
This result is in a custom UE4 build, which fixes some issues of the UE4 | ||
importer. If you are technical to compile the engine, you can check the fork | ||
[here][ue4 fork]. Hopefully we can get to integrate our fixes into the main | ||
branch. | ||
[ue4 fork]: https://github.com/0xafbf/UnrealEngine/tree/master | ||
|
||
Now [__Download the latest version__][download_link] and install from the | ||
Blender addons preferences pane. | ||
|
||
[download_link]: https://github.com/0xafbf/blender-datasmith-export/archive/master.zip | ||
|
||
If you want to support the project, also consider supporting via [Patreon], | ||
even if it is a little it adds up. | ||
|
||
[patreon]: https://www.patreon.com/0xafbf | ||
|
||
This is a work in progress, if you want to contribute to improve it, feel free | ||
to submit pull requests or support me on Patreon: | ||
https://www.patreon.com/0xafbf | ||
Please please, [join the project Discord][join_discord] and share your results! | ||
I want to see what you make and I am open to any feedback you have. | ||
|
||
This is an unofficial exporter. If you would like to get in touch, please [join the project Discord](https://discord.gg/h2GHqMq) | ||
[join_discord]: https://discord.gg/h2GHqMq | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Testing tools | ||
In this folder there is a python script that runs the export command, with some | ||
extra steps for testing, and a powershell script that runs the command on | ||
different test files. you can use these as sample scripts for your convenience. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# build all files | ||
|
||
# & blender -b archiviz/archiviz.blend -P test_datasmith_export.py | ||
# & blender -b pabellon_barcelona/pavillon_barcelone_v1_2.blend -P test_datasmith_export.py | ||
# & blender -b classroom/classroom.blend -P test_datasmith_export.py | ||
& blender -b $PSScriptRoot/the_junk_shop/the_junk_shop.blend -P $PSScriptRoot/test_datasmith_export.py | ||
# & blender -b barbershop/barbershop_interior_cpu.blend -P test_datasmith_export.py | ||
|
||
# & blender -b bmw27GE\BMW27GE.blend -P test_datasmith_export.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# | ||
# | ||
# datasmith export test suite | ||
# run this file with the following command: | ||
# blender -b sample_file.blend -P test_datasmith_export.py | ||
|
||
import bpy.ops | ||
import bpy | ||
import os | ||
import logging | ||
import time | ||
import shutil | ||
logging_level = logging.INFO # WARNING, INFO, DEBUG | ||
# logging_level = logging.DEBUG # WARNING, INFO, DEBUG | ||
|
||
logging.basicConfig( | ||
level=logging_level, | ||
# format='%(asctime)s.%(msecs)03d %(name)-12s %(levelname)-8s %(message)s', | ||
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S' | ||
) | ||
log = logging.getLogger() | ||
|
||
clean_path = os.path.normpath(bpy.data.filepath) | ||
|
||
base_dir, file_name = os.path.split(clean_path) | ||
name, ext = os.path.splitext(file_name) | ||
target_path = os.path.join(base_dir, name + ".udatasmith") | ||
|
||
|
||
log.info("basedir %s", base_dir) | ||
use_diff = True | ||
backup_path = None | ||
if use_diff and os.path.isfile(target_path): | ||
log.info("backing up previous test") | ||
last_modification_time = os.path.getmtime(target_path) | ||
time_str = time.strftime('%Y%m%d_%H%M%S', time.localtime(last_modification_time)) | ||
backup_path = os.path.join(base_dir, "%s_%s.udatasmith" % (name, time_str)) | ||
log.debug("last modification was:%s", backup_path) | ||
shutil.copy(target_path, backup_path) | ||
|
||
log.info("Starting automated export") | ||
|
||
custom_args = {} | ||
custom_args["experimental_tex_mode"] = True | ||
custom_args["apply_modifiers"] = True | ||
|
||
|
||
bpy.ops.export_scene.datasmith(filepath=target_path, **custom_args) | ||
log.info("Ended automated export") | ||
|
||
# right now this is not so useful as the export is non deterministic | ||
# i guess it is because the usage of dictionaries | ||
|
||
if backup_path: | ||
log.info("writing diff file") | ||
import difflib | ||
|
||
with open(backup_path) as ff: | ||
from_lines = ff.readlines() | ||
with open(target_path) as tf: | ||
to_lines = tf.readlines() | ||
|
||
diff = difflib.unified_diff(from_lines, to_lines, backup_path, target_path) | ||
|
||
new_modification_time = os.path.getmtime(target_path) | ||
new_time_str = time.strftime('%Y%m%d_%H%M%S', time.localtime(new_modification_time)) | ||
diff_path = os.path.join(base_dir, "export_diff_%s.diff" % new_time_str) | ||
with open(diff_path, 'w') as diff_file: | ||
diff_file.writelines(diff) | ||
static_diff_path = os.path.join(base_dir, "export_diff.diff") | ||
shutil.copy(diff_path, static_diff_path) | ||
|
||
|