use of org.sunflow.Benchmark in project joons-renderer by joonhyublee.
the class SunflowGUI method main.
public static void main(String[] args) {
if (args.length > 0) {
boolean showFrame = true;
String sampler = null;
boolean noRender = false;
String filename = null;
String input = null;
int i = 0;
int threads = 0;
boolean lowPriority = true;
boolean showAA = false;
boolean noGI = false;
boolean noCaustics = false;
int pathGI = 0;
float maxDist = 0;
String shaderOverride = null;
int resolutionW = 0, resolutionH = 0;
int aaMin = -5, aaMax = -5;
int samples = -1;
int bucketSize = 0;
String bucketOrder = null;
String bakingName = null;
boolean bakeViewdep = false;
String filterType = null;
boolean runBenchmark = false;
boolean runRTBenchmark = false;
String translateFilename = null;
int frameStart = 1, frameStop = 1;
while (i < args.length) {
if (args[i].equals("-o")) {
if (i > args.length - 2) {
usage(false);
}
filename = args[i + 1];
i += 2;
} else if (args[i].equals("-nogui")) {
showFrame = false;
i++;
} else if (args[i].equals("-ipr")) {
sampler = "ipr";
i++;
} else if (args[i].equals("-threads")) {
if (i > args.length - 2) {
usage(false);
}
threads = Integer.parseInt(args[i + 1]);
i += 2;
} else if (args[i].equals("-lopri")) {
lowPriority = true;
i++;
} else if (args[i].equals("-hipri")) {
lowPriority = false;
i++;
} else if (args[i].equals("-sampler")) {
if (i > args.length - 2) {
usage(false);
}
sampler = args[i + 1];
i += 2;
} else if (args[i].equals("-smallmesh")) {
TriangleMesh.setSmallTriangles(true);
i++;
} else if (args[i].equals("-dumpkd")) {
KDTree.setDumpMode(true, "kdtree");
i++;
} else if (args[i].equals("-buildonly")) {
noRender = true;
i++;
} else if (args[i].equals("-showaa")) {
showAA = true;
i++;
} else if (args[i].equals("-nogi")) {
noGI = true;
i++;
} else if (args[i].equals("-nocaustics")) {
noCaustics = true;
i++;
} else if (args[i].equals("-pathgi")) {
if (i > args.length - 2) {
usage(false);
}
pathGI = Integer.parseInt(args[i + 1]);
i += 2;
} else if (args[i].equals("-quick_ambocc")) {
if (i > args.length - 2) {
usage(false);
}
maxDist = Float.parseFloat(args[i + 1]);
// new
shaderOverride = "ambient_occlusion";
// AmbientOcclusionShader(Color.WHITE,
// d);
i += 2;
} else if (args[i].equals("-quick_uvs")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "show_uvs";
i++;
} else if (args[i].equals("-quick_normals")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "show_normals";
i++;
} else if (args[i].equals("-quick_id")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "show_instance_id";
i++;
} else if (args[i].equals("-quick_prims")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "show_primitive_id";
i++;
} else if (args[i].equals("-quick_gray")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "quick_gray";
i++;
} else if (args[i].equals("-quick_wire")) {
if (i > args.length - 1) {
usage(false);
}
shaderOverride = "wireframe";
i++;
} else if (args[i].equals("-resolution")) {
if (i > args.length - 3) {
usage(false);
}
resolutionW = Integer.parseInt(args[i + 1]);
resolutionH = Integer.parseInt(args[i + 2]);
i += 3;
} else if (args[i].equals("-aa")) {
if (i > args.length - 3) {
usage(false);
}
aaMin = Integer.parseInt(args[i + 1]);
aaMax = Integer.parseInt(args[i + 2]);
i += 3;
} else if (args[i].equals("-samples")) {
if (i > args.length - 2) {
usage(false);
}
samples = Integer.parseInt(args[i + 1]);
i += 2;
} else if (args[i].equals("-bucket")) {
if (i > args.length - 3) {
usage(false);
}
bucketSize = Integer.parseInt(args[i + 1]);
bucketOrder = args[i + 2];
i += 3;
} else if (args[i].equals("-bake")) {
if (i > args.length - 2) {
usage(false);
}
bakingName = args[i + 1];
i += 2;
} else if (args[i].equals("-bakedir")) {
if (i > args.length - 2) {
usage(false);
}
String baketype = args[i + 1];
if (baketype.equals("view")) {
bakeViewdep = true;
} else if (baketype.equals("ortho")) {
bakeViewdep = false;
} else {
usage(false);
}
i += 2;
} else if (args[i].equals("-filter")) {
if (i > args.length - 2) {
usage(false);
}
filterType = args[i + 1];
i += 2;
} else if (args[i].equals("-bench")) {
runBenchmark = true;
i++;
} else if (args[i].equals("-rtbench")) {
runRTBenchmark = true;
i++;
} else if (args[i].equals("-frame")) {
if (i > args.length - 2) {
usage(false);
}
frameStart = frameStop = Integer.parseInt(args[i + 1]);
i += 2;
} else if (args[i].equals("-anim")) {
if (i > args.length - 3) {
usage(false);
}
frameStart = Integer.parseInt(args[i + 1]);
frameStop = Integer.parseInt(args[i + 2]);
i += 3;
} else if (args[i].equals("-v")) {
if (i > args.length - 2) {
usage(false);
}
UI.verbosity(Integer.parseInt(args[i + 1]));
i += 2;
} else if (args[i].equals("-translate")) {
if (i > args.length - 2) {
usage(false);
}
translateFilename = args[i + 1];
i += 2;
} else if (args[i].equals("-h") || args[i].equals("-help")) {
usage(true);
} else {
if (input != null) {
usage(false);
}
input = args[i];
i++;
}
}
if (runBenchmark) {
SunflowAPI.runSystemCheck();
new Benchmark().execute();
return;
}
if (runRTBenchmark) {
SunflowAPI.runSystemCheck();
new RealtimeBenchmark(showFrame, threads);
return;
}
if (input == null) {
usage(false);
}
SunflowAPI.runSystemCheck();
if (translateFilename != null) {
SunflowAPI.translate(input, translateFilename);
return;
}
if (frameStart < frameStop && showFrame) {
UI.printWarning(Module.GUI, "Animations should not be rendered without -nogui - forcing GUI off anyway");
showFrame = false;
}
if (frameStart < frameStop && filename == null) {
filename = "output.#.png";
UI.printWarning(Module.GUI, "Animation output was not specified - defaulting to: \"%s\"", filename);
}
for (int frameNumber = frameStart; frameNumber <= frameStop; frameNumber++) {
SunflowAPI api = SunflowAPI.create(input, frameNumber);
if (api == null) {
continue;
}
if (noRender) {
continue;
}
if (resolutionW > 0 && resolutionH > 0) {
api.parameter("resolutionX", resolutionW);
api.parameter("resolutionY", resolutionH);
}
if (aaMin != -5 || aaMax != -5) {
api.parameter("aa.min", aaMin);
api.parameter("aa.max", aaMax);
}
if (samples >= 0) {
api.parameter("aa.samples", samples);
}
if (bucketSize > 0) {
api.parameter("bucket.size", bucketSize);
}
if (bucketOrder != null) {
api.parameter("bucket.order", bucketOrder);
}
api.parameter("aa.display", showAA);
api.parameter("threads", threads);
api.parameter("threads.lowPriority", lowPriority);
if (bakingName != null) {
api.parameter("baking.instance", bakingName);
api.parameter("baking.viewdep", bakeViewdep);
}
if (filterType != null) {
api.parameter("filter", filterType);
}
if (noGI) {
api.parameter("gi.engine", "none");
} else if (pathGI > 0) {
api.parameter("gi.engine", "path");
api.parameter("gi.path.samples", pathGI);
}
if (noCaustics) {
api.parameter("caustics", "none");
}
if (sampler != null) {
api.parameter("sampler", sampler);
}
api.options(SunflowAPI.DEFAULT_OPTIONS);
if (shaderOverride != null) {
if (shaderOverride.equals("ambient_occlusion")) {
api.parameter("maxdist", maxDist);
}
api.shader("cmdline_override", shaderOverride);
api.parameter("override.shader", "cmdline_override");
api.parameter("override.photons", true);
api.options(SunflowAPI.DEFAULT_OPTIONS);
}
// create display
Display display;
String currentFilename = (filename != null) ? filename.replace("#", String.format("%04d", frameNumber)) : null;
if (showFrame) {
display = new FrameDisplay(currentFilename);
} else {
if (currentFilename != null && currentFilename.equals("imgpipe")) {
display = new ImgPipeDisplay();
} else {
display = new FileDisplay(currentFilename);
}
}
api.render(SunflowAPI.DEFAULT_OPTIONS, display);
}
} else {
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}
SunflowGUI gui = new SunflowGUI();
gui.setVisible(true);
Dimension screenRes = Toolkit.getDefaultToolkit().getScreenSize();
if (screenRes.getWidth() <= DEFAULT_WIDTH || screenRes.getHeight() <= DEFAULT_HEIGHT) {
gui.setExtendedState(MAXIMIZED_BOTH);
}
gui.tileWindowMenuItem.doClick();
SunflowAPI.runSystemCheck();
}
}
Aggregations