SOLVED How to add Layers Shader - C++

Hello,

How to add Layers Shader that contain two layers (Bitmap shader and Hue/Saturation/Lightness effects) with HSL -100 %.

BaseMaterial *Mat = BaseMaterial::Alloc(Mmaterial);
if (!Mat)
	return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);

BaseContainer *Data = Mat->GetDataInstance();
if (!Data)
	return true;

BaseShader* bsXlayer = BaseShader::Alloc(Xlayer);
if (!bsXlayer)
	return false;

Data->SetLink(MATERIAL_ENVIRONMENT_SHADER, bsXlayer);
Mat->InsertShader(bsXlayer);

Thanks.

Hi mfersaoui, thanks for reaching out us.

With regard to your question, whilst it's actually possible to query for the layers belonging to a certain Layer Shader, it's not possible to programmatically add new layers with the current API implementation.

Here you can find an old discussion on the argument.

Best, Riccardo

@r_gigante
Hi Riccardo,
Thank you, I will try to import my material from a scene file.

@r_gigante

I have another question, is it possible to edit the Blur Offset and Blur Scale of shader via c++?

shader-blur.jpg

Thanks.

"Blur Offset" and "Blur Scale" are parameters of the BaseShader class, so you should be able to access these parameters like any other parameter; if in doubt, they should be available in the shader's BaseContainer. See xbase.h.

@s_bach

Thank you.