# a faster ray SOP

## Recommended Posts

Hio, I'm finding that I love love love the ray SOP, but it's too slow.

The Point Wrangle SOP, lovely as it is, is a little opaque to me. I don't have a lot of VEX experience.

But what I think I need is the "rayhittest" function, but I can't seem to get it to work. I get the error "Call to undefined function 'rayhittest'..."

whaaa?

See attached.

reraySOP.hip

##### Share on other sites

AFAIK that function is available for shaders, not in SOPs. I think you will need to use the intersect function.

##### Share on other sites

thanks, sounds good, I'll give it a shot!

##### Share on other sites

Although some functionality is missing, you can try the ray ql sop from qlib, it is faster.

##### Share on other sites

In an effort to learn some VEX I figured out how to use Intersect in a Point Wrangle. It's a bit different than using the same in a VOPSOP where it is very straightforward in my opinion. It got very basic functionality versus the Ray SOP, and it may not be very clean, but I'm sharing my result anyway:

```int hitprim;
int input;
vector pos;
float hitu;
float hitv;
vector dist;
vector lift;
float maxdist;
vector scale;

input = 1; //which input to collide with
dist = @N * 1; //the length of N is distance of the ray, so multiply to increase distance
lift = @N * 0; //the amount to lift after points have been rayed
maxdist = clamp(length(@N), 0, 1); //if you want a max distance
scale = 1; //scale of the operation

i@hitprim = intersect(input, @P, dist * maxdist, v@pos, f@hitu, f@hitv);

@P = (((@pos + lift) - @P)*scale)+@P;
```
##### Share on other sites

nice I'll see if I have some time and maybe can create a simple .otl from it and possibly extend it to also support nearest point/surface

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×