Hardware accelerated ray-box intersection

バージョン 1.1.0.0 (55.4 KB) 作成者: Thomas Seers
GPU portable implementation of the ray-box intersection method of Smits (1998)
ダウンロード: 553
更新 2015/2/13

ライセンスの表示

% Ray-box intersection algorithm of Smit (1998) formatted for arrayfun to
% allow hardware acceleration:
% Smits, B. (1998). Efficiency issues for ray tracing. Journal of Graphics
% Tools, 3(2):1–14.
% Call with gpuarray and arrayfun to execute on the GPU: this
% may give two orders of magnitude speed up over vectorized
% cpu based implementation

% Ray box intersection is typically used to locate (axis aligned) spatial
% bins (e.g. octree bins / regular grid) to optimise ray-tracing (i.e. by
% reducing the number of potential triangles

% INPUT (scalar):
% orx, ory, orz: xyz componants of the ray origin
% Dx, Dy, Dz: xyz components of the ray directional (unit) vectors
% minx, miny, minz: xyz componants of the box minima
% maxx, maxy, maxz: xyz componants of the box maxima
% OUTPUT (scalar:
% tmin: minimum distance from from the ray-box intersection to the
% origin or nan if no intersection is located
% flag: 1 if intersection / 0 if no intersection

% Usage example:
% Step 1: convert mx3 direction vectors, D = [Dx Dy Dz] to gpuarray object
% >> gD = gpuArray(D);
% Step 2: call rayBoxGPU using arrayfun with scalar input formatting
% where min, max are the nx3 vertex lists of the box min-max corner points
% and where or is the xyz coordinates of the origin
% >> [tmin, flag] = arrayfun(@rayBoxGPU, min(:,1)', min(:,2)', min(:,3)', ...
% max(:,1)', max(:,2)', max(:,3)', ...
% or(:,1), or(:,2), or(:,3), ...
% gD(:,1),gD(:,2),gD(:,3));
% Step 3: recover data
% distmin = gather(tmin);
% flagBox = gather(flag);
% Output is one mxn array containing a the distance from the ray-box
% intersection to the origin or nan if no intersection is located (distmin)
% and one mxn logical containing flags for ray-box intersections.

% Per-ray flags can be obtained from the output tmin using the following
% method:
% >> flagB = true(size(D,1),1);
% >> flagB(sum(isnan(tmin),2) == size(min,1)) = false;
% This may save transfer time off the GPU

% Dependencies: requires Parallel Computing Toolbox
% Based upon the implementation by Jesus P. Mena-Chalco
% Test data (testDataBox.mat) is provided with the package

引用

Thomas Seers (2024). Hardware accelerated ray-box intersection (https://www.mathworks.com/matlabcentral/fileexchange/49671-hardware-accelerated-ray-box-intersection), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2013a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersGPU Computing についてさらに検索
謝辞

ヒントを得たファイル: Ray/box Intersection, RayShapeArticle_FEX.zip

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
バージョン 公開済み リリース ノート
1.1.0.0

Added acknowledgement to Paul Peeling's submission on FEX which the implementation takes from

1.0.0.0