question

Bhuwan Sharma avatar image
Bhuwan Sharma asked ·

template file not working for osl shader UI

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

shadersosl
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

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')

oslrndtemptemplate.zip


2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

do you know how can i compile all these files(template, mtd and osl) without restarting maya?

cause right now I'm into a recursive process of restarting maya...xd

0 Likes 0 · ·

no way, you have to restart Maya each time you change the code

1 Like 1 · ·
rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

Here is the LayerTemplate.py and the .mtd file for Maya, Houdini, Cinema4D
layerstemplate.zip


layerstemplate.zip (1.1 KiB)
Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

work fine with .mtd & template file


layers.jpg (65.3 KiB)
5 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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.

0 Likes 0 · ·

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

0 Likes 0 · ·
Mads Drøschler avatar image Mads Drøschler rachid Hadj Abderrahmane ·

Good idea, Ill look at it.

0 Likes 0 · ·
Show more comments
Edward Conry avatar image
Edward Conry answered ·

@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.

1 comment Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

lol, and I'm into that crap right now.....xd

0 Likes 0 · ·
rachid Hadj Abderrahmane avatar image
rachid Hadj Abderrahmane answered ·

If maya.classification STRING "shader/surface" you get automatically normalCamera & hardwareColor.
So you have to use self.suppress!

1 comment Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

ahhhh! got it....thanks for that

0 Likes 0 · ·
Bhuwan Sharma avatar image
Bhuwan Sharma answered ·

@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)..................................


capture.jpg (12.0 KiB)
Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Bhuwan Sharma avatar image
Bhuwan Sharma answered ·

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)

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Bhuwan Sharma avatar image
Bhuwan Sharma answered ·
1 comment Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

and also is there any way I can compile my osl shader(with UI meta file and template file) without restarting maya?

0 Likes 0 · ·
Edward Conry avatar image
Edward Conry answered ·

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.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Bhuwan Sharma avatar image
Bhuwan Sharma answered ·

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

2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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",
float min = 0.0,
float max = 100.0
]],
https://github.com/gkmotu/OSL-Shaders/blob/master/Layers.osl
0 Likes 0 · ·

see it doesn't work with maya...:P

1 Like 1 · ·
capture.jpg (21.0 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.