Jump to content

Point cloud troubles


Recommended Posts

Can anyone see what is wrong with this bit of code?

I think I'm missing something blindingly obvious but I can't see it.

It actually seems to work but when I put it on an animated object the results seem to vary radically from frame to frame, I just can't see why.

#define PI 3.1415926535897932

float shadows(string pcmap;int nfp;float rad,samt;int back)
{
   vector mapP;
   float w,occ;
   int test,pn;
   string channel = "S";
   vector pp = wo_space(P);
   int handle = pcopen(pcmap, "P", pp, rad, nfp);

   while (pcunshaded(handle,channel)) {
      pcimport(handle, "P", mapP);
      pcimport(handle, "width", w);
      
      float shad = 0;
      int lc = 0;
      if (back) {
          illuminance(ow_space(mapP),N,PI) {
            if (rayhittest(ow_space(mapP),L,w+0.05)>0) shad++;
            //if (fastshadow(ow_space(mapP),L,w+0.05)==0) shad++;
            lc ++;
          }
      }
      else {
          illuminance(ow_space(mapP)) {
            if (rayhittest(ow_space(mapP),L,w+0.05)>0) shad++;
            lc ++;
          }
      }
      occ = 1-shad/lc*samt;
      test = pcexport(handle, channel, occ);
   }

    shad = pcfilter(handle,channel);

    pcclose(handle);

    return shad;
}

surface
shadow_cloud(
	string   pcmap  = "";    // pointcloud file
	float    samt   = 0.5;
	int      snfp   = 50;
	float    srad   = 10;
	int  doback = 1;
)
{
	Cf  = shadows(pcmap,snfp,srad,samt,doback);
}

Doh! figured it out, it's just the bias value too high.

Edited by sibarrick
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...