Announcement

Collapse
No announcement yet.

Basic ray tracing examples?

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

  • Basic ray tracing examples?

    Hi,
    Does anyone have a really basic example of ray tracing along arbitrary paths in a vray plugin texture? I looked at the dirt shader example but that seems to rely on a Max include (#include "../../../3dsmax_plugins/common/vraydirt_impl.h") to work and I don't have Max.

    I am just looking for example code which does something like this (in psudocode):

    someData hitValues;
    vector rayOrig;
    vector rayDir;
    bool hit = trace (rayOrig, rayDir, hitValues);

    if (hit)
    {
    vector hit = hitValues.Normal;
    float rayDistance = hitValues.rayDist;
    }


    Could you point me to anything like that?
    Thanks,

    Philip

  • #2
    I'm attaching the vraydirt_impl.h file here; it does not really contain any 3ds Max specific code. It's somewhat more complicated that what you need, but I hope the main points are clear:

    1) You need to create a new ray context out of the existing one using VRayContext::newSpawnContext();
    2) You need to fill in the ray direction etc in the rayparams member of the ray context;
    3) Declare an IntersectionData structure to hold the result of the nearest hit;
    4) Call VRayContext::vray->findIntersection() to get the nearest hit;
    5) Do whatever you need with the intersection;
    6) Potentially call findIntersection() again to find the rest of the hits along the ray;
    7) Release the ray context using VRayContext::releaseContext().

    If you need to trace multiple rays for the same shading point, it will be faster to reuse the same ray context, rather than creating a new one from scratch for each ray.

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

    Comment


    • #3
      Thanks again for a quick reply. That's really helpful.
      One more question - how do I test code changes for material/texture plugins in maya? I seem to have to restart Maya everytime I make a code change otherwise Maya crashes. Is there a way to refresh the plugin to test code changes as I am working on a plugin?
      Thanks

      Comment


      • #4
        If you won't need to change any parameters on your shader/texture you can export a vrscene file and then you can use the V-Ray Standalone, which is quite a lot faster in regards to startup and debugging.

        There is some documentation how to export a vrscene file: http://www.spot3d.com/vray/help/maya...translator.htm
        V-Ray developer

        Comment


        • #5
          You could also try unloading and reloading the V-Ray for Maya plugin itself - it should cause all the V-Ray plugins to be reloaded on the next render.

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

          Comment


          • #6
            Great, I'll try that. Thanks!

            Comment

            Working...
            X