It seems not to crash now. I made sure I freed all the bitmaps and flushed all containers.
Posts made by rui_mac
-
RE: Shader crashes when quitting with unfinished IRR
-
Shader crashes when quitting with unfinished IRR
I coded a shader and it is working fine.
However, when I have IRR on and I quit Cinema4D before the IRR finishes rendering, I get a crash. If the IRR finishes and I quit, everything works fine.
What could it be? -
RE: BakeShaderIntoBaseBitmap and Alphas
@i_mazlov
Here is a snippet of my code:BaseShader* shader; shader = (BaseShader*)dat->GetLink(CUBICFACE_BACK_TEXTURE, irs.doc); if (shader != nullptr) { AutoAlloc<BaseBitmap> bitmap; if (bitmap != nullptr) { const IMAGERESULT imageResult = bitmap->Init(quality, quality, 32, INITBITMAPFLAGS::NONE); if (imageResult == IMAGERESULT::OK) { shader->BakeShaderIntoBaseBitmap(*bitmap, *irs.doc, nullptr, true, irs.document_colorprofile, irs.linear_workflow, true, 0, quality-1, 0, quality-1); cfdata.bt_back = BaseBitmap::Alloc(); bitmap->CopyTo(cfdata.bt_back); } } }
However, even if the texture placed in the link CUBICFACE_BACK_TEXTURE is a PNG with trnasparency or a shader that creates an alpha (like Fire or Flame), the resulting bitmap never gets an alpha.
-
RE: SetUniqueIP gets lost
Well, I got lucky, then
As I'm assigning a set of IDs to the objects, using SetUniqueIP inside the InitRender function and I'm being able to read then back inside the Output function, with GetUniqueIP.I mean... my shader is working fine now, and I just need to polish it a bit.
-
RE: BakeShaderIntoBaseBitmap and Alphas
I was able to solve it by reading the alpha directly from the image file.
But I will past my previous code here (the one that was not creating any alpha) as soon as I get home. -
RE: SetUniqueIP gets lost
It work now!! I don't know why it wasn't working but it was surely my mistake.
-
SetUniqueIP gets lost
Let me try to explain what I need/want...
-
Inside the InitRender function I go through all the objects that are affected by the shader (the list of obtained from the VolumeData) and I assign a unique number to each, using SetUniqueIP.
-
Inside the Output function I read the unique number assigned to the object, using GetUniqueIP.
However, I already noticed that the objects that I get inside the Output function are polygonal objects, meaning that it is already a converted version of the original objects that I got in the InitRender function.
So, I guess that is why the UniqueIP gets lost.I also tried, inside the InitRender function, getting the object container, add it a new sub-container with an Int32 data container a unique number and loading back the modified container to the object, but it also seems not to carry over to the converted object.
So, is there any way to store a unique number (an Int32) in an object so that it survives the conversion to polygon that I get in the Output function? -
-
RE: Create a dynamic list of structs or BaseContainers
@spedler said in Create a dynamic list of structs or BaseContainers:
Why not just use a BaseArray of the data structures you want to use? Re-initialise this every time InitRender is called then you can iterate through it when needed (presumably in the Output function?).
You’ll also need to implement CopyTo() to make sure the data is available when rendering to the picture viewer.
Steve
That could be a good option but I need a list to different types of values. I could create an array of structs but I believe the BaseContainer already has everything I need.
If I create the BaseContainer as a public variable inside my plugin shader class, it will be available to the Output function? -
Create a dynamic list of structs or BaseContainers
I need to create a dynamic list of data that will be populated with a variable number of elements, in the InitRender method of a shader.
I need to store a few Float values, an Int32 and a Matrix, so, I can use a struct of a BaseContainer.
Maybe the BaseContainer is the best method as I can add to the BaseContainer another BaseContainer, creating a hierarchy that I can travel through, starting with the parent Container.
What do you guys think? Am I thinking correctly? -
RE: How to know inside a shader what exact object is the shader attached.
Ok, found out what is wrong.
The code inside the Output is being executed in multiple threads.
So, one thread may be calculating the color of one object but the data I have in my struct is from another object being calculated by another thread.
Is there any way to force a shader to be only calculate in a single thread?
Or, is there any way to get a unique value from each object so that I can store a set of structures in the InitRender method, and detect which one is being rendered in the Output method and use the correct structure of data? -
RE: How to know inside a shader what exact object is the shader attached.
I guess I can only make sure I know what is the object being rendered from inside the Output method, as in the InitRender method I can't make sure what is the one being affected.
-
BakeShaderIntoBaseBitmap and Alphas
If I have a PNG file in a Link field of a shader, and I use BakeShaderIntoBaseBitmap to get a bitmap that I can read the RGB and alpha values of the pixels, the internal alpha of the PNG file is ignored.
I mean, I create the bitmap with:AutoAlloc<BaseBitmap> bitmap; if (bitmap != nullptr) { const IMAGERESULT imageResult = bitmap->Init(256, 256, 32, INITBITMAPFLAGS::NONE); if (imageResult == IMAGERESULT::OK) { shader->BakeShaderIntoBaseBitmap(*bitmap, *irs.doc, nullptr, true, irs.document_colorprofile, irs.linear_workflow, true, 0, 255, 0, 255); cfdata.bt_middle = BaseBitmap::Alloc(); bitmap->CopyTo(cfdata.bt_middle); } } }
... I get a bitmap without any alpha channel, even if I Init it with 32 bits and set the doAlpha parameter of the BakeShaderIntoBaseBitmap command to true.
How can I get a bitmap from the Link field of a shader that, if it is an image with alpha (a PNG, or a TIFF, or a TGA), it respects its alpha? -
How to know inside a shader what exact object is the shader attached.
I created a shader that needs to know exactly what object it is attached to.
So, if a material that contains that shader in, for example, the Color channel, is assigned to different objects, it will produce different results.
I know that the VolumeData contains a list of all objects being rendered and that each object in the VolumeData, obtained by GetObj(i) contains a RayObject that contains the texture_link parameter.
But, inside my shader, I get ALL the objects that include the material that contains the shader.
So, from inside the shader, how can I know what is the exact object that is being rendered? -
RE: How to get the number of points in an object?
Thank you very much, Ilia.
I will look into both approaches.
I only have to check it at the begining of the calculations of the shader, so the best way should be to make in the InitRender method, right? That way, all the possibly "slow" stuff only gets calculated once. -
How to get the number of points in an object?
I have this code to check if an object op is a polygonal object and if it is a plane object.
PointObject* polyop; Bool all_ok = false; Bool isPoly = (op->GetType() == Opolygon); if (isPoly) { polyop = static_cast<PointObject*>(op); all_ok = true; } Bool isPlane = op->GetType() == Oplane; if (isPlane) { polyop = ToPoint(op); all_ok = true; } if (all_ok == false) return Vector(0); Int32 pcnt = polyop->GetPointCount(); GePrint(maxon::ToString(pcnt, nullptr, false)); if (pcnt == 4) return Vector(1); ...
If it is a polygonal object, I can easily check the number of points. But if it is a plane, I always get a count of 0 (zero) points, even if I convert the plane into a polygonal object, with ToPoly.
How can I get a polygonal version of the object? -
RE: Is InitRender called once for each frame of a render?
Thank you very much, Ferdinand. I understand.
-
Is InitRender called once for each frame of a render?
When rendering an animation, is the InitRender method of a Shader plugin called just once at the start of the render, or is it called once at the start of each rendered frame?
-
RE: Must I pay $99 each year to develop for Mac?
I will look into it.
But, at least, I can code and build the plugins and test them, without signing, right? -
Must I pay $99 each year to develop for Mac?
I was setting up all that is required to start coding a C++ plugin for Cinema4D.
I installed the SDK, the Project Tool, XCode 12.4 (I'm still in Catalina) and generated the Solution with Project Tool.
I'm following all the steps stated in the Development for macOS page on Maxon. And... must I pay $99 per year, just to create a plugin that I may just want to use for myself? I mean... I don't even know if I will be able to code it in C++ (it has been a long time since I code in C++, as I develop mainly in PYTHON now).
Or, is it possible to create the plugin just for testing and only pay the $99 if I managed to make it work and decide to release the plugin?
Can anyone fill me in on the details? -
RE: Getting UV coordinates from a plane
@i_mazlov
Thank you so much, Ilia.
I would never expect to find those function inside the HairLibrary. I performed a search inside the SDK for "barycenter" or "bary" and I only got some stuff about RayCollider and VolumeData. I guess the GetPolyPointST function will be fine and faster than my calculation.
The s and t roughly correspond to the u and v coordinates?