Tuesday, August 23, 2011

3Delight for Maya | renderman code nodes & linear stuff

Ok, I was getting ready for next tutorial-like post but I thought I should take another read on some posts @ 3delight's forum.

Basically, using the next function in renderman code nodes and connecting your maya file node in the input will result in a "linearized" image, right?


color sRGBToLinear( color inCol )
{
float _r,_g,_b = 0;
if( comp(inCol,0) < 0.04045 ) { _r = comp(inCol,0)/12.92; }else{ _r = pow( (comp(inCol,0)+0.055)/1.055, 2.4 ); }
if( comp(inCol,1) < 0.04045 ) { _g = comp(inCol,1)/12.92; }else{ _g = pow( (comp(inCol,1)+0.055)/1.055, 2.4 ); }
if( comp(inCol,2) < 0.04045 ) { _b = comp(inCol,2)/12.92; }else{ _b = pow( (comp(inCol,2)+0.055)/1.055, 2.4 ); }

return color(_r,_g,_b);
}


Well, it won't. There's a file called DL_globals.mel in your 3delight installation which will perform a tdlmake call on every file node. This means we'll get a prefiltered image from a srgb texture map and this is incorrect. A solution? Well, we could simply edit that file (line 3269) from


string $cmd = "tdlmake -newer -mode periodic ";


to


string $cmd = "tdlmake -colorspace srgb -newer -mode periodic ";


But we have some exr and hdr files from time to time. Then we should check if the file is in any of those formats (linear) and modify that tdlmake call. Or we could simply use tdlmake in terminal on the textures to be used, outside maya. If we have lots of files, we can use a batch script (zsh works fine).

Long story short: This can mess up with the way you're rendering and that's why it is complicated to find the perfect workflow here, in the "web". From this point, it is better to assume everything read into maya is in the correct color space.

Some links:
http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=2690
http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=2690
http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=2210


That function, by the way, is from Nick Deboar's shaders posted here: http://www.3delight.com/en/modules/PunBB/viewtopic.php?id=3010

I'll fix some scenes and will get back with something useful (yeah, probably has been too much garbage around here for a couple of months).

No comments: