Hi,
Can't figure this out. When accessing a color parameter in shader, I get strangely repeating values:
e.g. my shader has red diffuse and grey ambient, so for example myPhong.diffuse red=1.0 and myPhong.ambient.red=0.5
and now..
LogMessage(myPhong.diffuse red+","+myPhong.ambient.red)
will log 1.0, 1.0 instead of 1.0, 0.5
which is weird.
When I use GetValue with the string names of the parameter apparently it works correctly but I still wonder what I'm doing wrong
Cheers
accessing color in scripts question
accessing color in scripts question
softimage resources section updated Jan 5th 2024
Re: accessing color in scripts question
I think I've always used NestedObjects or Parameters : myPhong.ambient.parameters('red') So I've never run into this problem but I've just tried what you said and effectively, it seems that the variable gets overwritten to whatever you got first.
If I do :
- Diffuse First
LogMessage (myPhong.diffuse.red)
LogMessage (myPhong.ambient.red)
Will log both diffuse.red.
If I do the opposite:
- Ambient First
LogMessage (myPhong.ambient.red)
LogMessage (myPhong.diffuse.red)
Will log both ambient.
- NestedObjects parameters
LogMessage (myPhong.diffuse.parameters('red'))
LogMessage (myPhong.ambient.parameters('red'))
LogMessage (myPhong.diffuse.NestedObjects('red'))
LogMessage (myPhong.ambient.NestedObjects('red'))
This works fine.
Curiously, if you change one of them to capital letters, it will also work
LogMessage (myPhong.ambient.red)
LogMessage (myPhong.diffuse.Red)
RED, or reD would also work.
If I do :
- Diffuse First
LogMessage (myPhong.diffuse.red)
LogMessage (myPhong.ambient.red)
Will log both diffuse.red.
If I do the opposite:
- Ambient First
LogMessage (myPhong.ambient.red)
LogMessage (myPhong.diffuse.red)
Will log both ambient.
- NestedObjects parameters
LogMessage (myPhong.diffuse.parameters('red'))
LogMessage (myPhong.ambient.parameters('red'))
LogMessage (myPhong.diffuse.NestedObjects('red'))
LogMessage (myPhong.ambient.NestedObjects('red'))
This works fine.
Curiously, if you change one of them to capital letters, it will also work
LogMessage (myPhong.ambient.red)
LogMessage (myPhong.diffuse.Red)
RED, or reD would also work.
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: accessing color in scripts question
Thanks for your inquiries. Didn't even know about the parameters("name") syntax, I'll use that from now on. The other syntax looks like it has a bug, maybe an optimization that went wrong.
softimage resources section updated Jan 5th 2024
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: accessing color in scripts question
Properties and Parameters using the object model as explained here
http://download.autodesk.com/global/doc ... forNovices
set oAmbientRed = myPhong.Properties("ambient").Parameters("Red")
logmessage (oAmbientRed.Value)
Your original problem does not work because your are not asking the value of the parameter "Red"
Try this:
LogMessage(myPhong.Diffuse.Red.Value+","+myPhong.Ambient.Red.Value)
http://download.autodesk.com/global/doc ... forNovices
set oAmbientRed = myPhong.Properties("ambient").Parameters("Red")
logmessage (oAmbientRed.Value)
Your original problem does not work because your are not asking the value of the parameter "Red"
Try this:
LogMessage(myPhong.Diffuse.Red.Value+","+myPhong.Ambient.Red.Value)
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Re: accessing color in scripts question
That's the bug, that doesn't work, it only gives you the value of the first one. Try it
It does work with parameters or nestedobjects, but not directly
It does work with parameters or nestedobjects, but not directly
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
- Daniel Brassard
- Posts: 878
- Joined: 18 Mar 2010, 23:38
- Location: St. Thomas, Ontario
- Contact:
Re: accessing color in scripts question
VBScript is case insensitive so red, Red and reD are the same variable in vbscript
JScript and C# in the other hand are case sensitive so red, Red and reD would be three different variables. This is also true for Python, C and C++.
When you use GetValue your are actually asking the current "Value" of the parameter
So the question is what XSI returning when asking for
LogMessage (myPhong.diffuse.red)
LogMessage (myPhong.ambient.red)
Is it returning the default value, index of the parameter, true/false or a value set elsewhere?
http://download.autodesk.com/global/doc ... r.Red.html
JScript and C# in the other hand are case sensitive so red, Red and reD would be three different variables. This is also true for Python, C and C++.
When you use GetValue your are actually asking the current "Value" of the parameter
So the question is what XSI returning when asking for
LogMessage (myPhong.diffuse.red)
LogMessage (myPhong.ambient.red)
Is it returning the default value, index of the parameter, true/false or a value set elsewhere?
http://download.autodesk.com/global/doc ... r.Red.html
$ifndef "Softimage"
set "Softimage" "true"
$endif
set "Softimage" "true"
$endif
Re: accessing color in scripts question
myPhong.diffuse.red is the parameter object, not the value. I meant to add the .value in the orig question but typed too quickly
When you log a parameter object, the parameter name is printed which is "myPhong.diffuse.red". The bug happens when you do the second log message with ambient. This prints "myPhong.diffuse.red" instead of what it should print ("myPhong.ambient.red")
Similarly when ".value" is added then "logmessage(myPhong.ambient.red.value)" prints the value of myPhong.diffuse.red instead if you accessed ...diffuse.red before. Some caching bug probably where xsi looks at "red" only.
So as Martin found you can work around by using a different case for some letters (it doesn't seem to matter in Jscript even, probably it's accessing the parameter through some kind of COM wrapper)
Am using the ...diffuse.parameter("green") syntax now because it's much less confusing than ...diffuse.gReEn
When you log a parameter object, the parameter name is printed which is "myPhong.diffuse.red". The bug happens when you do the second log message with ambient. This prints "myPhong.diffuse.red" instead of what it should print ("myPhong.ambient.red")
Similarly when ".value" is added then "logmessage(myPhong.ambient.red.value)" prints the value of myPhong.diffuse.red instead if you accessed ...diffuse.red before. Some caching bug probably where xsi looks at "red" only.
So as Martin found you can work around by using a different case for some letters (it doesn't seem to matter in Jscript even, probably it's accessing the parameter through some kind of COM wrapper)
Am using the ...diffuse.parameter("green") syntax now because it's much less confusing than ...diffuse.gReEn
softimage resources section updated Jan 5th 2024
Who is online
Users browsing this forum: No registered users and 16 guests