Jump to content

pbr rayswitch


Recommended Posts

  • 11 months later...

I know I am quite late to the party, but I just had to deal with this problem myself and luckily found a solution :) . It works for both PBR and Raytracing (when using the pbrlighting nodes or compute lighting).
It uses some undocumented ray labels that you can import into your shader. Those can be found in pbrlighting.vfl. Always worthwhile to skim through those source files and discover something new.
 

$HFS/houdini/vex/Surface/pbrlighting.vfl    (line 227-237)

if (trace(hitP, hitI, hitTime,
	"SID", path_sid,
	"angle", filter_angle,
	"ray:length", hitLength,
	"Cf", hitLight,
	"Ce", hitEmission,
	"send:diffuselevel", dlevel,
	"send:reflectlevel", rlevel,
	"send:refractlevel", tlevel,
	"send:volumelevel", vlevel,
	"send:pathstate", pathstate))

post-6793-0-18800100-1417185161_thumb.jp

rayswitch.hip

  • Like 1
Link to comment
Share on other sites

This version works even better. This code is used to switch between the different labels:

int pathstate;
string label;

rayimport("pathstate", pathstate);
label = bouncelabel(pathstate);

if (getraylevel() == 0) { ray = 0;} // primary visibility
else if (label == "reflect") { ray = 1;}
else if (label == "refract") { ray = 2;}
else if (label == "diffuse") { ray = 3;}

post-6793-0-47635100-1417188726_thumb.jp

rayswitch_improved.hip

Edited by dennis.albus
  • Like 5
Link to comment
Share on other sites

  • 7 months later...
  • 4 weeks later...

hi there;

 

not so related maybe but I have a question. I have a single object with a ramp lets say as Cd attribute, black to white. its a glass object and has two spheres behind it red and green. Would it be possible to tell to shader to rfract and relect white areas for object 1 only and black areas for object 2.

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