lynch_ppl Posted December 13, 2006 Share Posted December 13, 2006 I am trying to get a VEX Geometry operator that I wrote and convert it to a shader... For some reason I have a feeling that its the pcopen that is not working. Any help is appreicated. here is a snippet: ( any ideas? ) int pointcloud = pcopen(filename, "P", P, radius, numpoints); while(pciterate(pointcloud)) { float dist; vector col; pcimport(pointcloud, "point.distance", dist); pcimport(pointcloud, "Cd", col); float dd = pow(dist/radius,falloff); dd = smooth(0,1,dd); Cd += col * ( 1 - dd ); } Cf = Cd; Quote Link to comment Share on other sites More sharing options...
doc Posted December 13, 2006 Share Posted December 13, 2006 the first thing that comes to mind is that P in the shading context is in a different space than P in sop space. In the shading context P (0,0,0) is at the camera position. try using the wo_space() function on P. Luca Quote Link to comment Share on other sites More sharing options...
lynch_ppl Posted December 14, 2006 Author Share Posted December 14, 2006 Thanks for that tip Luca, much appreciated. Yet it still does not seem work, yet I kept the wo_space(P) change in there because you are definetly right... I tried upping the search radius with no luck as well... With the print function inside of the while loop, I can see that we never even enter the while loop. I had a print function above the while and that ran fine. I believe the while loop is the problem...yet I cant wrap my head around it because this exact same thing worked fine in sops. here is the whole thing: #pragma hint filename file #pragma hint height hidden surface christmas(string filename=""; export float height = 0; float radius = 1; float falloff = 1; export vector Cd=0) { int numpoints = 10; Cd=0; int pointcloud = pcopen(filename, "P", wo_space(P), 100000000, 100); while(pciterate(pointcloud)) { printf("PRINTME\n"); float dist; vector col; pcimport(pointcloud, "point.distance", dist); pcimport(pointcloud, "Cd", col); float dd = pow(dist/radius,falloff); dd = smooth(0,1,dd); Cd += col * ( 1 - dd ); } Cf = Cd; } Quote Link to comment Share on other sites More sharing options...
B.Walters Posted January 9, 2007 Share Posted January 9, 2007 With the print function inside of the while loop, I can see that we never even enter the while loop. I had a print function above the while and that ran fine. I seem to have the same problem - I can't get point cloud textures to work on anything but Geometry Operators - not Surface Shaders. Perhaps when in shaders, the specified point cloud texture has to be in some specific format? .bgeo, geo, obj? Anybody have any ideas to where we're going wrong? Quote Link to comment Share on other sites More sharing options...
aracid Posted January 9, 2007 Share Posted January 9, 2007 Anybody have any ideas to where we're going wrong? hey there i ran into the same problem, i'd go with doc on that, i was the space change issue heres a file that shows the point cloud on a shader, heres an example of a point cloud shader that works, basically im taking the color from the grid and texturing the teapot with that color. pointCloud_v1.hip hope this helps a bitbrian Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted January 9, 2007 Share Posted January 9, 2007 Yup. Space is a very important "gotcha" when working with point clouds. Just keep the following in mind, and you should be OK (at least as far as spaces is concerned): 1. All built-in and user-defined pointcloud attributes are in object space. This includes the pointcloud's P and N, but also rest, rnml, and any other space-sensitive attribute you may have added yourself (since you likely added them at the SOP level). 2. All globals and parameters to functions (with a few exceptions, like pcopen) in the surface shading context are implicitly in camera space. This includes locally declared constants as well -- i.e: if you write vector v = {0,1,2}; that value is assumed to be in camera space. And if you write illuminance(pp,nn,M_PI/2,...){}, the pp and nn arguments are assumed to be in camera space. This is why, for example, the "P" that you pass to pcopen() has to be converted to object space, and so usually looks like this: pcopen(filename, "P", wo_space(P),...). And also why variables retrieved through pcimport may sometimes need to be converted to world space to be used as arguments to specular(), or illuminance(), or some other built-in function. So, just keep this in mind and ensure that all calculations are done in the same space -- whichever one makes things easier in your specific case: it doesn't matter which, as long as all terms are in the same space. HTH Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.