Announcement

Collapse
No announcement yet.

SDK: Writing Specular/Diffuse Informations to render elements

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

  • SDK: Writing Specular/Diffuse Informations to render elements

    Hi,

    I am writing an own small shader to do some basic stuff and have one big problem.. I am calculation the diffuse, specular and ambient color in the eval() method and am returning the combined color.

    That's working fine and looks right, but as soon as I add some render-elements to get a specular pass for example, the result of my material looks wrong in this element.

    But that's right too, because how should VRay know about my specular-values? I am not passing them to VRay anywhere.. only the combined result color.

    So, how can I tell VRay what color to use for the specular-element-pass?

    Thanks,
    Aya

  • #2
    V-Ray will automatically add the diffuse and specular results, but you must check the flags passed to BRDFSampler::eval() for the FBRDF_SPECULAR and FBRDF_DIFFUSE options, and just compute the required component.

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      ah okay, thanks

      And is there a way to write something to an own render-element?
      For example, create a render-element called "Fancy stuff" and have my material put some fancy stuff in there..

      Aya~

      Comment


      • #4
        Yes, you can do that. When you create a V-Ray render element plugin, you need to define an "alias" for it; after that, in the traceForward() method of your BRDF, you can write to this element in the following way:
        Code:
        VR::Fragment *f=(VR::Fragment*) rc.mtlresult.fragment;
        if (f) {
          VR::Color someColor(0.5f, 0.5f, 0.5f);
          f->setChannelDataByAlias(myElementAlias, &someColor);
        }
        Best regards,
        Vlado
        I only act like I know everything, Rogers.

        Comment


        • #5
          Thanks a lot

          One last question... there's an "VRay_SelfIllumination" RenderElement.. how can I write to this one?

          Aya~

          Comment


          • #6
            It should work if, in the code above, you replace "myElementAlias" with "REG_CHAN_VFB_SELFILLUM".

            Best regards,
            Vlado
            I only act like I know everything, Rogers.

            Comment


            • #7
              This is how my traceForward looks now:


              void MyBaseBSDF::traceForward(VR::VRayContext &rc, int doDiffuse)
              {
              VR::Fragment *f = (VR::Fragment*)rc.mtlresult.fragment;
              if (f) {
              VR::Color color(0.5f,0.5f,0.0f);
              f->setChannelDataByAlias(REG_CHAN_VFB_SELFILLUM, &color);
              }
              }
              But it's not working.. the VRay_SelfIllumination is still black
              Do I have to call traceForward myself somewhere?

              Aya~

              Comment


              • #8
                If you put a breakpoint in the code, is it reached?

                Best regards,
                Vlado
                I only act like I know everything, Rogers.

                Comment


                • #9
                  umh, it was my fault.. forgot to assign the material xD

                  But do I need any special default implementation for the traceForward()?
                  Because if I just add the traceForward()-function in my code without anything in it:

                  Code:
                  void MyBaseBSDF::traceForward(VR::VRayContext &rc, int doDiffuse)
                  {
                  }
                  then my material looks a lot lighter (or transparent).. how comes this?

                  Aya~

                  Comment


                  • #10
                    Be sure to call the default implementation BRDFSampler::traceForward() before or after your code.

                    Best regards,
                    Vlado
                    I only act like I know everything, Rogers.

                    Comment


                    • #11
                      Ah okay, it's working now
                      Thansk~

                      Comment

                      Working...
                      X