62 lines
3.2 KiB
Text
62 lines
3.2 KiB
Text
TEXTURESETS := $(foreach file, $(TEXTURESET_FOLDER), $(basename $(notdir $(wildcard $(TEXTURESET_FOLDER)/*))))
|
|
|
|
|
|
RENDER_FOLDER = $(shell cat $(MATERIALLIST) | jq -r --arg folder "$(SET)" '.[] | select(.name==$$folder) | .type')
|
|
|
|
RENDER_FILES = $(foreach RENDER, $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/$(shell cat $(MATERIALLIST) | jq -r --arg folder "$(SET)" '.[] | select(.name==$$folder) | .type')/*.blend))), $(SET)_$(RENDER))
|
|
RENDER_LIST := $(foreach SET, $(TEXTURESETS), $(RENDER_FILES))
|
|
|
|
|
|
BLENDFILES := $(foreach file, $(BLENDFILES_FOLDER)/master, $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/master/*.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 $(PREVIEW_FOLDER)/, $(file)))
|
|
|
|
RENDERS := $(foreach file, $(BLENDFILES_SUFFIX), $(addprefix %, $(file)))
|
|
RENDERS := $(foreach file, $(RENDERS), $(addsuffix .png, $(file)))
|
|
RENDERS := $(foreach file, $(RENDERS), $(addprefix $(PREVIEW_FOLDER)/, $(file)))
|
|
|
|
all: $(TARGET)
|
|
|
|
$(RENDERS): $(TEXTURESET_FOLDER)/%
|
|
@ echo "RENDER_LIST : $(RENDER_LIST)"
|
|
@ echo "RENDER_FILES : $(RENDER_FILES)"
|
|
@ echo "RENDERS :" $(RENDERS)
|
|
@ echo "BLENDFILES :" $(BLENDFILES)
|
|
@ echo "BLENDFILES_SUFFIX :" $(BLENDFILES_SUFFIX)
|
|
@ echo "TARGET : $(TARGET)"
|
|
@ echo "TEXTURESETS : $(TEXTURESETS)"
|
|
@ 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/\\//');\
|
|
mkdir --parents $(BLENDFILES_FOLDER)/textures;\
|
|
echo "Copying "$$file ;\
|
|
cp $$file $(BLENDFILES_FOLDER)/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 $(BLENDFILES_FOLDER)/$$rendertype/*.blend | sed -r 's|$(BLENDFILES_FOLDER)/.*/||' | 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 :"$(PREVIEW_FOLDER)"/"$$destination;\
|
|
blendfile=$$(echo "$(BLENDFILES_FOLDER)/"$$rendertype"/"$$blendname".blend");\
|
|
echo "blendfile :" $$blendfile;\
|
|
mkdir --parents $(BLENDFILES_FOLDER)/render;\
|
|
temp_render_dir=$$(realpath $(BLENDFILES_FOLDER)/render);\
|
|
echo "Rendering "$(PREVIEW_FOLDER)/$$destination;\
|
|
$(BLENDEREXEC) -b $$blendfile --render-output $$temp_render_dir/render##.png -f 1 --addons > /dev/null 2>&1;\
|
|
mkdir --parents $(PREVIEW_FOLDER);\
|
|
composite -compose atop -gravity southeast -dissolve 90% $(LOGO) $(BLENDFILES_FOLDER)/render/render01.png $(PREVIEW_FOLDER)/$$destination;\
|
|
done
|
|
# Clean the subfolder with temp textures
|
|
@ rm -Rf $(BLENDFILES_FOLDER)/textures
|
|
# Clean the temp render folder
|
|
@ rm -Rf $(BLENDFILES_FOLDER)/render
|