Merge branch '6-untrack-material_list-json' into 'main'

Resolve "Untrack example content"

Closes #6

See merge request yannk/textures-factory!2
This commit is contained in:
yannk 2021-12-20 22:54:27 +01:00
commit 45ecd02aca
11 changed files with 33 additions and 28 deletions

6
.gitignore vendored
View file

@ -1,8 +1,8 @@
.autosave
build/ build/
*.png~
blenderfiles/textures/*
*.blend[0-9]* *.blend[0-9]*
# Ignore local configuration file # Ignore local configuration file
local-config.mk local-config.mk
# Ignore sbs autosave files
.autosave

View file

@ -2,7 +2,8 @@
SHELL=/bin/bash SHELL=/bin/bash
# Get Configuration informations from global or local config file # Get Configuration informations from global or local config file
CONFIG_FILES=global-config.mk local-config.mk LOCAL_CONFIG = $(wildcard local-config.mk)
CONFIG_FILES = global-config.mk $(LOCAL_CONFIG)
include $(CONFIG_FILES) include $(CONFIG_FILES)
# sbsar files generation part # sbsar files generation part

View file

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

View file

@ -6,20 +6,20 @@ This repository use [Git LFS](https://git-lfs.github.com/).
### Configuration of the Makefile ### Configuration of the Makefile
The file `global-config.mk` contain configuration informations about paths to sources, executables and to the building destinations. It details all the variables which can be set but shouldnt be modified, as it can receive new variables in the future needed for the script to work. Moreover is handled by git for new versions and any changes you make would be erased by new pull of the script. If you want to specify a dedicated value to any variable, you should copy its line definition to a new file inf the same folder, called `local-config.mk`. Like this, you will keep your local configuration files in the future with new versions of the script. The file `global-config.mk` contains configuration informations about paths to sources, executables and to the building destinations. It details all the variables which can be set. Be aware that it shouldnt be modified, as it can receive new variables in the future needed for the script to work and concerns only example files included with the script. Moreover it is handled by git for new versions and any changes you make would be erased by new pull of the script. To specify dedicated values to any variable, you should copy its line definition to a new file in the same folder, called `local-config.mk`. Like this, you will keep your local configuration files in the future with new versions of the script. You will have to do it at least to take in charge your personal data and not the `example` content given.
Simply write either the absolute or the relative path from your Makefile script situation for any information needed. Simply write either the absolute or the relative path from your Makefile script situation for any information needed.
## Executables used
These are the adress of the substance automation toolkit binaries.
## Sbsar files generation part ## Sbsar files generation part
You need to define a sbs source folder where the script will check for new content in the `SBS_DIR` variables content. You need to define a sbs source folder where the script will check for new content in the `SBS_DIR` variables content.
You must write down also the place where the script will write the generated sbsar. You must write down also the place where the script will write the generated sbsar.
## Executables used
These are the adress of the substance automation toolkit binaries. Note you can use former variables defined sooner in the file, like it is done in the `--includes` section of MAKESBSAR.
## Texturesets files ## Texturesets files
This files will be used only internally by the script to check the texturesets it handles. This files will be used only internally by the script to check the texturesets it handles.

View file

@ -1,13 +1,13 @@
# sbsar files generation part
export SBS_DIR=example/sbs
export SBSAR_DIR=build/sbsar
# executables used # executables used
export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "sbs/utilities/" export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "$(SBS_DIR)/utilities/"
export GETPRESET=sbsmutator info --print-presets export GETPRESET=sbsmutator info --print-presets
export GETOUTPUT=sbsmutator info --print-outputs export GETOUTPUT=sbsmutator info --print-outputs
export SBSRENDER=sbsrender export SBSRENDER=sbsrender
# sbsar files generation part
export SBS_DIR=sbs
export SBSAR_DIR=build/sbsar
# texturesets files # texturesets files
export TEXTURESET_FOLDER := build/texturesets export TEXTURESET_FOLDER := build/texturesets
@ -20,14 +20,14 @@ export PNG512_DIR := build/png_512
export PNG256_DIR := build/png_256 export PNG256_DIR := build/png_256
# Blender related # Blender related
export BLENDFILES_FOLDER := blenderfiles/master export BLENDFILES_FOLDER := example/blenderfiles
export BLENDEREXEC := blender export BLENDEREXEC := /opt/blender/blender
# Logo file # Logo file
export LOGO := logo/YKtextures.png export LOGO := example/logo/YKtextures.png
# Destination preview folder # Destination preview folder
export PREVIEW_FOLDER := build/previews export PREVIEW_FOLDER := build/previews
# Material list # Material list
export MATERIALLIST := material_list.json export MATERIALLIST := example/material_list.json