Hardware accelerated ray-box intersection

버전 1.1.0.0 (55.4 KB) 작성자: Thomas
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 (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 CenterMATLAB Answers에서 GPU Computing에 대해 자세히 알아보기

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