hi all!

after an hour or two of research i couldn’t come up with a solution in hlsl code so: i have a direction unit vector describing the infinite ray which intersects the origin (0,0,0) and i have a normal vector and a position which describes an infinite plane. how can i find the UV coordinate of the intersection point on the plane. (and let’s assume that the origin of the UV space is the position offset of the plane)

thanks in advance!

# Infinite ray intersects with infinite plane

**microdee**#1

**tonfilm**#2

maybe because you should know it from school ;)

```
bool IntersectRayPlane(float3 rayOrigin, float3 rayDirection, float3 posOnPlane, float3 planeNormal, out float3 intersectionPoint)
{
float rDotn = dot(rayDirection, planeNormal);
//parallel to plane or pointing away from plane?
if (rDotn < 0.0000001 )
return false;
float s = dot(planeNormal, (posOnPlane - rayOrigin)) / rDotn;
intersectionPoint = rayOrigin + s * rayDirection;
return true;
}
```

but no, of course i had to search in my shader codes, this is very similar to the Intersect (EX9.Geometry Quad) … if you need the intersection point in UV you have to to some more calculation, which i also would have to look up.

**microdee**#3

yeah probably i missed the lecture about dot product :D

thanks! i will try this tomorrow. i found a solution meanwhile as well but unfortunately that hitted the plane when it was in the opposite direction too.

**antokhio**#4

yea was quite sure it’s a dot hehe

nice gonna upgrade my slicer finnaly hehe ;]

thx tonfilm

**lasal**#6

Hey Microdee,

could you share your code with us?

i have a slicer (on cpu) but this approach seems to be faster ;)

Thanks

**microdee**#7

fake-cubemap-for-dx11 here you go look at FakeCubeUtils.fxh it’s used in deciding which side should be sampled