Math for Artists - November 21 - Live from HQ

The laser graphics is just a plane (or ribbon particle) with gradient map on masked glowing material.
You set ribbon’s origin to raycast origin and ribbon end to hit location in world space…

Then you get the hit surface’s normal and do the math he shows to find vector for the next raycast.
I’m pretty sure it’s a For(x) loop, at least in C++ I just run a loop for the amount of rays I want to test.

Oh there’s builtin function in engine for that btw:
https://docs.unrealengine.com/en-US/…tor/index.html

Use case:



for (int32 i=0; i < MyReflectionLimit; i++) {

            const FVector Reflection = FMath::GetReflectionVector( REF_Location, REF_LastHit.ImpactNormal );

            //

            FHitResult REF_Hit;
            if ( RayTrace(Channel, REF_Hit, REF_Location, Reflection, TraceParameters) ) {
                REF_LastHit = REF_Hit;
                REF_Location = REF_LastHit.Normal + REF_LastHit.ImpactPoint;
            }
}




bool RayTrace(const TEnumAsByte<ECollisionChannel> &TraceChannel, FHitResult &Hit, const FVector &Start, const FVector &End, FCollisionQueryParams &Parameters) {

           Hit = FHitResult(ForceInit);
           GetWorld()->LineTraceSingleByChannel(Hit, Start, End, TraceChannel, Parameters);

           return ( Hit.GetActor() != nullptr );
}