(SDK) Custom material shader and render elements

Hi,

I’ve implemented a material shader similar to vray_MtlDiffuse in the sdk directory and I wanted the newly created shader to support render elements.
In shade(), I did something like this:

VR::Fragment *f=rc.mtlresult.fragment;
if (f) {
	f->setChannelData(renderChannelIndex_color, &rc.mtlresult.color);
}

I’ve noticed that renderChannelIndex_color is from a plugin parameter:
paramList->setParamCache("render_channel_color", &renderChannelPlugin_color);

Then I have the following questions:
1. How do I set the plugin parameter to my shader such that I can get a correct index for the method setChannelData?
2. If I want to make my material support the existing render channels, what is the correct way of doing that?
3. If I create a new render channel plugin, how do I make it support the built-in/custom material shaders?
Thanks!

Best regards,
Gene

Instead of using a fixed channel index, you can use one of the predefined channel aliases. For example, if you want to write to the Refraction render element, you can call Fragment::setChannelDataByAlias(REG_CHAN_VFB_REFRACT, &colorValue).

The list of render channels that you can pass to a shader is only used for the MaterialSelect render element; I’m not sure whether this work with custom shaders - I think so, but I need to check.

Best regards,
Vlado

Hi Vlado,

Thank you for the quick response.
I ended up using Fragment::setChannelDataByAlias with several user-defined channel aliases.

Best regards,
Gene