Jump to content

pcOcclusion Vex to Vops


LaidlawFX

Recommended Posts

So I've been trying to convert the VEX code from the otl pcOcclusion_v01.otl into vops (Thanks a lot to whom created it). It's has a bunch of concepts that I want to learn more about, point clouds, vops, vex, shading, and coding in general. But I need a little help... My hip file is really sad for progress, so if anyone could help me recreate a chunk of the code, esp chunks that contain a while, gather, if and else statement that would be awesome.

Thanks again.

OccVexToVops_01.hip

pcOcclusion_v01.otl

Below is the code produced by the node.

Original_Code()
{
 float outOccl;
 vector outEnvVect;
 float outOcclDelta;
 float outTrueOccl;
 vector vec;

 // Code produced by: pc_occlusion1
 int hndl=pcopen("../ShaderTesterIrradiance.pc", "P", ptransform("space:camera", "space:world", P), 0, 0);
 vector pcP=0;
 vector pcN=0;
 float occl=0;
 vector gatherDir=0;
 vector envVect=0;
 int ok=0;

 while (pcunshaded(hndl, "occl")) {

 ok=pcimport(hndl, "P", pcP);
 ok=pcimport(hndl, "N", pcN);
 pcP=ptransform("space:world", "space:camera", pcP);
 pcN=ntransform("space:world", "space:camera", pcN);

 occl=0;
 envVect=0;
 gather(pcP, pcN, 
 "samples", 256, 
 "angle", 1.57079637,
 "distribution", "cosine",
 "bias", 0.00499999989,
 "raystyle", "global",
 "scope", "*",
 "maxdist", -1,
 "samplebase", 0,
 "ray:direction", gatherDir
 ) {
 occl+=1;
 }
 else {
 envVect+=gatherDir;
 };

 ok=pcexport(hndl, "occl", 1-occl/256);
 ok=pcexport(hndl, "envDir", envVect/256);
 };

 if (1) {

 outOccl=pcfilter(hndl, "occl");
 outEnvVect=pcfilter(hndl, "envDir");
 outOcclDelta=0;
 outTrueOccl=0;

 } else {

 float tmpOccl=0;
 float minOccl=1;
 float maxOccl=0;
 int pCount=0;

 while(pciterate(hndl)) {
 pCount+=1;
 tmpOccl=0;
 ok=pcimport(hndl, "occl", tmpOccl);
 if (tmpOccl>maxOccl) maxOccl=tmpOccl;
 if (tmpOccl<minOccl) minOccl=tmpOccl;
 };

 if ((abs(maxOccl-minOccl)<0.100000001) && pCount>10) {

 outOccl=pcfilter(hndl, "occl");
 outEnvVect=pcfilter(hndl, "envDir");
 outOcclDelta=abs(maxOccl-minOccl);
 outTrueOccl=0;

 } else {

 occl=0;
 envVect=0;
 gather(P, N, 
 "samples", 256, 
 "angle", 1.57079637,
 "distribution", "cosine",
 "bias", 0.00499999989,
 "raystyle", "global",
 "scope", "*",
 "maxdist", -1,
 "samplebase", 0,
 "ray:direction", gatherDir
 ) {
 occl+=1;
 }
 else {
 envVect+=gatherDir;
 };

 outOccl=1-occl/256;
 outEnvVect=envVect/256;
 outTrueOccl=1;
 outOcclDelta=abs(maxOccl-minOccl);

 };

 };

 // Code produced by: floattovec4
 vec = vop_floattovec(outOccl, outOccl, outOccl);

 // Code produced by: surface_output
 vector tempCf = vec;
 Cf = tempCf;
}

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...