needs help converting vex code into opencl

   308   3   1
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
int samples = 30;
string lightOP = “../../arealight1”;
matrix lightmat = optransform(lightOP);


for(int s=0; s < samples; s++) {
vector lightCd = chv(lightOP + “/light_color”);


vector sampleP = random(@ptnum, s*123);
sampleP = fit01(sampleP, {-0.5,-0.5,0}, {0.5,0.5,0});


vector lightP = sampleP * lightmat;


vector lightray = lightP - v@P;
vector offset = v@N*0.001;
vector lP, luv;
float lightvis = (intersect(0, v@P+offset, lightray, lP, luv) == -1);
f@lightvis = lightvis;



float geoterm = clamp(dot(v@N, normalize(lightray)), 0, 1);

v@Cd += lightCd * lightvis * geoterm;
}
v@Cd = v@Cd / float(samples);


//END

It's a simple for loop, but I'm still new to opencl, can someone help? thanks
User Avatar
Member
2981 posts
Joined: Sept. 2011
Offline
I don't think you can without making your own ray-tracing solution. There is no ‘intersect’ function built-in to openCL.
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
jsmack
I don't think you can without making your own ray-tracing solution. There is no ‘intersect’ function built-in to openCL.

Oh didn't know though, I intuitively thought whatever is available to VEX is also available to openCL
User Avatar
Member
474 posts
Joined: Sept. 2013
Offline
ouroboros1221
I intuitively thought whatever is available to VEX is also available to openCL

No, I guess it´s quite the opposite.

Please someone prove me wrong, but as far as I know:

  1. No VEX function at all is available in OpenCL.
  2. OpenCL does not come with comparable functions, either.
  3. You have to create all necessary attributes beforehand.
  4. All you can do is manipulate existing attributes.
  5. Everything has to be solved purely mathematically/programmatically.
  6. You cannot delete or create geometry right away.
  • Quick Links