Textures_factory/Makefile_previews

49 lines
2.4 KiB
Text
Raw Normal View History

2021-12-15 20:55:20 +00:00
TEXTURESETS := $(foreach file, $(TEXTURESET_FOLDER), $(basename $(notdir $(wildcard $(TEXTURESET_FOLDER)/*))))
BLENDFILES := $(foreach file, $(BLENDFILES_FOLDER), $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/*.blend))))
BLENDFILES_SUFFIX := $(foreach file, $(BLENDFILES), $(addsuffix $(file), _))
TARGET := $(foreach file, $(TEXTURESETS), $(addprefix $(file), $(BLENDFILES_SUFFIX)))
TARGET := $(foreach file, $(TARGET), $(addsuffix .png, $(file)))
TARGET := $(foreach file, $(TARGET), $(addprefix $(BUILD_FOLDER)/, $(file)))
RENDERS := $(foreach file, $(BLENDFILES_SUFFIX), $(addprefix %, $(file)))
RENDERS := $(foreach file, $(RENDERS), $(addsuffix .png, $(file)))
RENDERS := $(foreach file, $(RENDERS), $(addprefix $(BUILD_FOLDER)/, $(file)))
all: $(TARGET)
$(RENDERS): $(TEXTURESET_FOLDER)/%
@ echo "RENDERS :" $(RENDERS)
@ echo "BLENDFILES :" $(BLENDFILES)
@ echo "Prerequisite :" $<
@ pngset=`cat $<`;\
echo "pngset :" $$pngset ;\
for file in $$pngset ;\
do basename=$$(basename "$$file");\
newname=$$(echo $$basename | sed -r 's/.*($(TEXTURES_NAMES))/\\\1/' | sed -r 's/\\//');\
2021-12-15 20:55:20 +00:00
mkdir --parents blenderfiles/textures;\
echo "Copying "$$file ;\
cp $$file blenderfiles/textures/$$newname ; done ;\
presetname=$$(echo $$(basename $< ".png") | sed -r 's/(.*_[0-9]{2})_.*/\\\1/' | sed -r 's/\\//');\
echo "presetname :"$$presetname;\
echo "MATERIALLIST :"$(MATERIALLIST);\
rendertype=$$(cat $(MATERIALLIST) | jq -r --arg folder "$$presetname" '.[] | select(.name==$$folder) | .type');\
echo "foldername :" $$rendertype;\
blender_render_files=$$(ls blenderfiles/$$rendertype/*.blend | sed -r 's/blenderfiles\/.*\///' | sed -r 's/\.blend//' | tr '\n' ' ') ;\
echo "blender_render_files :"$$blender_render_files;\
for blendname in $$blender_render_files;\
do echo "blendname :" $$blendname;\
destination=$$(echo $$presetname"_"$$blendname.png);\
echo "destination :"$(BUILD_FOLDER)"/"$$destination;\
blendfile=$$(echo "blenderfiles/"$$rendertype"/"$$blendname".blend");\
echo "blendfile :" $$blendfile;\
mkdir --parents render;\
echo "Rendering "$(BUILD_FOLDER)/$$destination;\
$(BLENDEREXEC) -b $$blendfile --render-output //../../render/render##.png -f 1 --addons > nul 2>&1;\
mkdir --parents $(BUILD_FOLDER);\
composite -compose atop -gravity southeast -dissolve 90% $(LOGO) render/render01.png $(BUILD_FOLDER)/$$destination;\
done
# Clean the subfolder with temp textures
@ rm -Rf blenderfiles/textures
# Clean the temp render folder
@ rm -Rf render