Created
April 26, 2011 13:48
-
-
Save dbr/942288 to your computer and use it in GitHub Desktop.
WIP OCIO integration for RV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rvtypes; | |
use app_utils; | |
use commands; | |
use extra_commands; | |
use rvui; | |
require math; | |
require io; | |
require qt; | |
require system; | |
module: ocio_source_setup { | |
\: makelut(string; string src, string dest, string shaper) | |
{ | |
string outfile = "/tmp/ocio_%s_via_%s_to_%s.csp" % (src, shaper, dest); | |
string extra = ""; | |
if(shaper neq nil) | |
{ | |
extra = "--shaperspace %s" % shaper; | |
} | |
string cmdstr = "ociobakelut --cubesize 3 --shapersize 10 --format cinespace --inputspace %s %s --outputspace %s %s" % (src, extra, dest, outfile); | |
print("Running command: %s\n" % cmdstr); | |
qt.QTime timer = qt.QTime(); | |
timer.start(); | |
int status = system.system(cmdstr); | |
if(status != 0) | |
{ | |
print("Error while generating LUT's, exit code was %s after %sms\n" % (status, timer.restart())); | |
} | |
else | |
{ | |
print("LUT generated in %sms\n" % timer.restart()); | |
} | |
return outfile; | |
} | |
class: SourceSetupMode : MinorMode | |
{ | |
\: sourceSetup (void; Event event, bool noColorChanges) | |
{ | |
qt.QTime timer_overall = qt.QTime(); | |
timer_overall.start(); | |
let args = event.contents().split(";;"), | |
source = args[0], | |
colorNode = associatedNode("RVColor", source), | |
fmtNode = associatedNode("RVFormat", source), | |
tformNode = associatedNode("RVTransform2D", source), | |
lookNode = associatedNode("RVLookLUT", source), | |
type = args[1], | |
file = args[2], | |
ext = io.path.extension(file); | |
print("Source is: %s\n" % source); | |
print("Type is %s\n" % type); | |
print("File is %s\n" % file); | |
qt.QTime timer = qt.QTime(); | |
timer.start(); | |
int cubesize = 32; | |
float[] zecube = float[](); | |
for(int b = 0; b < cubesize; b++) | |
{ | |
for(int g = 0; g < cubesize; g++) | |
{ | |
for(int r = 0; r < cubesize; r++) | |
{ | |
zecube.push_back(r / (float(cubesize)-1)); | |
zecube.push_back(g*1.2 / (float(cubesize)-1)); | |
zecube.push_back(b / (float(cubesize)-1)); | |
} | |
} | |
} | |
print("Making dummy LUT took %sms\n" % timer.restart()); | |
timer.start(); | |
setIntProperty("%s.lut.size" % lookNode, int[] {cubesize, cubesize, cubesize}); | |
set("%s.lut.lut" % lookNode, zecube); | |
setStringProperty("%s.lut.type" % lookNode, string[] {"RGB"}); | |
setIntProperty("%s.lut.active" % lookNode, int[] {1}); | |
print("Manually setting LUT's took %sms\n" % timer.restart()); | |
/* Old slow file-based LUT method | |
// Generate the LUT's | |
timer.start(); | |
string filelutfile = makelut("lg10", "lnf", nil); | |
string looklutfile = makelut("lnf", "srgb8", "lg10"); | |
print("Generating both LUT's took %sms\n" % timer.restart()); | |
// Read the LUT's | |
timer.start(); | |
readLUT(filelutfile, colorNode); | |
readLUT(looklutfile, lookNode); | |
print("readLUT's took %sms\n" % timer.restart()); | |
// Activate them | |
timer.start(); | |
setIntProperty("%s.lut.active" % lookNode, int[] {1}); | |
setIntProperty("%s.lut.active" % colorNode, int[] {1}); | |
print("setIntProperty to active LUT %sms\n" % timer.restart()); | |
*/ | |
// Force LUT's to be updated | |
timer.start(); | |
updateLUT(); | |
print("updateLUT took %sms\n" % timer.restart()); | |
// Disable RV's default linear-to-blah transforms | |
set("#RVDisplayColor.color.sRGB", 0); | |
set("#RVDisplayColor.color.Rec709", 0); | |
event.reject(); | |
print("Overall took %sms\n" % timer_overall.restart()); | |
} | |
method: SourceSetupMode (SourceSetupMode;) | |
{ | |
init("Source Setup", | |
nil, | |
[("new-source", sourceSetup(,false), "Color and Geometry Management")], | |
nil); | |
} | |
} | |
\: createMode (Mode;) | |
{ | |
return SourceSetupMode(); | |
} | |
} // end ocio_source_setup module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment