Jump to content

Custom importance sampling question


sabotage

Recommended Posts

Hello guys I am trying to implement somekind of structured or wavelet importance sampling. For a start I tried using raydirections with gather function in renderman pro server 14.5 . Anyway the results are always grainy no matter how much samples I use. Can someone help or suggest a solution for an importance sampling via gather if it is possible.

Here is the function I tried first.

computeIsotropicWardDirs(float samples, alpha;
                         vector I; normal Ns; vector dPdu, dPdv;
                       output vector raydirs[1024]; ) // results
{

    vector ndir = vector(Ns), udir = normalize(dPdu), vdir;
    vector In = normalize(I), IinPlane, hdir;
    uniform float s;
    float delta, phi, r; // (delta is angle from the "up" axis)
    float u, v, n;

    // Create an orthonormal basis
    udir = udir - (Ns.udir) * Ns; // project udir onto plane perp. to normal
    normalize(udir);
    vdir = Ns ^ udir;

    // Compute directions
    for (s = 0; s < samples; s += 1) {
        // Compute (delta,phi) specifying the half vector h
        delta = atan(alpha * sqrt(-log(random())));
        phi = 2 * 3.141592 * random();

        // Compute half vector h
        n = cos(delta);
        r = sin(delta);
        u = r * cos(phi);
        v = r * sin(phi);
        hdir = u * udir + v * vdir + n * ndir;

    // Convert to a reflection direction
        raydirs[s] = reflect(In, hdir);
    }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...