Jump to content

How to use point clouds to shade soft falloff points on a surface?


magneto

Recommended Posts

Hi,

 

I was watching Peter Quint's tutorial on using point clouds in shaders but I am having weird results. Even the original files do not render correctly unfortunately. I fixed some issues regarding orientation and rendering the files to disk but still no white patches as shown in the video:

 

xwQwVMs.png

 

http://vimeo.com/9108284

 

This is what I am getting:

 

CmqoBiL.png

 

I attached my simple file. You have to render the point cloud first as the forum doesn't allow me to attach that.

 

I know how to use point clouds but never used them in a shader, and this tutorial is for H10, so I assume some major renderer, shader change have happened that causes the results I am seeing?

 

 

Thanks :)

pcloud_shader.hip

Edited by magneto
Link to comment
Share on other sites

I think you just need to carry on the tutorial :)

 

from around the minute 17, he explains that by using a VOPSOP rather than direct VEX code, there are some difficulties to set the order in which the code will be executed, and that you are actually calling a pciterate before you are using the value you want to use, resulting in out of index data at the end of the point cloud (pciterate move the pointer to the next point as soon as it is called).

He also explains how you can cheat that by introducing a dummy switch node.

 

I just tested it to confirm it was that, by doing so and reducing the search radius, you'll get your expected result.

  • Like 1
Link to comment
Share on other sites

Thanks you are right. It works. I also got it working with pcnumfound which also required the switch trick. I didn't realize you couldn't order operations otherwise. Is there a better way to do this?

 

Lastly I don't understand how In Peter's example he iterates outside the while loop first and then imports P. Shouldn't he first import P out of pcopen and then at the end do a pciterate?

 

Because in his example it looks like this:

success = pciterate
while success
   import(P)
   success = pciterate

Mine looks like this:

success = pcnumfound
while success
   import(P)
   success = pciterate

Am I missing something? Using point clouds in VOPs is not as intuitive as in code :)

 

 

Thanks.

Edited by magneto
Link to comment
Share on other sites

I'm not following the tuto but I quickly scrubed through the timeline and I think he is only using pciterate as a test to trigger the while loop, the same way you are using pcnumfound.

 

With pcnumfound you get a positive result if there are point within your search radius, since it's a non-zero result, you satisfy the condition of the while loop and execute its code : loop through all the points, etc etc

 

Peter get the same positive result to trigger the execution of the while loop, but inside the loop, he is reusing the original handle, where the pointer had not been moved due to the call to pciterate.

 

I might be wrong but this is how I understand it with a quick look.

 

 

edit: typo

Edited by iamyog
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

it's a lot easier to just do:

 

while (pciterate(handle))
{
    pcimport stuff
}

 

no need to check pcnumfound or anything...

 

and iamyog is right, you can't use pcimport functions without first calling pciterate.  i wouldn't be surprised if there was an error message on your console about this.

Link to comment
Share on other sites

  • 2 weeks later...

A belated reply. Since that tutorial was recorded, the new Point Cloud Import by Index VOP node has been added. This allows you to use a for loop instead of a PC iterate, and thus avoid the ordering problem discussed above. You can use PC numfound to determine the range of the for loop. 

 

Peter 

  • Like 1
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...