diff options
author | Michael Kowalski <makowalski> | 2022-01-27 17:43:14 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2022-01-27 17:51:50 +0300 |
commit | c85c52f2ce478ab0e30c5e93fd5a5cb812db232f (patch) | |
tree | cb4f2e120cbcfa9a9ff65244d209d40868a5865e /source/blender/blenlib/intern/path_util.c | |
parent | d518550c46d7811ea98fb549cc29961621d66b07 (diff) |
USD Preview Surface material export.
Add `USD Preview Surface From Nodes` export option, to convert a
Principled BSDF material node network to an approximate USD Preview
Surface shader representation. If this option is disabled, the original
material export behavior is maintained, where viewport setting are saved
to the Preview Surface shader.
Also added the following options for texture export.
- `Export Textures`: If converting Preview Surface, export textures
referenced by shader nodes to a 'textures' directory which is a
sibling of the USD file.
- `Overwrite Textures`: Allow overwriting existing texture files when
exporting textures (this option is off by default).
- `Relative Texture Paths`: Make texture asset paths relative to the
USD.
The entry point for the new functionality is
`create_usd_preview_surface_material()`, called from
`USDAbstractWriter::ensure_usd_material()`. The material conversion
currently handles a small subset of Blender shading nodes,
`BSDF_DIFFUSE`, `BSDF_PRINCIPLED`, `TEX_IMAGE` and `UVMAP`.
Texture export is handled by copying texture files from their original
location to a `textures` folder in the same directory as the USD.
In-memory and packed textures are saved directly to the textures folder.
This patch is based, in part, on code in Tangent Animation's USD
exporter branch.
Reviewed By: sybren, HooglyBoogly
Differential Revision: https://developer.blender.org/D13647
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 64bde1193a6..250415c11f9 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1829,3 +1829,21 @@ void BLI_path_slash_native(char *path) BLI_str_replace_char(path + BLI_path_unc_prefix_len(path), ALTSEP, SEP); #endif } + +bool BLI_paths_equal(const char *p1, const char *p2) +{ + /* Normalize the paths so we can compare them. */ + char norm_p1[FILE_MAX]; + char norm_p2[FILE_MAX]; + + BLI_strncpy(norm_p1, p1, sizeof(norm_p1)); + BLI_strncpy(norm_p2, p2, sizeof(norm_p2)); + + BLI_path_slash_native(norm_p1); + BLI_path_slash_native(norm_p2); + + BLI_path_normalize(NULL, norm_p1); + BLI_path_normalize(NULL, norm_p2); + + return BLI_path_cmp(norm_p1, norm_p2) == 0; +} |