+ // Calculate z coordinate value in Camera Space.
+ const Matrix& viewMatrix = renderTask.GetCameraActor()->GetViewMatrix();
+ const Vector4& hitDir = Vector4(rayDir.x * distance, rayDir.y * distance, rayDir.z * distance, 0.0f);
+ const float cameraDepthDistance = (viewMatrix * hitDir).z;
+
+ // Check if cameraDepthDistance is between clipping plane
+ if(cameraDepthDistance >= nearClippingPlane && cameraDepthDistance <= farClippingPlane)