2021-12-15 20:55:20 +00:00
|
|
|
|
# Variables definitions
|
|
|
|
|
SHELL=/bin/bash
|
|
|
|
|
|
2021-12-17 21:45:16 +00:00
|
|
|
|
# Get Configuration informations from global or local config file
|
2021-12-20 21:50:52 +00:00
|
|
|
|
LOCAL_CONFIG = $(wildcard local-config.mk)
|
|
|
|
|
CONFIG_FILES = global-config.mk $(LOCAL_CONFIG)
|
2021-12-17 21:45:16 +00:00
|
|
|
|
include $(CONFIG_FILES)
|
2021-12-15 20:55:20 +00:00
|
|
|
|
|
|
|
|
|
# sbsar files generation part
|
2021-12-17 21:45:16 +00:00
|
|
|
|
|
2021-12-15 20:55:20 +00:00
|
|
|
|
export SBSFILES = $(wildcard $(SBS_DIR)/*.sbs)
|
|
|
|
|
export SBSARDESTINATION = $(subst $(SBS_DIR)/, $(SBSAR_DIR)/, $(SBSFILES))
|
|
|
|
|
export SBSARFILES = $(SBSARDESTINATION:.sbs=.sbsar)
|
|
|
|
|
|
2021-12-27 17:11:50 +00:00
|
|
|
|
# existing texturesets list
|
|
|
|
|
export TEXTURES := $(wildcard $(TEXTURESET_FOLDER)/*)
|
|
|
|
|
|
2021-12-15 21:15:57 +00:00
|
|
|
|
### RECIPE PART ###
|
|
|
|
|
|
2021-12-30 13:24:37 +00:00
|
|
|
|
all : del_obsolete export
|
2021-12-15 20:55:20 +00:00
|
|
|
|
|
2021-12-30 13:24:37 +00:00
|
|
|
|
previews: $(SBSARFILES) | subformats
|
2021-12-15 20:55:20 +00:00
|
|
|
|
$(MAKE) -f Makefile_previews all
|
|
|
|
|
|
|
|
|
|
subformats: $(SBSARFILES)
|
|
|
|
|
$(MAKE) -f Makefile_subformats all
|
|
|
|
|
|
2021-12-30 13:24:37 +00:00
|
|
|
|
del_obsolete: $(SBS_DIR) | previews
|
|
|
|
|
@ for material in $$(ls $(SBSAR_DIR)); do \
|
|
|
|
|
rootname=$$(echo $$material | sed -r 's|(.*)\.sbsar|\1|');\
|
2021-12-27 17:11:50 +00:00
|
|
|
|
sbs_name=$(SBS_DIR)/$$rootname.sbs ;\
|
|
|
|
|
if [ ! -f $$sbs_name ] ;\
|
|
|
|
|
then echo "CLEANUP : The corresponding $$sbs_name doesn’t exist any more, deleting the corresponding obsolete files :" ;\
|
|
|
|
|
rm -Rf $(SBSAR_DIR)/$$rootname.sbsar ;\
|
|
|
|
|
echo " -"$(SBSAR_DIR)/$$rootname.sbsar ;\
|
|
|
|
|
rm -Rf $(PNG1024_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
echo " -"$(PNG1024_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
rm -Rf $(PNG512_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
echo " -"$(PNG512_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
rm -Rf $(PNG256_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
echo " -"$(PNG256_DIR)/$$(basename $$material)* ;\
|
|
|
|
|
rm -Rf $(TEXTURESET_FOLDER)/$$(basename $$material) ;\
|
|
|
|
|
echo " -"$(TEXTURESET_FOLDER)/$$(basename $$material) ;\
|
|
|
|
|
rm -Rf $(PREVIEW_FOLDER)/$$(basename $$material)* ;\
|
|
|
|
|
echo " -"$(PREVIEW_FOLDER)/$$(basename $$material)* ;\
|
|
|
|
|
fi ;\
|
|
|
|
|
done
|
|
|
|
|
|
2021-12-28 15:44:50 +00:00
|
|
|
|
export: $(SBSARFILES) | subformats
|
2021-12-15 20:55:20 +00:00
|
|
|
|
$(MAKE) -f Makefile_export all
|
|
|
|
|
|
|
|
|
|
# Recipe to make sbsar, its main PNG files and its preset textureset file
|
|
|
|
|
$(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
|
|
|
|
|
@ echo "Processing" $< "->" $@
|
|
|
|
|
@ mkdir -p $(SBSAR_DIR)
|
|
|
|
|
@ $(MAKESBSAR) --output-path $(SBSAR_DIR) $<
|
|
|
|
|
# Then build png imageset from sbsar
|
|
|
|
|
# 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)
|
2021-12-27 17:11:50 +00:00
|
|
|
|
# Get graph outputs list
|
2024-05-22 15:24:10 +00:00
|
|
|
|
@ outputs=$$(xmlstarlet sel -t -m "//content/graph[1]/graphOutputs/graphoutput/identifier" -o " " -v "@v" $<) ;\
|
|
|
|
|
echo " - Graph OUTPUTS : $$outputs";\
|
2021-12-27 17:11:50 +00:00
|
|
|
|
echo "Building 1024 png imageset(s) from presets of" $@ ;\
|
2021-12-15 20:55:20 +00:00
|
|
|
|
pngfiles="";\
|
2024-05-22 15:24:10 +00:00
|
|
|
|
presetlist=$$(xmlstarlet sel -t -m "//content/graph[1]/sbspresets/sbspreset/label" -o " " -v "@v" $<);\
|
|
|
|
|
echo " presetlist: " $$presetlist ; \
|
|
|
|
|
for preset in $$presetlist ; do \
|
2021-12-15 20:55:20 +00:00
|
|
|
|
echo "- Preset" $$preset; \
|
2021-12-27 17:11:50 +00:00
|
|
|
|
material=$$(basename -s .sbsar $@);\
|
|
|
|
|
echo "material :"$$material;\
|
|
|
|
|
obsolete="$${material}_$${preset}" ;\
|
|
|
|
|
echo "Cleaning old entries from the material : $$obsolete" ;\
|
|
|
|
|
rm -Rf $(PNG1024_DIR)/$$obsolete* ;\
|
|
|
|
|
rm -Rf $(PNG512_DIR)/$$obsolete* ;\
|
|
|
|
|
rm -Rf $(PNG256_DIR)/$$obsolete* ;\
|
2021-12-15 20:55:20 +00:00
|
|
|
|
listitem="";\
|
2024-05-22 15:24:10 +00:00
|
|
|
|
for item in $$outputs;\
|
2021-12-15 20:55:20 +00:00
|
|
|
|
do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\
|
|
|
|
|
listitem="$$listitem $$itemfull";\
|
|
|
|
|
done;\
|
|
|
|
|
echo "listitem :"$$listitem;\
|
|
|
|
|
mkdir --parents $(TEXTURESET_FOLDER);\
|
2021-12-27 17:11:50 +00:00
|
|
|
|
echo $$listitem > $(TEXTURESET_FOLDER)/$$(basename -s .sbsar $@)_$$preset;\
|
2021-12-30 09:14:18 +00:00
|
|
|
|
rendersize=$$(cat $(MATERIALLIST) | jq -r --arg folder "$${material}_$${preset}" '.[] | select(.name==$$folder) | .format') ;\
|
|
|
|
|
$(SBSRENDER) render $@ --use-preset $$preset --output-name {inputGraphUrl}\_$$preset\_{outputNodeName} --set-value \$$outputsize@$$rendersize# --output-path $(PNG1024_DIR); \
|
2021-12-15 20:55:20 +00:00
|
|
|
|
done;\
|
|
|
|
|
|