Using xmlstarlet instead of SAT tools to retrieve information from sbs files

This commit is contained in:
Yann Kervran 2024-05-22 17:24:10 +02:00
parent 3e88552835
commit 2e57184009
8 changed files with 40 additions and 34 deletions

View file

@ -58,26 +58,14 @@ $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
# There is a png imageset for each preset of a base texture
# All png are stored in a png_1024 folder
@ mkdir -p $(PNG1024_DIR)
# Get all presets for the graph
@ $(eval PRESETLIST=`$(GETPRESET) --input $< | grep PRESET | sed -r 's/PRESET "(.*)"/\1/g'`)
# Get graph outputs list
@ declare -i graphcount=0 ;\
output_list="" ;\
for line in $$($(GETOUTPUT) $<) ; do \
if [ "$$line" = "GRAPH-URL" ] ;\
then ((graphcount++)) ;\
fi ;\
if [ $$graphcount -le 1 ] ;\
then if [ "$$line" != "OUTPUT" ] && [ "$$line" != "GRAPH-URL" ] && [ "$${line:0:4}" != "pkg:" ] ;\
then output_list+=" $${line}" ;\
fi ;\
else : ;\
fi ;\
done;\
echo " - Graph output_list :"$$output_list;\
@ outputs=$$(xmlstarlet sel -t -m "//content/graph[1]/graphOutputs/graphoutput/identifier" -o " " -v "@v" $<) ;\
echo " - Graph OUTPUTS : $$outputs";\
echo "Building 1024 png imageset(s) from presets of" $@ ;\
pngfiles="";\
for preset in $(PRESETLIST) ; do \
presetlist=$$(xmlstarlet sel -t -m "//content/graph[1]/sbspresets/sbspreset/label" -o " " -v "@v" $<);\
echo " presetlist: " $$presetlist ; \
for preset in $$presetlist ; do \
echo "- Preset" $$preset; \
material=$$(basename -s .sbsar $@);\
echo "material :"$$material;\
@ -87,7 +75,7 @@ $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
rm -Rf $(PNG512_DIR)/$$obsolete* ;\
rm -Rf $(PNG256_DIR)/$$obsolete* ;\
listitem="";\
for item in $$output_list;\
for item in $$outputs;\
do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\
listitem="$$listitem $$itemfull";\
done;\

View file

@ -2,6 +2,13 @@
This repository use [Git LFS](https://git-lfs.github.com/).
## Structure of sbs files
Your preset should be written without any space in their label.
For now, the script export only the first graph of each file.
## Organisation of a factory
### Configuration of the Makefile
@ -34,7 +41,7 @@ Theses are the places where the script will generate the final png files. It wil
#### Blender related
You have to define also a blender file directory where you will store the files used to generate previews of texturesets. They will be handled vie the `material_list.json` file indicated in the following section. They will have to be organized a special way to function, see later.
You have to define also a blender file directory where you will store the files used to generate previews of texturesets. They will be handled by the `material_list.json` file indicated in the following section. They will have to be organized a special way to function, see later.
The `BLENDEREXEC` variable is the path to the binary used to generate the preview. It must be compatible with the version used to save the renders files.
@ -52,10 +59,12 @@ The path to the json file used to manage all the metadata linked to texturesets
### Configuration of the json file
You have to fill this file to tell the system where it should export the result (the png textures and the blender file used for the preview render)
- `name` is the mundane texture name
- `description` is the description of the texture
- `type` is the subfolder name in `BLENDFILES_FOLDER` in the `local-config.mk` file the blender files used to generate the rpeviews are stored
- `type` is the subfolder name in `BLENDFILES_FOLDER` in the `local-config.mk` file the blender files used to generate the previews are stored
- `format` is the format of the texture, square or rectangular, it must be either "10,10" for normal 1024x1024 files, "9,10" for 512x1024 and "10,9" for 1024x512
- `destination_1024` is the folders names list where to copy the generated textrues files in 1024x1024, it can be left with an empty field if non-relevant.
- `destination_512` is the folders names list where to copy the generated textrues files in 512x512, it can be left with an empty field if non-relevant.
- `destination_256` is the folders names list where to copy the generated textrues files in 256x256, it can be left with an empty field if non-relevant.
- `destination_1024` is the folders names list where to copy the generated textures files in 1024x1024, it can be left with an empty field if non-relevant.
- `destination_512` is the folders names list where to copy the generated textures files in 512x512, it can be left with an empty field if non-relevant.
- `destination_256` is the folders names list where to copy the generated textures files in 256x256, it can be left with an empty field if non-relevant.

View file

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1f57ea0c1190f8fd9c4df24cf59c8322427e73181fe059915fe8a4f8cb2a06ab
size 11441

BIN
example/logo/yk.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
example/logo/yk.png~ Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -1,6 +1,15 @@
[
{
"name":"texture_factory_test_preset0",
"name":"texture_factory_test_Preset_numero_1",
"description":"Texture factory testing material",
"type":"bhonr",
"format":"10,10",
"destination_1024":["build/export/project_A"],
"destination_512":["build/export/project_B_512"],
"destination_256":[""]
},
{
"name":"texture_factory_test_Preset_numero_2",
"description":"Texture factory testing material",
"type":"bhonr",
"format":"10,10",

File diff suppressed because one or more lines are too long

View file

@ -3,10 +3,10 @@ export SBS_DIR=example/sbs
export SBSAR_DIR=build/sbsar
# executables used
export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "$(SBS_DIR)/utilities/"
export GETPRESET=sbsmutator info --print-presets
export GETOUTPUT=sbsmutator info --print-outputs
export SBSRENDER=sbsrender
# TODO:was used to add --includes "~/.local/share/Steam/steamapps/common/Substance 3D Designer 2023/resources/packages/" --includes "$(SBS_DIR)/utilities/"
# but it seems obsolete, check how to add other dependencies integrated if needed
export MAKESBSAR=~/.local/share/Steam/steamapps/common/Substance\ 3D\ Designer\ 2023/sbscooker --quiet --output-name {inputName}
export SBSRENDER=~/.local/share/Steam/steamapps/common/Substance\ 3D\ Designer\ 2023/sbsrender
# texturesets files
export TEXTURESET_FOLDER := build/texturesets
@ -21,10 +21,10 @@ export PNG256_DIR := build/png_256
# Blender related
export BLENDFILES_FOLDER := example/blenderfiles
export BLENDEREXEC := /opt/blender/blender
export BLENDEREXEC := /home/yann/Documents/3D/blender_builds/current_stable/blender
# Logo file
export LOGO := example/logo/YKtextures.png
export LOGO := example/logo/yk.png
# Destination preview folder
export PREVIEW_FOLDER := build/previews