BaseMaterial::Update() not updating editor
-
On 30/01/2013 at 07:27, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14.025
Platform:
Language(s) : C++ ;---------
Is it intended that BaseMaterial::Update() does not update the editor textures? I call this method
from BaseShader:Message() to update the material the shader is attached to because of changes that
do not get pointed out by Cinema. The material itself is updated correctly, but objects that have the
material attached look as the material wasn't updated.-Niklas
-
On 31/01/2013 at 00:04, xxxxxxxx wrote:
Hi Niklas,
Do you call BaseMaterial::Update(Bool preview, Bool rttm) with both preview (preview thumbnail is updated) and rttm (real time texture map of the material will be recalculated) parameters set to TRUE?
-
On 31/01/2013 at 08:01, xxxxxxxx wrote:
Hi Yannick,
Yes, I even tried all possible combinations.
-
On 31/01/2013 at 08:10, xxxxxxxx wrote:
I also noticed, that I need to call BaseMaterial::Message(MSG_CHANGE); after calling ~::Update().
Without, the material isn't updated at all. -
On 19/04/2013 at 09:24, xxxxxxxx wrote:
Hi!
I still have this problem. The material preview is updating properly, but the textures on the objects
do not update and stay as if nothing would have changed. It doesn't even update when I manually
change a parameter in the material.Bool CoreMessage(LONG type, const BaseContainer& msg) { if (type == EVMSG_DOCUMENTRECALCULATED) { BaseDocument* doc = GetActiveDocument(); if (!doc) return FALSE; BaseMaterial* mat = doc->GetFirstMaterial(); while (mat) { if (ShaderLinkCheckUpdateMaterial(mat)) { mat->Update(TRUE, TRUE); mat->Message(MSG_UPDATE); } mat = mat->GetNext(); } } return TRUE; }
I also tried various things from the Script Manager. I can't get the editor textures updated from
a script. Only, for example, adding a new shader manually to the material does the trick.Do I need to use DrawViews() or anything to get them updated as well?Thanks,
-Niklas -
On 22/04/2013 at 03:16, xxxxxxxx wrote:
*bump*
-
On 22/04/2013 at 04:10, xxxxxxxx wrote:
hey,
could you explain what you meant with you cannot get a script to work ? for me on r14.034
these few lines do work as expected. it is obviously for a document where the first material
has a checkboard shader in the color channel.import c4d def main() : mat = doc.GetFirstMaterial() sha = mat[c4d.MATERIAL_COLOR_SHADER] sha[c4d.CHECKERBOARDSHADER_SCALEX] += 2 mat.Update(1,1) c4d.EventAdd() if __name__=='__main__': main()
-
On 22/04/2013 at 04:20, xxxxxxxx wrote:
ok, forget what i have said, the parameter passed to Update() have no influence on
the result of the script, but why don't you send a msg to the basedocument or the
core as those seem to work (at least in python) as i did in those few lines. -
On 22/04/2013 at 04:53, xxxxxxxx wrote:
Hi Ferdinand,
thanks for your answer! Your script works for me. I tried marking my shader as dirty when the
shader it was referencing (being not inserted in the materials shader list) changed. But that didn't
work.EDIT: Yes, it works! After the code I posted abvoe, I had an EventAdd() at the end, which was
necessary because the textures did only reload after one manually dragged in the viewport. But
that seemed to break up the re-rendering of the textures. I don't know why, but it works when
adding the EventAdd() on the next call to CoreMessage() :class ShaderUpdateHook : public MessageData { Bool requireUpdate; public: ShaderUpdateHook() : requireUpdate(FALSE) {} // MessageData Bool CoreMessage(LONG type, const BaseContainer& msg) { if (requireUpdate) { requireUpdate = FALSE; EventAdd(); } if (type == EVMSG_DOCUMENTRECALCULATED) { BaseDocument* doc = GetActiveDocument(); if (!doc) return FALSE; BaseMaterial* mat = doc->GetFirstMaterial(); while (mat) { if (ShaderLinkCheckUpdateMaterial(mat)) { mat->Update(TRUE, TRUE); mat->Message(MSG_UPDATE); requireUpdate = TRUE; } mat = mat->GetNext(); } } return TRUE; } };
Best,
-Niklas