60 lines
3.3 KiB
Text
60 lines
3.3 KiB
Text
TEXTURESETS := $(foreach file, $(TEXTURESET_FOLDER), $(basename $(notdir $(wildcard $(TEXTURESET_FOLDER)/*))))
|
|
|
|
# Build list of destination filenames of previews
|
|
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))
|
|
# Add them png suffix and destination path
|
|
TARGET := $(foreach file, $(RENDER_LIST), $(addsuffix .png, $(file)))
|
|
TARGET := $(foreach file, $(TARGET), $(addprefix $(PREVIEW_FOLDER)/, $(file)))
|
|
|
|
# Build list of corresponding recipe filenames
|
|
RECIPE_RENDERS = $(foreach RECIPE_RENDER, $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/$(shell cat $(MATERIALLIST) | jq -r --arg folder "$(TEX_SET)" '.[] | select(.name==$$folder) | .type')/*.blend))), %_$(RECIPE_RENDER))
|
|
RECIPE_RENDERS_LIST := $(foreach TEX_SET, $(TEXTURESETS), $(RECIPE_RENDERS))
|
|
# Add them png suffix and destination path
|
|
RENDERS := $(foreach file, $(RECIPE_RENDERS_LIST), $(addsuffix .png, $(file)))
|
|
RENDERS := $(foreach file, $(RENDERS), $(addprefix $(PREVIEW_FOLDER)/, $(file)))
|
|
|
|
|
|
all: $(TARGET)
|
|
@ echo "RENDER_LIST : $(RENDER_LIST)"
|
|
@ echo "RENDER_FILES : $(RENDER_FILES)"
|
|
@ echo "RENDERS :" $(RENDERS)
|
|
@ echo "RECIPE_RENDERS :" $(RECIPE_RENDERS)
|
|
@ echo "RECIPE_RENDERS_LIST :" $(RECIPE_RENDERS_LIST)
|
|
@ echo "TARGET : $(TARGET)"
|
|
@ echo "TEXTURESETS : $(TEXTURESETS)"
|
|
|
|
$(RENDERS): $(TEXTURESET_FOLDER)/%
|
|
@ 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
|