Users browsing this thread: 2 Guest(s)
Render Scale Fidelity Comparator
#1
Hey all,

Recently I inspired myself to create a Windows batch script to help with deciding at which multiple scale to bake diffuse maps for model submissions, designed for the task of baking textures with vertex colours.

(This script requires ImageMagick, located here.)
The script makes each iterative pair of scaled textures comparative by temporarily downscaling the larger of the pair to match the dimensions of the smaller, then uses the RMSE metric to output the difference between that pair.
The script requires at least 2 PNG textures in the script's directory, named as (2^n)+"x.png", up to "1024x.png".
e.g. "1x.png", "2x.png", "4x.png", "8x.png", "16x.png"...

Example script output:
Code:
Scale Render Resolution Comparator (lower is closer):

Lower Scale     Higher Scale    Difference
1x              2x              0.500008
2x              4x              0.227054
4x              8x              0.0524371
8x              16x             0.0255653
16x             32x             0.00988641

A difference of less than 1% has been found, stopping.

From this output you can then easily determine the point of diminishing returns, at which the texture's fidelity is not worth the scale.

In this example the difference in iterations between 4x and 8x is 5.24%, and between 16x and 32x is 0.99%, from which we can then assume the appropriate scale to be at least 4x, up to 16x.

Save the below code insert as a batch file (.cmd extension):
Code:
@!! 2>NUL||CMD/Q/V/C%0&&EXIT/B&CD/D%~dp0
SET A=%1&IF NOT DEFINED A (SET A=10)&WHERE magick>NUL 2>&1&IF ERRORLEVEL 1 (PAUSE>NUL|SET/P="ImageMagick path not found, stopping."&EXIT/B)
TITLE Render Scale Fidelity Comparator&ECHO Scale Render Resolution Comparator (lower is closer):^

^

Lower Scale    Higher Scale    Difference
SET B=1&FOR /L %%A IN (1,1,%A%) DO SET/AB*=2&IF EXIST !B!x.png SET/AC=!B!/2&IF EXIST !C!x.png FOR /F %%A IN ('magick compare -format "%%[distortion]" -dissimilarity-threshold 1 -metric RMSE -subimage-search !B!x.png[50%%] !C!x.png null: 2^>NUL') DO SET D=%%A&ECHO !C!x        !B!x        !D!&IF "!D:~,4!"=="0.00" ECHO/&PAUSE>NUL|SET/P="A difference of less than 1%% has been found, stopping."&EXIT/B
Reply
Thanked by:


Forum Jump: