Community
Arnold for Maya Forum
Rendering with Arnold in Maya using the MtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

template file not working for osl shader UI

28 REPLIES 28
Reply
Message 1 of 29
Anonymous
1707 Views, 28 Replies

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

Tags (2)
Labels (2)
28 REPLIES 28
Message 2 of 29
madsd
in reply to: Anonymous

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.

Message 3 of 29
Anonymous
in reply to: Anonymous

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

Message 4 of 29
madsd
in reply to: Anonymous

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
Message 5 of 29
teddude75
in reply to: Anonymous

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.

Message 6 of 29
Anonymous
in reply to: Anonymous
Message 7 of 29
Anonymous
in reply to: Anonymous

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

Message 8 of 29
Anonymous
in reply to: madsd

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

4698-capture.jpg

Message 9 of 29
teddude75
in reply to: Anonymous

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

Message 10 of 29
Anonymous
in reply to: teddude75

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

Message 11 of 29
Anonymous
in reply to: Anonymous

work fine with .mtd & template file

4699-layers.jpg

Message 12 of 29
madsd
in reply to: Anonymous

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.

Message 13 of 29
Anonymous
in reply to: madsd

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

Message 14 of 29
madsd
in reply to: Anonymous

Good idea, Ill look at it.

Message 15 of 29
Anonymous
in reply to: Anonymous

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

Message 16 of 29
madsd
in reply to: Anonymous

4704-eee.png

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.

Message 17 of 29
Anonymous
in reply to: Anonymous

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)

Message 18 of 29
Anonymous
in reply to: Anonymous

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

4710-oslrndtemp.jpg

oslrndtemptemplate.zip

Message 19 of 29
Anonymous
in reply to: madsd

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

4711-kick-layers.jpg

Message 20 of 29
Anonymous
in reply to: Anonymous

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

4713-capture.jpg

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report