Announcement

Collapse
No announcement yet.

(SDK) Custom material shader and render elements

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • (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:
    Code:
    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:
    Code:
    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

  • #2
    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_REFRA CT, &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
    I only act like I know everything, Rogers.

    Comment


    • #3
      Hi Vlado,

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

      Best regards,
      Gene

      Comment

      Working...
      X