Feat: Use custom color config

This commit is contained in:
Raimund58
2025-03-11 15:48:36 +00:00
committed by Sheepit Renderfarm
parent 912c69e8c8
commit d2f202de5c

View File

@@ -40,6 +40,9 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -200,7 +203,7 @@ import static com.sheepit.client.rendering.RenderSettings.UPDATE_METHOD_BY_TILE;
new_env.put("BLENDER_SYSTEM_DATAFILES", ""); new_env.put("BLENDER_SYSTEM_DATAFILES", "");
new_env.put("BLENDER_SYSTEM_PYTHON", ""); new_env.put("BLENDER_SYSTEM_PYTHON", "");
new_env.put("OCIO", ""); //prevent blender from loading a non-standard color configuration new_env.put("OCIO", getColorConfig()); //load custom color configs. If the path is invalid, Blender should fall back to the bundled config
new_env.put("TEMP", configuration.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\")); new_env.put("TEMP", configuration.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\"));
new_env.put("TMP", configuration.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\")); new_env.put("TMP", configuration.getWorkingDirectory().getAbsolutePath().replace("\\", "\\\\"));
@@ -658,6 +661,26 @@ import static com.sheepit.client.rendering.RenderSettings.UPDATE_METHOD_BY_TILE;
return Error.Type.OK; return Error.Type.OK;
} }
/**
* Checks whether the project contains a custom color config and if so, returns the path to it, otherwise returns an empty string.
* The color config must be in a folder called OCIO and contain a config.ocio file
*/
private String getColorConfig() {
String scenePath = getScenePath(); // Get the full path to the .blend file
String sceneDirectory = new File(scenePath).getParent(); // Get the directory containing the .blend file
Path ocioPath = Paths.get(sceneDirectory, "OCIO", "config.ocio"); // Construct the correct path to the custom color config
if (Files.exists(ocioPath)) {
log.info("Job::getColorConfig Using custom color configuration");
return ocioPath.toAbsolutePath().toString();
}
else {
log.info("Job::getColorConfig Using default color configuration");
return "";
}
}
private int computeRenderingProgress(String line, Pattern tilePattern, int currentProgress) { private int computeRenderingProgress(String line, Pattern tilePattern, int currentProgress) {
Matcher standardTileInfo = tilePattern.matcher(line); Matcher standardTileInfo = tilePattern.matcher(line);
int newProgress = currentProgress; int newProgress = currentProgress;