Announcement

Collapse
No announcement yet.

How to Obtain Surface Tangent at Intersection?

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

  • How to Obtain Surface Tangent at Intersection?

    I am writing a custom hair shader for use with Maya nHair. Among the items I will need for the shading calcs is the hair tangent at the surface intersection. In Renderman Shading Language, this would be in the variable "dPdv", which is the derivative in the v direction at the surface intersection. In Mental Ray, it is contained in the state variable "derivs[0]", which is the interpolated tangent of the hair. I am looking for the equivalent in VRay.

    In the VRayContext, I have access to RayParams and RayResult. In both of these there are attributes for "dPdx" and "dPdy". Which of these (if any) will provide the hair tangent?

    Thanks for your help.

  • #2
    You can obtain a vector along the hair strand like this (please note that the vector may not be of unit length):
    Code:
    		VRayMayaHairDataInterface *dataInterface = (VRayMayaHairDataInterface*)GET_INTERFACE(rc.rayresult.sd, EXT_MAYA_HAIR_DATA);
    		if (dataInterface){
    			dataInterface->getShadeData(rc, data);
    		}
    		else {
    			// used only for tesing
    			Vector u=(rc.rayresult.normal^VR::Vector(0.0f, 0.0f, 1.0f));
    			Vector t=VR::normalize0(u^rc.rayresult.normal);
    			data.hairDirection=t;
    		}
    		Vector hairDir=normalize0(data.hairDirection);
    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      Hi vlado,

      That's excellent! Thank you. This is a great help.

      By the way, I was looking through the VRay for Maya SDK documentation online at the following link: http://www.spot3d.com/vray/help/maya/sdk22/. The descriptions for VRayMayaHairDataInterface that are given in the classes documentation do not match what is contained in the vrayplugins.h file that I have from nightlies. For example, the getShadeData exists in the vrayplugin.h file but not in the online documentation. It would appear that the online documentation is not current.

      Comment


      • #4
        Originally posted by JabbaTheNut View Post
        It would appear that the online documentation is not current.
        That page is based on the current official build. Each nightly build includes its own up-to-date documentation in the vraysdk/docs/classes folder.

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

        Comment

        Working...
        X