如何正确延伸 3Ds Max 材质
基本上,我只是尝试向 3Ds Max 9 中的“标准”材质添加更多属性。实际上,我已经设法通过 max 脚本完成此任务,但它破坏了我们的导出器。
导出器对于使用普通“标准”材质进行蒙皮的任何东西都可以正常工作,但扩展版本似乎对导出器隐藏了基类的属性。
到目前为止我所得到的是:
plugin material Standard_WithOutlines
name:"Standard & Outlines"
classID:#(0x73212413, 0x1ca9e3e6)
extends:Standard replaceUI:false version:1
(
parameters shaderParameters
(
diffuse type:#color
glossiness type:#float
specular type:#color
specularLevel type:#float
selfIllumColor type:#color
selfIllumAmount type:#float
opacity type:#float
on diffuse get val do delegate.diffuse
on glossiness get val do delegate.glossiness / 100.0
on specular get val do delegate.specular
on specularLevel get val do delegate.specularLevel
on selfIllumColor get val do delegate.selfIllumColor
on selfIllumAmount get val do delegate.selfIllumAmount
on opacity get val do delegate.opacity / 100.0
on diffuse set val do delegate.diffuse = val
on glossiness set val do delegate.glossiness = val * 100.0
on specular set val do delegate.specular = val
on specularLevel set val do delegate.specularLevel = val
on selfIllumColor set val do delegate.selfIllumColor = val
on selfIllumAmount set val do delegate.selfIllumAmount = val
on opacity set val do delegate.opacity = val * 100.0
)
parameters MainParams rollout:ExtendedMatRollout
(
ShowOutlining type:#boolean animatable:false default:false ui:outline_Enabled
OutlineColour type:#color animatable:false default:(color 0 0 0) ui:outline_Colour
OutlineThickness type:#float animatable:false default:5 ui:outline_Thickness
)
rollout ExtendedMatRollout "Extended Parameters"
(
groupBox outlinegrp "Outlining" pos:[8,0] width:312 height:62
checkbox outline_Enabled "Enabled" pos:[18,16] width:128 height:16
colorPicker outline_Colour "Colour:" pos:[160,34] width:56 height:20 enabled:ShowOutlining
spinner outline_Thickness "Thickness:" pos:[50,36] width:80 height:16 enabled:ShowOutlining range:[0,100,0]
on outline_Enabled changed state do
(
outline_Colour.enabled = state
outline_Thickness.enabled = state
)
)
)
通过自己声明变量,导出器可以读取它们,但这实际上并没有链接到 UI 设置的值。 为了解决这个问题,我使用“on XXX get/set”事件链接到隐藏的项目。 所以这些现在可以正常工作,但是漫反射和镜面反射等材质贴图不起作用(据我所知,这是对物体进行纹理处理的唯一方法)。
我应该如何将这几个设置添加到材质类型中,以便它也导出“委托”类中的所有数据(基本继承是否要求太多)?
谢谢
Basically, I'm just trying to add a few more properties to the "Standard" material in 3Ds Max 9. I've actually managed to accomplish this through max script, but it is breaking our exporter.
The exporter works fine for anything skinned with the normal "Standard" material, but the extended version seems to hide the base class's properties from the exporter.
What I have so far is this:
plugin material Standard_WithOutlines
name:"Standard & Outlines"
classID:#(0x73212413, 0x1ca9e3e6)
extends:Standard replaceUI:false version:1
(
parameters shaderParameters
(
diffuse type:#color
glossiness type:#float
specular type:#color
specularLevel type:#float
selfIllumColor type:#color
selfIllumAmount type:#float
opacity type:#float
on diffuse get val do delegate.diffuse
on glossiness get val do delegate.glossiness / 100.0
on specular get val do delegate.specular
on specularLevel get val do delegate.specularLevel
on selfIllumColor get val do delegate.selfIllumColor
on selfIllumAmount get val do delegate.selfIllumAmount
on opacity get val do delegate.opacity / 100.0
on diffuse set val do delegate.diffuse = val
on glossiness set val do delegate.glossiness = val * 100.0
on specular set val do delegate.specular = val
on specularLevel set val do delegate.specularLevel = val
on selfIllumColor set val do delegate.selfIllumColor = val
on selfIllumAmount set val do delegate.selfIllumAmount = val
on opacity set val do delegate.opacity = val * 100.0
)
parameters MainParams rollout:ExtendedMatRollout
(
ShowOutlining type:#boolean animatable:false default:false ui:outline_Enabled
OutlineColour type:#color animatable:false default:(color 0 0 0) ui:outline_Colour
OutlineThickness type:#float animatable:false default:5 ui:outline_Thickness
)
rollout ExtendedMatRollout "Extended Parameters"
(
groupBox outlinegrp "Outlining" pos:[8,0] width:312 height:62
checkbox outline_Enabled "Enabled" pos:[18,16] width:128 height:16
colorPicker outline_Colour "Colour:" pos:[160,34] width:56 height:20 enabled:ShowOutlining
spinner outline_Thickness "Thickness:" pos:[50,36] width:80 height:16 enabled:ShowOutlining range:[0,100,0]
on outline_Enabled changed state do
(
outline_Colour.enabled = state
outline_Thickness.enabled = state
)
)
)
By declaring the variables myself, the exporter could read them, but this didn't actually link to the values being set by the UI. To solve that, I used the 'on XXX get/set' events to link to the hidden items. So those now work correctly, but the material maps for things like diffuse and specular don't work (which is the only way to texture the thing AFAIK).
How should I be going about adding these couple of settings to a material type, so that it exports all of the data within the 'delegate' class as well (is basic inheritance too much to ask for)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两种可能性:
您的导出器是否枚举了所有参数块? 我想脚本中的参数最终会出现在一个额外的 pblock 中。 如果您的导出器只查看 pblock 0,这可能是您的问题。
我以前没有见过这种用法,其中参数在脚本和委托中具有相同的名称。 我认为您通常应该在脚本中创建新参数并使用不同的名称适当地分配给委托参数。 至少,我就是这样做的。
Two possiblities:
Does your exporter enumerate all the paramblocks? I imagine that your parameters in the script will end up in an additional pblock. If your exporter just looks at pblock 0 that might be your problem.
I haven't seen this usage before where parameters have the same name in the script and the delegate. I think you typically are supposed to make new parameters in the script and assign to the delegate ones appropriately, using different names. At least, that's how I've done it.
这是一个基本的扩展着色器。
我认为您遇到的问题是您的推出未指定参数。
如果它没有定义,那么你就找不到它们,如果找不到它们,那么导出器就会出错。
Here's a basic extended shader.
I think the problem you have is that your rollout is not specified for the parameters.
If it's not defined, then you cannot find then, if it cannot find them then exporter get's all buggy.