[Closed] Issue with custom renderer and material in viewport
Hello all,
I’m working on developing a plugin for a 3ds max renderer and I’ve run into a problem with how my custom materials are being rendered in the viewport.
For testing I have created a very simple material that just contains a diffuse color that it returns through the Mtl::GetDiffuse() function. This color is stored in a paramblock2 and tied to a color swatch in the material editor UI. The material is set up so Mtl::Update() will read the color out of the paramblock for the correct time and store it in a local variable. Mtl::GetDiffuse() returns this variable.
When the default scanline renderer is selected, changes to the color of the material through the material editor are immediately visible in the viewport on any objects that have that material applied.
When I have my new renderer selected, changes in the material editor do not change how the material is displayed in the viewport. Renders still work as expected, so I know the color is being set right in the param block.
After digging a little deeper, it seems that the problem is that my material’s Mtl::Update() is never called when my renderer is selected, but it is for the default renderer.
Anyone have any idea about where I should start looking to debug this? I never wrote any code for the renderer relating to viewport rendering that I recall, so I have no idea where to even begin.
Hi,
It seems to work fine in my case.
Here is my code:
https://github.com/appleseedhq/appleseed-max/blob/master/src/appleseed-stdmtl/appleseedstdmtl.cpp
I haven’t pushed the changes yet, but I have changed GetDiffuse() to return the value of m_base_color and the color changes are properly reflected in the viewport.
Make sure your NotifyRefChanged() method returns REF_SUCCEED to the right messages (mine always return REF_SUCCEED for now).