Recreate the bounces of a light ray but with geometry?

   2613   10   1
User Avatar
Member
403 posts
Joined: June 2015
Offline
I would like to create a polyspline that bounces against other geometry the same way a light ray does. In theory i guess i'd have to do that with for each / loops and a SOP solver to evaluate enough iteration (bounces) before outputting my geo, each evluation checking out the normals of the geometry facing the direction of my first origin point, then checking the next collision object after the 1st bounce, and so on and so on up to my max iteration value. But i'm not quite sure how to practically build that. Anyone please?

Cheers,

A.
Edited by Adriano - May 4, 2018 21:04:13
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
I don't know how to do in Houdini…but I'm sure some guru would..anyway, I did do it in Max MCG…just for a bit of silly refs here are my results:





User Avatar
Member
403 posts
Joined: June 2015
Offline
vusta
I don't know how to do in Houdini…but I'm sure some guru would..anyway, I did do it in Max MCG…just for a bit of silly refs here are my results:




Exactly what i'm after, nice one, Vusta. Unfortunately i've set up my entire scene in Houdini already and it's got so many shaders i don't feel like converting them to Max now, otherwise i'd beg you to share the good stuff with me for a donation you'd most likely take as an offense

But basically i'm trying to set up a scene like this little video (https://vimeo.com/256512922). I'm planning to render only steady cameras so i wnat to render 1 backplate of beauty pass with GI, and then use the same type of bouncy beam you created with the MCG with a taper onto it and a ramp applied to it as well (to fade it out)and then blur it and use it as a mask to reveal the GI pass to fake the dynamic GI coming from that light beams at post… if you understand what i mean. But yeah, i wouldn't know how to create it in Houdini either…nor in Max for that matter Cause for now the set up works with GI on, but the render times are nothig i can afford. So i must find a creative way to cheat. And using that polyspline geo as light source, even without GI (in a RS mesh light for instance since i'm rendering with Redshift) would still give interesting results.

Cheers,

A.
Edited by Adriano - May 5, 2018 02:40:48
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
freeeeeeee

http://www.scriptspot.com/3ds-max/mcg/mcg-dr-evil-laser [www.scriptspot.com]

I did try to extort ppl with my Dr. Evil laser…but no one fell for my dirty tricks
User Avatar
Member
8525 posts
Joined: July 2007
Offline
a simple example in Houdini

