hey guys, I'm making an UI for my osl shader and everything compiles fine if I put just one control to the template file. but as soon as I put another control, the template file is no longer compiled by maya...don't know why........
this is the link to the doc.: https://docs.arnoldrenderer.com/display/A5AFMUG/Creating+a+Shader
it works fine for just one parameter.....asa I do self.addControl(bla bla bla) on another line it doesn't work
wow that sounds very convoluted to populate ui for osl shaders in maya.
In max/notepad, all we do is simply write a single shader file that contains body and UI and these also works in other hosts.
I was hitting my head around this and finally (with the help of solidAngle support team) I brought my osl UI into work...and now again the problem comes ....damn it .......
does max read UI metadata directly from osl?...that's cool.......
by "other hosts" you mean all other softwares? except maya?:xd
OH IC. (ouch) Yes, meta drives it 4sure.
Try see example I did here ->
Line 147 -152 -
float Visibility10 = 100.0[[string label="10:Visibility",https://github.com/gkmotu/OSL-Shaders/blob/master/Layers.osl
float min = 0.0,
float max = 100.0
]],
I don't know if this will help but there is a osl shader in maya that takes the code and compiles it. It's called aiOslShader. After it's compiled than you can export it as an osl shader. It makes it easier for testing.
and also is there any way I can compile my osl shader(with UI meta file and template file) without restarting maya?
@Bhuwan Sharma Yeah I think that aiOslShader is limited. I think that restarting Maya every time would drive me nuts when testing code. I wish there was a workaround.
Looks good. Its more advanced than what we can achieve in max. we are forced to name things with a unique string, else stuff gets populated on same line in ui. You did what I want to do there, just call Mix, Mix, and not mix4. Love the slider, we dont have that.
Yeah with Label in AEtemplate you can rename any parameter.
Just a suggestion, it will be great if you change Enable and Visibility to Boolean on or off
Here is the LayerTemplate.py and the .mtd file for Maya, Houdini, Cinema4D
layerstemplate.zip
The "widget" meta tag is used to trigger boolean condition in max, my guess is maya skips this.
The shader already uses this, maybe you can still extract the integer state to a maya boolean in the UI you write.
thank you so much @rachid Hadj Abderrahmane
python is very sensitive to indentations...so that was creating problem in my code.....thanks
and also which version of maya are you using? the template and mtd file you gave above(for Layers.osl) doesn't work for me(the mtd file isn't working)
Your osl file has constantColorA and constantColorB, so put the same name in AEtemplate!
So change from:
self.addControl('floatA', label='floatParamA', annotation='Constant floatA')
self.addControl('floatB', label='floatParamB', annotation='Constant floatB')
To this
self.addControl("constantColorA", label="floatParamA", annotation="Constant floatA")
self.addControl("constantColorB", label="floatParamB", annotation="Constant floatB")
self.endLayout()
self.suppress('normalCamera')
self.suppress('hardwareColor')
Yes Maya skip that widget because it's not part for the shader, when I kick -info Layers, return this informations as you can see, no boolean parameter
@rachid Hadj Abderrahmane what i concluded after so many failing attempts that it takes 'maya.name' from the metadata not the 'attr' name
**edited : lol, it takes both (attr name and maya.name)....both working fine xd....cheers!!!
and why it was not working for me cause there was some indentation problem ....it's working now...
and if every thing goes fine it'll automatically suppress the normal camera and hardware color param(no need to explicitly say self.suppress()....(atleast in maya 2019.2)..................................
Can't find what you're looking for? Ask the community or share your knowledge.