Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
降低虚引擎4.22的C++时间复杂度_C++_Algorithm_Optimization_Time Complexity - Fatal编程技术网

降低虚引擎4.22的C++时间复杂度

降低虚引擎4.22的C++时间复杂度,c++,algorithm,optimization,time-complexity,C++,Algorithm,Optimization,Time Complexity,我正在开发一个基于光线跟踪的激光雷达传感器。在我的例子中,模拟可以配置为以每秒30帧的速度运行。i、 E1帧以33.34ms的速度运行 目前每秒进行300000次光线跟踪,包括水平和垂直光线跟踪。以每秒30帧的速度,每帧执行10000条光线跟踪。代码如下所示 //call back at the start of frame (just for understanding - not the actual code, data type conversions and some other ba

我正在开发一个基于光线跟踪的激光雷达传感器。在我的例子中,模拟可以配置为以每秒30帧的速度运行。i、 E1帧以33.34ms的速度运行

目前每秒进行300000次光线跟踪,包括水平和垂直光线跟踪。以每秒30帧的速度,每帧执行10000条光线跟踪。代码如下所示

//call back at the start of frame (just for understanding - not the actual code, data type conversions and some other basics are ignored)
uint32 channels = 16;
float vert_angle[] = {15, 13, 11, 9, 7, 5, 3, 1, -1, -3, -5, -7, -9, -11, -13, -15};
float hor_angle_ref = 0;
uint32 points_per_second = 300000;
float rotation_frequency = 10;

/* 300000 points per second is divided into points per frame. 
These points are distributed horizontally and vertically*/
void callback_scan(){
    uint32 poits_to_scan_with_one_laser = points_per_second/ (fps * channels);
    auto hor_angle_covered_this_frame = points_per_second* rotation_frequency * (1/fps);
    auto hor_angle_resolution = hor_angle_covered_this_frame / poits_to_scan_with_one_laser ;
    auto hor_angle = hor_angle_ref ;

    for(auto i= 0u; i< poits_to_scan_with_one_laser ; ++i){
       for(auto ch= 0u; ch< channels; ++ch){
          auto hitPoint = raytrace(hor_angle, vert_angle[ch]);
          // process_data(); -> distance, time and energy are calculated
          /* distance -> Euclidean distance calculation and addition of noise
             time -> c=d/t
             energy -> Pr = Pt*pow(D,2)*nsys*natm*row/ pow(dist,2);*/
       }
       hor_angle += hor_angle_resolution ;
    }
    hor_angle_ref = hor_angle;

}
上面的代码运行得很好。一切都在33.33毫秒的预期时间内完成。现在需要引入效应发散

所用溶液:每个点取8个样品。i、 e 8嵌套for循环内的更多光线跟踪。总共8+1*300000条光线轨迹。此解决方案占用了大量时间,不可能在33毫秒内完成。是否有人可以提出任何其他替代方案来构建代码/算法的体系结构/一种不同的方法,我可以使用这种方法以较少的计算复杂性来实现这一点

其他信息:


虚幻引擎4.22,在GPU上运行

我不知道您使用的引擎,也不知道您试图实现的效果,但除了明显的并行化和GPU之外,我知道有两种主要方法可以加速光线跟踪器:

使用旧的帧/光线,而不是投射更多光线

这通常用于过光、反射、运动模糊和类似效果。。。因此,只需使用最后一帧或多帧的光线,而不是在稍微不同的方向投射更多光线。。。但是,这需要额外的缓冲区来存储所需的最后一帧数据。如果您需要的不仅仅是生成的颜色,那么它可能需要相当大的内存,特别是对于光线跟踪器

使用随机性而不是分割光线

这是非常常见的方法。你们知道当光线击中一个表面时,它应该分为反射光线和折射光线。随机光线跟踪不会分割。相反,根据伪随机值,它以50/50的几率反射或折射。正如您可以看到的,在不进行分割的情况下,场景中要投射的光线要少得多。另一方面,这会产生明显的噪声,类似于低光条件下的旧CCD相机图像。通过对最后几帧进行平均或对同一场景每一帧进行多次光线跟踪,可以部分抑制该效果

这种方法的另一个优点是,它不需要GLSL中未实现的递归,因此可以更轻松地在GLSL中进行光线跟踪。如果没有它,您将需要将递归转换为不简单的迭代。请参见:


此算法已在GPU上运行?是的,此算法已在GPU上运行