Attachments:
ts_sop_laser.hip (99.2 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
403 posts
Joined: June 2015
Offline
vusta
freeeeeeee

http://www.scriptspot.com/3ds-max/mcg/mcg-dr-evil-laser [www.scriptspot.com]

I did try to extort ppl with my Dr. Evil laser…but no one fell for my dirty tricks

Ahaha, i see you went all out on the Dr Evil role there Nice one! Thanks for sharing.

Cheers,

A.
User Avatar
Member
403 posts
Joined: June 2015
Offline
tamte
a simple example in Houdini
man, it feels awesome waking up to that generous gift, Tomas. Can i get an Orange-mocha-frapuccino delivered at Method's to show my gratitude? Cause that's about as happy as i am right now looking at your wrangles.

Thank you.

A.
Edited by Adriano - May 5, 2018 14:00:06

Attachments:
frapuccino.gif (575.6 KB)

User Avatar
Member
403 posts
Joined: June 2015
Offline
tamte
a simple example in Houdini

Thanks again, Tomas, for the file. However after playing around a bit with it i realize it just won't work for my scene. Your set up does exactly what it's supposed to do and that's awesome. But the colliding geometry, my environment is way to detailed, has way too many creases trapping the lasers and sending them into crazy directions from one frame to the other, way too hectic.

Any chance please you could strip your vex code so it just cuts off the laser upon “hit” instead of bouncing it and creating a new point/line please? I'll keep trying to do it myself, but so far i didn't manage. I've been reading about trace, intersect, and more, but couldn't find any practical examples.


The only trick i got is to put a wrangle behind yours that removes points superior to “1” ,

if (@ptnum > 1) removepoint(0, @ptnum);

but it still implies calculating all the bounces before that, so not the fastest/smartest way.
I guess beside the “maxlength” a “max amount of bounces” would be ideal in your wrangle.

I added a copy SOP behind putting sprites at the hit/bounce points, so it behaves like a laser upon impact. I'll keep that in and that will do just fine for this set up.

Thanks either way. If anyone passing by knows how to, please be so kind to show me how.



Cheers,

A.

vector hitP, hituv;

float bias = chf(“bias”);
float maxlength = chf(“maxlength”);
float length = maxlength;
vector P = @P;
vector dir = normalize(v@N);

int prim = addprim(0, “polyline”);
int pt = @ptnum;
addvertex(0, prim, pt);

int hit = 1;
while (hit) {
int hitprim = intersect(1, P + dir*bias, dir*(length-bias), hitP, hituv);
hit = hitprim != -1;
if (hit) {
pt = addpoint(0, hitP);
addvertex(0, prim, pt);
length -= distance(P, hitP);
vector N = normalize(primuv(1, “N”, hitprim, hituv));
dir = reflect(dir, N);
P = hitP;
}
else {
pt = addpoint(0, P + dir*length);
addvertex(0, prim, pt);
}
}
Edited by Adriano - May 6, 2018 20:49:06
User Avatar
Member
8525 posts
Joined: July 2007
Offline
I've added Maxdepth control so you can limit number of bounces, see tne file

or here is the code if you just want to swap it out, you'll still have to create maxdepth slider though
vector hitP, hituv;

float bias = chf("bias");
float maxlength = chf("maxlength");
int maxdepth = chi("maxdepth");
float length = maxlength;
vector P = @P;
vector dir = normalize(v@N);

int prim = addprim(0, "polyline");
int pt = @ptnum;
addvertex(0, prim, pt);

for (int i=0;i<maxdepth;i++) {
    int hitprim = intersect(1, P + dir*bias, dir*(length-bias), hitP, hituv);
    if (hitprim != -1) {
        pt = addpoint(0, hitP);
        addvertex(0, prim, pt);
        length -= distance(P, hitP);
        vector N = normalize(primuv(1, "N", hitprim, hituv));
        dir = reflect(dir, N);
        P = hitP;        
    }
    else {
        pt = addpoint(0, P + dir*length);
        addvertex(0, prim, pt);
        break;
    }
} 

Attachments:
ts_sop_laser2.hip (113.4 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
403 posts
Joined: June 2015
Offline
tamte
I've added Maxdepth control so you can limit number of bounces, see tne file

or here is the code if you just want to swap it out, you'll still have to create maxdepth slider though
vector hitP, hituv;

float bias = chf("bias");
float maxlength = chf("maxlength");
int maxdepth = chi("maxdepth");
float length = maxlength;
vector P = @P;
vector dir = normalize(v@N);

int prim = addprim(0, "polyline");
int pt = @ptnum;
addvertex(0, prim, pt);

for (int i=0;i<maxdepth;i++) {
    int hitprim = intersect(1, P + dir*bias, dir*(length-bias), hitP, hituv);
    if (hitprim != -1) {
        pt = addpoint(0, hitP);
        addvertex(0, prim, pt);
        length -= distance(P, hitP);
        vector N = normalize(primuv(1, "N", hitprim, hituv));
        dir = reflect(dir, N);
        P = hitP;        
    }
    else {
        pt = addpoint(0, P + dir*length);
        addvertex(0, prim, pt);
        break;
    }
} 


Thanks a lot, Tomas. Much appreciated.

Cheers,

A.
User Avatar
Member
403 posts
Joined: June 2015
Offline
Hey Tomas,

In the previous file you sent it was easy to have the Normals of the points of hit/impact oriented to the collision geometry. For some reason now i can't do it anymore. Do you know why perhaps?

Cheers,

A.
  • Quick Links