Textures_factory/Makefile
2021-12-15 21:55:20 +01:00

91 lines
3 KiB
Makefile

# Variables definitions
SHELL=/bin/bash
# executables used
export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "sbs/utilities/"
export GETPRESET=sbsmutator info --print-presets
export GETOUTPUT=sbsmutator info --print-outputs
export SBSRENDER=sbsrender
# sbsar files generation part
export SBS_DIR=sbs
export SBSAR_DIR=sbsar
export SBSFILES = $(wildcard $(SBS_DIR)/*.sbs)
export SBSARDESTINATION = $(subst $(SBS_DIR)/, $(SBSAR_DIR)/, $(SBSFILES))
export SBSARFILES = $(SBSARDESTINATION:.sbs=.sbsar)
# texturesets files
export TEXTURESET_FOLDER := texturesets
# png files folders - Veiller à changer dans le script create_pngsets_makefile.sh également si besoin
export PNG1024_DIR := png_1024
export PNG512_DIR := png_512
export PNG256_DIR := png_256
# Blender related
export BLENDFILES_FOLDER := blenderfiles/master
export BLENDEREXEC := /home/yann/Documents/3D/blender_builds/daily/blender-3.1.0-alpha+daily.c1f5d8d023c6/blender
# Logo file
export LOGO := logo/YKtextures.png
# Destination folder
export BUILD_FOLDER := build
# Material list
export MATERIALLIST := material_list.json
all : previews subformats
previews: $(SBSARFILES)
$(MAKE) -f Makefile_previews all
subformats: $(SBSARFILES)
$(MAKE) -f Makefile_subformats all
export: $(SBSARFILES)
$(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 $$(basename $@ ".sbsar")
@ 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)
@ echo "Building 1024 png imageset(s) from presets of" $@
# Get all presets from this base material
@ $(eval PRESETLIST=`$(GETPRESET) --input $< | grep PRESET | sed -r 's/PRESET "(.*)"/\1/g'`)
@ 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 "output_list :"$$output_list;\
pngfiles="";\
material=$$(basename $@ ".sbsar");\
echo "material :"$$material;\
for preset in $(PRESETLIST) ; do \
echo "- Preset" $$preset; \
listitem="";\
for item in $$output_list;\
do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\
listitem="$$listitem $$itemfull";\
done;\
echo "listitem :"$$listitem;\
mkdir --parents $(TEXTURESET_FOLDER);\
echo $$listitem > $(TEXTURESET_FOLDER)/$$(basename $@ ".sbsar")_$$preset;\
$(SBSRENDER) render $@ --use-preset $$preset --output-name {inputGraphUrl}\_$$preset\_{outputNodeName} --set-value \$$outputsize@10,10# --output-path $(PNG1024_DIR); \
done;\