Tuesday, August 23, 2011

Tricks with standart input/output and the renderman shader compiler

Did you know that renderman shader compiler support the standart unix pipe?
I am looking for a way to rapidly develop co-shaders containing helpers data.
And I found a way that suits me.

in bash command line:

echo 'class test(float kd=0.7; float ks=0.1; color diffuse = color(1,0,0)){}' | shader -o /myProj/myShader.slo

echo 'class test(){ struct _data {varying float kd=0.7; varying float ks=0.1; varying color diffuse = color(1,0,0);}}' | shader -o /myProj/myShader.slo

in Maya mel:

system("echo 'class test(float kd=0.7; float ks=0.1; color diffuse = color(1,0,0)){}' | shader -o /myProj/myShader.slo");

or:

string $HelperContent = "'class test(float kd=0.7; float ks=0.1; color diffuse = color(1,0,0)){}'";
string $ShaderObject = "/myProj/myShader.slo";

system("echo "+$HelperContent+"|shader -o "+$ShaderObject);

in Maya python:

import os
os.system("echo 'class test(float kd=0.7; float ks=0.1; color diffuse = color(1,0,0)){}' | shader -o /myProj/myShader.slo")

No comments:

Post a Comment