[Closed] Viewport textures for custom materials
Hello all,
I’m working on implementing a renderer plugin and to accomplish this I’ve implemented the renderer’s native material types as material plugins in max.
Right now I can control how these materials are rendered in the viewport with functions such as Mtl::GetAmbient, Mtl::GetDiffuse, etc, that are part of my plugin Mtl-derived class.
How can I go about getting textures to be displayed in the viewport for my material as well? Looking over the functions in Mtl, I don’t see anything that looks appropriate. I’m not looking to do anything fancy like write a real-time shader to emulate the renderer material, something as simple as setting a diffuse color texture would work great for my needs.
I’ve looked over this a bit and it looks like a simple option for me to just maintain an StdMat2 with the properties I want and use that to handle viewport rendering. I can make this material used for viewport rendering through Mtl::VPDisplaySubMtl.
The problem I’m having with this approach is that the StdMat2 will appear in the slate node editor like any other submaterial, but I want to maintain its state programatically and keep it hidden from the user.
Is there some way to hide a submaterial slot so it isn’t visible? This would solve my problem nicely if possible.
Posting again as I’m not sure I have this resolved but I believe I do now.
After digging around through the sdk documentation, I was able to find this: http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_6105A0AF_BD5F_48E6_A593_188FD160750D_htm
Ok, one more problem I’ve run into while implementing this as suggested in the wiki.
I’ve made my material plugin class derive from both ITextureDisplay and IMaterialViewportShading. It returns itself cast as an appropriate type from the GetInterface calls for these interfaces.
I’ve also implemented both SupportTexDisplay() and SupportMultiMapsInViewport() to return TRUE.
This has opened up the “Show material in viewport” button, but even after pressing it my material’s SetupTextures() function is never called, so the textures don’t appear in the viewport. In addition, my material’s GetInterface() function is never queried for ITEXTURE_DISPLAY_INTERFACE_ID, so it seems Max is not even trying to display the textures. Anyone know what I might be missing?