What I’m doing to make shadows is getting the contour hit points and casting them in a direction, and if that shadow ray collides with an object or something, it’d darken the pixel. But I want to do something else.
iirc Soft shadow algorithm requires the intersect point and the "outer"sect point. Which is why I made this thread.
Just a thought I had. You know the thickness of the object from where you hit it on the ray, you could cast another ray on the other side of the object in the direction of your hit point and give it a whitelist of just that object you care about. That should tell you the exit point for an object… of course with terrain you would need to employ some kind of ray marching technique (maybe someone else has a better idea for this.) Or perhaps using the ReadVoxels method on the Terrain object you could find the other side that way, then use a similar ray in the opposite direction technique.
You could get the part of which it hit (what FindPartOnRay returns first) and add it to a table, then use FindPartOnRayWithIgnoreList using that table.
I’m not certain if this’ll work for Terrain but it should work for BaseParts.
Mathematically:
You know the entry point by the look of it. If you think about it, for a wedge like that (triangle) you’d just have to find the line and you can easily work out the equation of the line and could probably work off of that to get one of the values.
Now to begin with the issue with an answer by Compiler is that he assumed that you’d have the reflected exit point. A ray however should pass straight through. As such you could use pythagoras in 3D in order to calculate the exit position. This can however be really awkward depending on ray angle and position and a lot of the time your probably going to have to work out one of the co-ordinates (usually the x component but can be the y component) where it decides to leave.
Honestly its hard for me to explain without pen, paper and a diagram
First off, thanks for pointing out a potential issue in my thinking. I think I’m misunderstanding what you meant though… let me restate my assumption.
My assumption was that if you extrapolated from your first point of intersect, at a minimum the greatest length from side to side of the object you hit, and used Roblox’s FindPartOnRayWithWhiteList setting its Ray’s start position to the point you’ve extrapolated to in the reverse direction of the initial ray is that you would find exactly the opposite side of the object. I’m not too sure what is incorrect about that assumption. Could you elaborate further?
Reading this it hints at being able to white list and ignore assets (when reading ignore list). What would be most probable is to ignore the first instance maybe? The thing is with using the word extrapolated thats assuming the factors are consistent and that a trend would continue. Also would it not return the rays first point of contact as suggested in the documentation in that it returns the point of intersection and the normal (assuming its the line which is at a tangent to the curve / ray which is basically just perpendicular if its a straight line at point x) - but this shouldnt get you the second intersection.
As such for a triangle 3D pythagoras mathematics should probably be applied (and its relatively easy to accomplish to a point). Might be very awkward though.
My understanding of the whitelist function is that it will only find points of intercept on the objects in the whitelist.
What I’m suggesting the second ray would have a whitelist with only that one object that the first ray intercepted. It doesn’t really matter if you overshoot the extrapolation with this method, you just want to make sure not to undershoot it. I’ll draw a quick picture of what this would look like:
In this picture the red arrow shows the first ray and the blue one shows the second.
The benefit to doing this, I think, is that it works on complex objects without having to get too fancy. The whitelist portion is important because we don’t care about other objects that might block the ray from hitting the first object. I think this works fine.
What happens if this object was terrain? That’s a huge roadblock because then the ENTIRE terrain is one super complex object. Terrain can have tons of ridges and blockage that can obscure this ray.