VPP  0.7
A high-level modern C++ API for Vulkan
vppLangFunctions.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
29 // -----------------------------------------------------------------------------
31 namespace vpp {
32 // -----------------------------------------------------------------------------
33 
42 Float Round ( const Float& x );
43 Vec2 Round ( const Vec2& x );
44 Vec3 Round ( const Vec3& x );
45 Vec4 Round ( const Vec4& x );
47 Double Round ( const Double& x );
48 DVec2 Round ( const DVec2& x );
49 DVec3 Round ( const DVec3& x );
50 DVec4 Round ( const DVec4& x );
52 // -----------------------------------------------------------------------------
53 
60 Float RoundEven ( const Float& x );
61 Vec2 RoundEven ( const Vec2& x );
62 Vec3 RoundEven ( const Vec3& x );
63 Vec4 RoundEven ( const Vec4& x );
65 Double RoundEven ( const Double& x );
66 DVec2 RoundEven ( const DVec2& x );
67 DVec3 RoundEven ( const DVec3& x );
68 DVec4 RoundEven ( const DVec4& x );
70 // -----------------------------------------------------------------------------
71 
77 Float Trunc ( const Float& x );
78 Vec2 Trunc ( const Vec2& x );
79 Vec3 Trunc ( const Vec3& x );
80 Vec4 Trunc ( const Vec4& x );
82 Double Trunc ( const Double& x );
83 DVec2 Trunc ( const DVec2& x );
84 DVec3 Trunc ( const DVec3& x );
85 DVec4 Trunc ( const DVec4& x );
87 // -----------------------------------------------------------------------------
88 
93 Int Abs ( const Int& x );
94 IVec2 Abs ( const IVec2& x );
95 IVec3 Abs ( const IVec3& x );
96 IVec4 Abs ( const IVec4& x );
98 Float Abs ( const Float& x );
99 Vec2 Abs ( const Vec2& x );
100 Vec3 Abs ( const Vec3& x );
101 Vec4 Abs ( const Vec4& x );
103 Double Abs ( const Double& x );
104 DVec2 Abs ( const DVec2& x );
105 DVec3 Abs ( const DVec3& x );
106 DVec4 Abs ( const DVec4& x );
108 // -----------------------------------------------------------------------------
109 
114 Int Sign ( const Int& x );
115 IVec2 Sign ( const IVec2& x );
116 IVec3 Sign ( const IVec3& x );
117 IVec4 Sign ( const IVec4& x );
119 Float Sign ( const Float& x );
120 Vec2 Sign ( const Vec2& x );
121 Vec3 Sign ( const Vec3& x );
122 Vec4 Sign ( const Vec4& x );
124 Double Sign ( const Double& x );
125 DVec2 Sign ( const DVec2& x );
126 DVec3 Sign ( const DVec3& x );
127 DVec4 Sign ( const DVec4& x );
129 // -----------------------------------------------------------------------------
130 
135 Float Floor ( const Float& x );
136 Vec2 Floor ( const Vec2& x );
137 Vec3 Floor ( const Vec3& x );
138 Vec4 Floor ( const Vec4& x );
140 Double Floor ( const Double& x );
141 DVec2 Floor ( const DVec2& x );
142 DVec3 Floor ( const DVec3& x );
143 DVec4 Floor ( const DVec4& x );
145 // -----------------------------------------------------------------------------
146 
151 Float Ceil ( const Float& x );
152 Vec2 Ceil ( const Vec2& x );
153 Vec3 Ceil ( const Vec3& x );
154 Vec4 Ceil ( const Vec4& x );
156 Double Ceil ( const Double& x );
157 DVec2 Ceil ( const DVec2& x );
158 DVec3 Ceil ( const DVec3& x );
159 DVec4 Ceil ( const DVec4& x );
161 // -----------------------------------------------------------------------------
162 
167 Float Fract ( const Float& x );
168 Vec2 Fract ( const Vec2& x );
169 Vec3 Fract ( const Vec3& x );
170 Vec4 Fract ( const Vec4& x );
172 Double Fract ( const Double& x );
173 DVec2 Fract ( const DVec2& x );
174 DVec3 Fract ( const DVec3& x );
175 DVec4 Fract ( const DVec4& x );
177 // -----------------------------------------------------------------------------
178 
183 Float Radians ( const Float& x );
184 Vec2 Radians ( const Vec2& x );
185 Vec3 Radians ( const Vec3& x );
186 Vec4 Radians ( const Vec4& x );
188 // -----------------------------------------------------------------------------
189 
194 Float Degrees ( const Float& x );
195 Vec2 Degrees ( const Vec2& x );
196 Vec3 Degrees ( const Vec3& x );
197 Vec4 Degrees ( const Vec4& x );
199 // -----------------------------------------------------------------------------
200 
205 Float Sin ( const Float& x );
206 Vec2 Sin ( const Vec2& x );
207 Vec3 Sin ( const Vec3& x );
208 Vec4 Sin ( const Vec4& x );
210 // -----------------------------------------------------------------------------
211 
216 Float Cos ( const Float& x );
217 Vec2 Cos ( const Vec2& x );
218 Vec3 Cos ( const Vec3& x );
219 Vec4 Cos ( const Vec4& x );
221 // -----------------------------------------------------------------------------
222 
227 Float Tan ( const Float& x );
228 Vec2 Tan ( const Vec2& x );
229 Vec3 Tan ( const Vec3& x );
230 Vec4 Tan ( const Vec4& x );
232 // -----------------------------------------------------------------------------
233 
240 Float Asin ( const Float& x );
241 Vec2 Asin ( const Vec2& x );
242 Vec3 Asin ( const Vec3& x );
243 Vec4 Asin ( const Vec4& x );
245 // -----------------------------------------------------------------------------
246 
253 Float Acos ( const Float& x );
254 Vec2 Acos ( const Vec2& x );
255 Vec3 Acos ( const Vec3& x );
256 Vec4 Acos ( const Vec4& x );
258 // -----------------------------------------------------------------------------
259 
265 Float Atan ( const Float& x );
266 Vec2 Atan ( const Vec2& x );
267 Vec3 Atan ( const Vec3& x );
268 Vec4 Atan ( const Vec4& x );
270 // -----------------------------------------------------------------------------
271 
276 Float Sinh ( const Float& x );
277 Vec2 Sinh ( const Vec2& x );
278 Vec3 Sinh ( const Vec3& x );
279 Vec4 Sinh ( const Vec4& x );
281 // -----------------------------------------------------------------------------
282 
287 Float Cosh ( const Float& x );
288 Vec2 Cosh ( const Vec2& x );
289 Vec3 Cosh ( const Vec3& x );
290 Vec4 Cosh ( const Vec4& x );
292 // -----------------------------------------------------------------------------
293 
298 Float Tanh ( const Float& x );
299 Vec2 Tanh ( const Vec2& x );
300 Vec3 Tanh ( const Vec3& x );
301 Vec4 Tanh ( const Vec4& x );
303 // -----------------------------------------------------------------------------
304 
311 Float Asinh ( const Float& x );
312 Vec2 Asinh ( const Vec2& x );
313 Vec3 Asinh ( const Vec3& x );
314 Vec4 Asinh ( const Vec4& x );
316 // -----------------------------------------------------------------------------
317 
324 Float Acosh ( const Float& x );
325 Vec2 Acosh ( const Vec2& x );
326 Vec3 Acosh ( const Vec3& x );
327 Vec4 Acosh ( const Vec4& x );
329 // -----------------------------------------------------------------------------
330 
337 Float Atanh ( const Float& x );
338 Vec2 Atanh ( const Vec2& x );
339 Vec3 Atanh ( const Vec3& x );
340 Vec4 Atanh ( const Vec4& x );
342 // -----------------------------------------------------------------------------
343 
353 Float Atan2 ( const Float& y, const Float& x );
354 Vec2 Atan2 ( const Vec2& y, const Vec2& x );
355 Vec3 Atan2 ( const Vec3& y, const Vec3& x );
356 Vec4 Atan2 ( const Vec4& y, const Vec4& x );
358 // -----------------------------------------------------------------------------
359 
366 Float Pow ( const Float& x, const Float& y );
367 Vec2 Pow ( const Vec2& x, const Vec2& y );
368 Vec3 Pow ( const Vec3& x, const Vec3& y );
369 Vec4 Pow ( const Vec4& x, const Vec4& y );
371 // -----------------------------------------------------------------------------
372 
377 Float Exp ( const Float& x );
378 Vec2 Exp ( const Vec2& x );
379 Vec3 Exp ( const Vec3& x );
380 Vec4 Exp ( const Vec4& x );
382 // -----------------------------------------------------------------------------
383 
390 Float Log ( const Float& x );
391 Vec2 Log ( const Vec2& x );
392 Vec3 Log ( const Vec3& x );
393 Vec4 Log ( const Vec4& x );
395 // -----------------------------------------------------------------------------
396 
401 Float Exp2 ( const Float& x );
402 Vec2 Exp2 ( const Vec2& x );
403 Vec3 Exp2 ( const Vec3& x );
404 Vec4 Exp2 ( const Vec4& x );
406 // -----------------------------------------------------------------------------
407 
414 Float Log2 ( const Float& x );
415 Vec2 Log2 ( const Vec2& x );
416 Vec3 Log2 ( const Vec3& x );
417 Vec4 Log2 ( const Vec4& x );
419 // -----------------------------------------------------------------------------
420 
427 Float Sqrt ( const Float& x );
428 Vec2 Sqrt ( const Vec2& x );
429 Vec3 Sqrt ( const Vec3& x );
430 Vec4 Sqrt ( const Vec4& x );
432 Double Sqrt ( const Double& x );
433 DVec2 Sqrt ( const DVec2& x );
434 DVec3 Sqrt ( const DVec3& x );
435 DVec4 Sqrt ( const DVec4& x );
437 // -----------------------------------------------------------------------------
438 
445 Float InverseSqrt ( const Float& x );
446 Vec2 InverseSqrt ( const Vec2& x );
447 Vec3 InverseSqrt ( const Vec3& x );
448 Vec4 InverseSqrt ( const Vec4& x );
450 Double InverseSqrt ( const Double& value );
451 DVec2 InverseSqrt ( const DVec2& value );
452 DVec3 InverseSqrt ( const DVec3& value );
453 DVec4 InverseSqrt ( const DVec4& value );
455 // -----------------------------------------------------------------------------
456 
461 Float Determinant ( const Mat2& x );
462 Float Determinant ( const Mat3& x );
463 Float Determinant ( const Mat4& x );
465 Double Determinant ( const DMat2& x );
466 Double Determinant ( const DMat3& x );
467 Double Determinant ( const DMat4& x );
469 // -----------------------------------------------------------------------------
470 
478 Mat2 MatrixInverse ( const Mat2& x );
479 Mat3 MatrixInverse ( const Mat3& x );
480 Mat4 MatrixInverse ( const Mat4& x );
482 DMat2 MatrixInverse ( const DMat2& x );
483 DMat3 MatrixInverse ( const DMat3& x );
484 DMat4 MatrixInverse ( const DMat4& x );
486 // -----------------------------------------------------------------------------
487 
492 template< typename ScalarT, size_t COLS, size_t ROWS >
493 Matrix< ScalarT, ROWS, COLS > Transpose ( const Matrix< ScalarT, COLS, ROWS >& value );
494 
495 // -----------------------------------------------------------------------------
496 
503 Int Min ( const Int& x, const Int& y );
504 IVec2 Min ( const IVec2& x, const IVec2& y );
505 IVec3 Min ( const IVec3& x, const IVec3& y );
506 IVec4 Min ( const IVec4& x, const IVec4& y );
508 UInt Min ( const UInt& x, const UInt& y );
509 UVec2 Min ( const UVec2& x, const UVec2& y );
510 UVec3 Min ( const UVec3& x, const UVec3& y );
511 UVec4 Min ( const UVec4& x, const UVec4& y );
513 Float Min ( const Float& x, const Float& y );
514 Vec2 Min ( const Vec2& x, const Vec2& y );
515 Vec3 Min ( const Vec3& x, const Vec3& y );
516 Vec4 Min ( const Vec4& x, const Vec4& y );
518 Double Min ( const Double& x, const Double& y );
519 DVec2 Min ( const DVec2& x, const DVec2& y );
520 DVec3 Min ( const DVec3& x, const DVec3& y );
521 DVec4 Min ( const DVec4& x, const DVec4& y );
523 // -----------------------------------------------------------------------------
524 
531 Int Max ( const Int& x, const Int& y );
532 IVec2 Max ( const IVec2& x, const IVec2& y );
533 IVec3 Max ( const IVec3& x, const IVec3& y );
534 IVec4 Max ( const IVec4& x, const IVec4& y );
536 UInt Max ( const UInt& x, const UInt& y );
537 UVec2 Max ( const UVec2& x, const UVec2& y );
538 UVec3 Max ( const UVec3& x, const UVec3& y );
539 UVec4 Max ( const UVec4& x, const UVec4& y );
541 Float Max ( const Float& x, const Float& y );
542 Vec2 Max ( const Vec2& x, const Vec2& y );
543 Vec3 Max ( const Vec3& x, const Vec3& y );
544 Vec4 Max ( const Vec4& x, const Vec4& y );
546 Double Max ( const Double& x, const Double& y );
547 DVec2 Max ( const DVec2& x, const DVec2& y );
548 DVec3 Max ( const DVec3& x, const DVec3& y );
549 DVec4 Max ( const DVec4& x, const DVec4& y );
551 // -----------------------------------------------------------------------------
552 
559 Int Clamp ( const Int& x, const Int& minVal, const Int& maxVal );
560 IVec2 Clamp ( const IVec2& x, const IVec2& minVal, const IVec2& maxVal );
561 IVec3 Clamp ( const IVec3& x, const IVec3& minVal, const IVec3& maxVal );
562 IVec4 Clamp ( const IVec4& x, const IVec4& minVal, const IVec4& maxVal );
564 UInt Clamp ( const UInt& x, const UInt& minVal, const UInt& maxVal );
565 UVec2 Clamp ( const UVec2& x, const UVec2& minVal, const UVec2& maxVal );
566 UVec3 Clamp ( const UVec3& x, const UVec3& minVal, const UVec3& maxVal );
567 UVec4 Clamp ( const UVec4& x, const UVec4& minVal, const UVec4& maxVal );
569 Float Clamp ( const Float& x, const Float& minVal, const Float& maxVal );
570 Vec2 Clamp ( const Vec2& x, const Vec2& minVal, const Vec2& maxVal );
571 Vec3 Clamp ( const Vec3& x, const Vec3& minVal, const Vec3& maxVal );
572 Vec4 Clamp ( const Vec4& x, const Vec4& minVal, const Vec4& maxVal );
574 Double Clamp ( const Double& x, const Double& minVal, const Double& maxVal );
575 DVec2 Clamp ( const DVec2& x, const DVec2& minVal, const DVec2& maxVal );
576 DVec3 Clamp ( const DVec3& x, const DVec3& minVal, const DVec3& maxVal );
577 DVec4 Clamp ( const DVec4& x, const DVec4& minVal, const DVec4& maxVal );
579 // -----------------------------------------------------------------------------
580 
585 Float Mix ( const Float& x, const Float& y, const Float& a );
586 Vec2 Mix ( const Vec2& x, const Vec2& y, const Vec2& a );
587 Vec3 Mix ( const Vec3& x, const Vec3& y, const Vec3& a );
588 Vec4 Mix ( const Vec4& x, const Vec4& y, const Vec4& a );
590 Double Mix ( const Double& x, const Double& y, const Double& a );
591 DVec2 Mix ( const DVec2& x, const DVec2& y, const DVec2& a );
592 DVec3 Mix ( const DVec3& x, const DVec3& y, const DVec3& a );
593 DVec4 Mix ( const DVec4& x, const DVec4& y, const DVec4& a );
595 // -----------------------------------------------------------------------------
596 
601 Float Step ( const Float& edge, const Float& x );
602 Vec2 Step ( const Vec2& edge, const Vec2& x );
603 Vec3 Step ( const Vec3& edge, const Vec3& x );
604 Vec4 Step ( const Vec4& edge, const Vec4& x );
606 Double Step ( const Double& edge, const Double& x );
607 DVec2 Step ( const DVec2& edge, const DVec2& x );
608 DVec3 Step ( const DVec3& edge, const DVec3& x );
609 DVec4 Step ( const DVec4& edge, const DVec4& x );
611 // -----------------------------------------------------------------------------
612 
623 Float SmoothStep ( const Float& edge0, const Float& edge1, const Float& x );
624 Vec2 SmoothStep ( const Vec2& edge0, const Vec2& edge1, const Vec2& x );
625 Vec3 SmoothStep ( const Vec3& edge0, const Vec3& edge1, const Vec3& x );
626 Vec4 SmoothStep ( const Vec4& edge0, const Vec4& edge1, const Vec4& x );
628 Double SmoothStep ( const Double& edge0, const Double& edge1, const Double& x );
629 DVec2 SmoothStep ( const DVec2& edge0, const DVec2& edge1, const DVec2& x );
630 DVec3 SmoothStep ( const DVec3& edge0, const DVec3& edge1, const DVec3& x );
631 DVec4 SmoothStep ( const DVec4& edge0, const DVec4& edge1, const DVec4& x );
633 // -----------------------------------------------------------------------------
634 
639 Float Fma ( const Float& edge0, const Float& edge1, const Float& x );
640 Vec2 Fma ( const Vec2& edge0, const Vec2& edge1, const Vec2& x );
641 Vec3 Fma ( const Vec3& edge0, const Vec3& edge1, const Vec3& x );
642 Vec4 Fma ( const Vec4& edge0, const Vec4& edge1, const Vec4& x );
644 Double Fma ( const Double& a, const Double& b, const Double& c );
645 DVec2 Fma ( const DVec2& a, const DVec2& b, const DVec2& c );
646 DVec3 Fma ( const DVec3& a, const DVec3& b, const DVec3& c );
647 DVec4 Fma ( const DVec4& a, const DVec4& b, const DVec4& c );
649 // -----------------------------------------------------------------------------
650 
665 UInt PackSnorm4x8 ( const Vec4& v );
666 
681 UInt PackUnorm4x8 ( const Vec4& v );
682 
697 UInt PackSnorm2x16 ( const Vec2& v );
698 
713 UInt PackUnorm2x16 ( const Vec2& v );
714 
723 UInt PackHalf2x16 ( const Vec2& v );
724 
736 Double PackDouble2x32 ( const UVec2& v );
737 
752 Vec2 UnpackSnorm2x16 ( const UInt& p );
753 
767 Vec2 UnpackUnorm2x16 ( const UInt& p );
768 
781 Vec2 UnpackHalf2x16 ( const UInt& v );
782 
796 Vec4 UnpackSnorm4x8 ( const UInt& p );
797 
811 Vec4 UnpackUnorm4x8 ( const UInt& p );
812 
821 UVec2 UnpackDouble2x32 ( const Double& value );
822 
823 // -----------------------------------------------------------------------------
828 Float Dot ( const Vec2& lhs, const Vec2& rhs );
829 Float Dot ( const Vec3& lhs, const Vec3& rhs );
830 Float Dot ( const Vec4& lhs, const Vec4& rhs );
832 Double Dot ( const DVec2& lhs, const DVec2& rhs );
833 Double Dot ( const DVec3& lhs, const DVec3& rhs );
834 Double Dot ( const DVec4& lhs, const DVec4& rhs );
836 // -----------------------------------------------------------------------------
841 template< size_t COLS, size_t ROWS >
842 inline TRMatrix< Float, COLS, ROWS > OuterProduct (
843  const TRVector< Float, ROWS >& lhs,
844  const TRVector< Float, COLS >& rhs );
845 
846 
847 template< size_t COLS, size_t ROWS >
848 inline TRMatrix< Double, COLS, ROWS > OuterProduct (
849  const TRVector< Double, ROWS >& lhs,
850  const TRVector< Double, COLS >& rhs );
852 // -----------------------------------------------------------------------------
857 Float Length ( const Float& value );
858 Float Length ( const Vec2& value );
859 Float Length ( const Vec3& value );
860 Float Length ( const Vec4& value );
862 Double Length ( const Double& value );
863 Double Length ( const DVec2& value );
864 Double Length ( const DVec3& value );
865 Double Length ( const DVec4& value );
867 // -----------------------------------------------------------------------------
872 Float Distance ( const Float& v1, const Float& v2 );
873 Float Distance ( const Vec2& v1, const Vec2& v2 );
874 Float Distance ( const Vec3& v1, const Vec3& v2 );
875 Float Distance ( const Vec4& v1, const Vec4& v2 );
877 Double Distance ( const Double& v1, const Double& v2 );
878 Double Distance ( const DVec2& v1, const DVec2& v2 );
879 Double Distance ( const DVec3& v1, const DVec3& v2 );
880 Double Distance ( const DVec4& v1, const DVec4& v2 );
882 // -----------------------------------------------------------------------------
887 Vec3 Cross ( const Vec3& x, const Vec3& y );
888 DVec3 Cross ( const DVec3& x, const DVec3& y );
890 // -----------------------------------------------------------------------------
895 Float Normalize ( const Float& x );
896 Vec2 Normalize ( const Vec2& x );
897 Vec3 Normalize ( const Vec3& x );
898 Vec4 Normalize ( const Vec4& x );
900 Double Normalize ( const Double& x );
901 DVec2 Normalize ( const DVec2& x );
902 DVec3 Normalize ( const DVec3& x );
903 DVec4 Normalize ( const DVec4& x );
905 // -----------------------------------------------------------------------------
911 Float FaceForward ( const Float& n, const Float& i, const Float& nref );
912 Vec2 FaceForward ( const Vec2& n, const Vec2& i, const Vec2& nref );
913 Vec3 FaceForward ( const Vec3& n, const Vec3& i, const Vec3& nref );
914 Vec4 FaceForward ( const Vec4& n, const Vec4& i, const Vec4& nref );
916 Double FaceForward ( const Double& n, const Double& i, const Double& nref );
917 DVec2 FaceForward ( const DVec2& n, const DVec2& i, const DVec2& nref );
918 DVec3 FaceForward ( const DVec3& n, const DVec3& i, const DVec3& nref );
919 DVec4 FaceForward ( const DVec4& n, const DVec4& i, const DVec4& nref );
921 // -----------------------------------------------------------------------------
934 Float Reflect ( const Float& i, const Float& n );
935 Vec2 Reflect ( const Vec2& i, const Vec2& n );
936 Vec3 Reflect ( const Vec3& i, const Vec3& n );
937 Vec4 Reflect ( const Vec4& i, const Vec4& n );
939 Double Reflect ( const Double& i, const Double& n );
940 DVec2 Reflect ( const DVec2& i, const DVec2& n );
941 DVec3 Reflect ( const DVec3& i, const DVec3& n );
942 DVec4 Reflect ( const DVec4& i, const DVec4& n );
944 // -----------------------------------------------------------------------------
964 Float Refract ( const Float& i, const Float& n, const Float& eta );
965 Vec2 Refract ( const Vec2& i, const Vec2& n, const Float& eta );
966 Vec3 Refract ( const Vec3& i, const Vec3& n, const Float& eta );
967 Vec4 Refract ( const Vec4& i, const Vec4& n, const Float& eta );
969 Double Refract ( const Double& i, const Double& n, const Float& eta );
970 DVec2 Refract ( const DVec2& i, const DVec2& n, const Float& eta );
971 DVec3 Refract ( const DVec3& i, const DVec3& n, const Float& eta );
972 DVec4 Refract ( const DVec4& i, const DVec4& n, const Float& eta );
974 // -----------------------------------------------------------------------------
982 Int FindLsb ( const Int& v );
983 IVec2 FindLsb ( const IVec2& v );
984 IVec3 FindLsb ( const IVec3& v );
985 IVec4 FindLsb ( const IVec4& v );
987 UInt FindLsb ( const UInt& v );
988 UVec2 FindLsb ( const UVec2& v );
989 UVec3 FindLsb ( const UVec3& v );
990 UVec4 FindLsb ( const UVec4& v );
992 // -----------------------------------------------------------------------------
1003 Int FindMsb ( const Int& value );
1004 IVec2 FindMsb ( const IVec2& value );
1005 IVec3 FindMsb ( const IVec3& value );
1006 IVec4 FindMsb ( const IVec4& value );
1008 UInt FindMsb ( const UInt& value );
1009 UVec2 FindMsb ( const UVec2& value );
1010 UVec3 FindMsb ( const UVec3& value );
1011 UVec4 FindMsb ( const UVec4& value );
1013 // -----------------------------------------------------------------------------
1021 Float NMin ( const Float& x, const Float& y );
1022 Vec2 NMin ( const Vec2& x, const Vec2& y );
1023 Vec3 NMin ( const Vec3& x, const Vec3& y );
1024 Vec4 NMin ( const Vec4& x, const Vec4& y );
1026 Double NMin ( const Double& x, const Double& y );
1027 DVec2 NMin ( const DVec2& x, const DVec2& y );
1028 DVec3 NMin ( const DVec3& x, const DVec3& y );
1029 DVec4 NMin ( const DVec4& x, const DVec4& y );
1031 // -----------------------------------------------------------------------------
1039 Float NMax ( const Float& x, const Float& y );
1040 Vec2 NMax ( const Vec2& x, const Vec2& y );
1041 Vec3 NMax ( const Vec3& x, const Vec3& y );
1042 Vec4 NMax ( const Vec4& x, const Vec4& y );
1044 Double NMax ( const Double& x, const Double& y );
1045 DVec2 NMax ( const DVec2& x, const DVec2& y );
1046 DVec3 NMax ( const DVec3& x, const DVec3& y );
1047 DVec4 NMax ( const DVec4& x, const DVec4& y );
1049 // -----------------------------------------------------------------------------
1057 Float NClamp ( const Float& x, const Float& minVal, const Float& maxVal );
1058 Vec2 NClamp ( const Vec2& x, const Vec2& minVal, const Vec2& maxVal );
1059 Vec3 NClamp ( const Vec3& x, const Vec3& minVal, const Vec3& maxVal );
1060 Vec4 NClamp ( const Vec4& x, const Vec4& minVal, const Vec4& maxVal );
1062 Double NClamp ( const Double& x, const Double& minVal, const Double& maxVal );
1063 DVec2 NClamp ( const DVec2& x, const DVec2& minVal, const DVec2& maxVal );
1064 DVec3 NClamp ( const DVec3& x, const DVec3& minVal, const DVec3& maxVal );
1065 DVec4 NClamp ( const DVec4& x, const DVec4& minVal, const DVec4& maxVal );
1067 // -----------------------------------------------------------------------------
1074 Int Mod ( const Int& lhs, const Int& rhs );
1075 IVec2 Mod ( const IVec2& lhs, const IVec2& rhs );
1076 IVec3 Mod ( const IVec3& lhs, const IVec3& rhs );
1077 IVec4 Mod ( const IVec4& lhs, const IVec4& rhs );
1078 IMat2 Mod ( const IMat2& lhs, const IMat2& rhs );
1079 IMat3 Mod ( const IMat3& lhs, const IMat3& rhs );
1080 IMat4 Mod ( const IMat4& lhs, const IMat4& rhs );
1082 UInt Mod ( const UInt& lhs, const UInt& rhs );
1083 UVec2 Mod ( const UVec2& lhs, const UVec2& rhs );
1084 UVec3 Mod ( const UVec3& lhs, const UVec3& rhs );
1085 UVec4 Mod ( const UVec4& lhs, const UVec4& rhs );
1086 UMat2 Mod ( const UMat2& lhs, const UMat2& rhs );
1087 UMat3 Mod ( const UMat3& lhs, const UMat3& rhs );
1088 UMat4 Mod ( const UMat4& lhs, const UMat4& rhs );
1090 Float Mod ( const Float& lhs, const Float& rhs );
1091 Vec2 Mod ( const Vec2& lhs, const Vec2& rhs );
1092 Vec3 Mod ( const Vec3& lhs, const Vec3& rhs );
1093 Vec4 Mod ( const Vec4& lhs, const Vec4& rhs );
1094 Mat2 Mod ( const Mat2& lhs, const Mat2& rhs );
1095 Mat3 Mod ( const Mat3& lhs, const Mat3& rhs );
1096 Mat4 Mod ( const Mat4& lhs, const Mat4& rhs );
1098 Double Mod ( const Double& lhs, const Double& rhs );
1099 DVec2 Mod ( const DVec2& lhs, const DVec2& rhs );
1100 DVec3 Mod ( const DVec3& lhs, const DVec3& rhs );
1101 DVec4 Mod ( const DVec4& lhs, const DVec4& rhs );
1102 DMat2 Mod ( const DMat2& lhs, const DMat2& rhs );
1103 DMat3 Mod ( const DMat3& lhs, const DMat3& rhs );
1104 DMat4 Mod ( const DMat4& lhs, const DMat4& rhs );
1106 // -----------------------------------------------------------------------------
1114 std::pair< Float, Float > Modf ( const Float& x );
1115 std::pair< Vec2, Vec2 > Modf ( const Vec2& x );
1116 std::pair< Vec3, Vec3 > Modf ( const Vec3& x );
1117 std::pair< Vec4, Vec4 > Modf ( const Vec4& x );
1119 std::pair< Double, Double > Modf ( const Double& x );
1120 std::pair< DVec2, DVec2 > Modf ( const DVec2& x );
1121 std::pair< DVec3, DVec3 > Modf ( const DVec3& x );
1122 std::pair< DVec4, DVec4 > Modf ( const DVec4& x );
1124 // -----------------------------------------------------------------------------
1144 Float Ldexp ( const Float& x, const Int& exp );
1145 Vec2 Ldexp ( const Vec2& x, const IVec2& exp );
1146 Vec3 Ldexp ( const Vec3& x, const IVec3& exp );
1147 Vec4 Ldexp ( const Vec4& x, const IVec4& exp );
1149 Double Ldexp ( const Double& x, const Int& exp );
1150 DVec2 Ldexp ( const DVec2& x, const IVec2& exp );
1151 DVec3 Ldexp ( const DVec3& x, const IVec3& exp );
1152 DVec4 Ldexp ( const DVec4& x, const IVec4& exp );
1154 // -----------------------------------------------------------------------------
1175 std::pair< Float, Int > Frexp ( const Float& x );
1176 std::pair< Vec2, IVec2 > Frexp ( const Vec2& x );
1177 std::pair< Vec3, IVec3 > Frexp ( const Vec3& x );
1178 std::pair< Vec4, IVec4 > Frexp ( const Vec4& x );
1180 std::pair< Double, Int > Frexp ( const Double& x );
1181 std::pair< DVec2, IVec2 > Frexp ( const DVec2& x );
1182 std::pair< DVec3, IVec3 > Frexp ( const DVec3& x );
1183 std::pair< DVec4, IVec4 > Frexp ( const DVec4& x );
1185 // -----------------------------------------------------------------------------
1190 Bool IsNaN ( const Float& x );
1191 BVec2 IsNaN ( const Vec2& x );
1192 BVec3 IsNaN ( const Vec3& x );
1193 BVec4 IsNaN ( const Vec4& x );
1195 Bool IsNaN ( const Double& x );
1196 BVec2 IsNaN ( const DVec2& x );
1197 BVec3 IsNaN ( const DVec3& x );
1198 BVec4 IsNaN ( const DVec4& x );
1200 // -----------------------------------------------------------------------------
1205 Bool IsInf ( const Float& value );
1206 BVec2 IsInf ( const Vec2& value );
1207 BVec3 IsInf ( const Vec3& value );
1208 BVec4 IsInf ( const Vec4& value );
1210 Bool IsInf ( const Double& value );
1211 BVec2 IsInf ( const DVec2& value );
1212 BVec3 IsInf ( const DVec3& value );
1213 BVec4 IsInf ( const DVec4& value );
1215 // -----------------------------------------------------------------------------
1220 Bool IsAnyComponentTrue ( const BVec2& v );
1221 Bool IsAnyComponentTrue ( const BVec3& v );
1222 Bool IsAnyComponentTrue ( const BVec4& v );
1224 // -----------------------------------------------------------------------------
1229 Bool IsAllComponentsTrue ( const BVec2& v );
1230 Bool IsAllComponentsTrue ( const BVec3& v );
1231 Bool IsAllComponentsTrue ( const BVec4& v );
1233 // -----------------------------------------------------------------------------
1240 Int BitCount ( const Int& value );
1241 IVec2 BitCount ( const IVec2& value );
1242 IVec3 BitCount ( const IVec3& value );
1243 IVec4 BitCount ( const IVec4& value );
1245 Int BitCount ( const UInt& value );
1246 IVec2 BitCount ( const UVec2& value );
1247 IVec3 BitCount ( const UVec3& value );
1248 IVec4 BitCount ( const UVec4& value );
1250 // -----------------------------------------------------------------------------
1257 Int BitReverse ( const Int& value );
1258 IVec2 BitReverse ( const IVec2& value );
1259 IVec3 BitReverse ( const IVec3& value );
1260 IVec4 BitReverse ( const IVec4& value );
1262 UInt BitReverse ( const UInt& value );
1263 UVec2 BitReverse ( const UVec2& value );
1264 UVec3 BitReverse ( const UVec3& value );
1265 UVec4 BitReverse ( const UVec4& value );
1267 // -----------------------------------------------------------------------------
1268 } // namespace vpp
1269 // -----------------------------------------------------------------------------
UInt PackSnorm4x8(const Vec4 &v)
Converts each component of the signed normalized floating-point value v into 8-bit integer values and...
Float Asin(const Float &x)
Arc sine. Result is an angle, in radians, whose sine is x.
Float NMax(const Float &x, const Float &y)
Result is y if x < y, otherwise result is x.
Float InverseSqrt(const Float &x)
Computes the reciprocal of Sqrt(x).
Int BitReverse(const Int &value)
Counts the number of set bits in specified value.
Float Log(const Float &x)
Computes the natural logarithm of x.
Float Degrees(const Float &x)
Converts radians to degrees.
Float Tan(const Float &x)
The standard trigonometric tangent of x radians.
Vec4 UnpackSnorm4x8(const UInt &p)
Unpacks a single 32-bit unsigned integer p into four 8-bit signed integers and converts them to norma...
Matrix< ScalarT, ROWS, COLS > Transpose(const Matrix< ScalarT, COLS, ROWS > &value)
Computes the transposition of a matrix.
Float Ceil(const Float &x)
Computes nearest whole number that is greater than or equal to x.
Bool IsAnyComponentTrue(const BVec2 &v)
Result is true if any component of the vector is true, otherwise false.
Int FindLsb(const Int &v)
Computes the bit number of the least-significant 1-bit in the binary representation of v...
Int Sign(const Int &x)
Result is 1 if x > 0, 0 if x == 0, or -1 if x < 0.
Float Atanh(const Float &x)
Arc hyperbolic tangent.
Float RoundEven(const Float &x)
Computes nearest whole number to x.
UInt PackUnorm2x16(const Vec2 &v)
Converts each component of the positive normalized floating-point value v into 16-bit integer values ...
Vec4 UnpackUnorm4x8(const UInt &p)
Unpacks a single 32-bit unsigned integer p into four 8-bit unsigned integers and converts them to nor...
Float Fma(const Float &edge0, const Float &edge1, const Float &x)
Computes a * b + c.
Float Length(const Float &value)
Computes the length of a vector.
Float Sinh(const Float &x)
Hyperbolic sine of x radians.
The VPP namespace.
Definition: main.hpp:1
Float Log2(const Float &x)
Computes the base-2 logarithm of x.
Float Step(const Float &edge, const Float &x)
Result is 0 if x < edge. Otherwise result is 1.
UInt PackSnorm2x16(const Vec2 &v)
Converts each component of the signed normalized floating-point value v into 16-bit integer values an...
Float NMin(const Float &x, const Float &y)
Result is y if y < x, otherwise result is x.
Float Atan2(const Float &y, const Float &x)
Arc tangent.
Float Floor(const Float &x)
Computes nearest whole number that is less than or equal to x.
Float Exp2(const Float &x)
Computes 2 raised to the x power (2^x).
Float Reflect(const Float &i, const Float &n)
Computes reflected vector to the vector i.
Float Determinant(const Mat2 &x)
Computes the determinant of x.
Int Min(const Int &x, const Int &y)
Result is y if y < x, otherwise result is x.
Vec2 UnpackHalf2x16(const UInt &v)
Unpacks a 32-bit unsigned integer into a pair of 16-bit values, interpreted as 16-bit floating-point ...
Int Abs(const Int &x)
Result is x if x >= 0. Otherwise result is -x.
Int Mod(const Int &lhs, const Int &rhs)
Modulo operation of lhs modulo rhs.
std::pair< Float, Int > Frexp(const Float &x)
Splits x into a floating-point significand in the range [0.5, 1.0) and an integral exponent of two...
Vec3 Cross(const Vec3 &x, const Vec3 &y)
Computes the cross product of x and y.
Int Max(const Int &x, const Int &y)
Result is y if x < y, otherwise result is x.
Int BitCount(const Int &value)
Reverses the bits in specified value.
Float Acosh(const Float &x)
Arc hyperbolic cosine.
Float Acos(const Float &x)
Arc cosine. Result is an angle, in radians, whose cosine is x.
Bool IsNaN(const Float &x)
Result is true if x is an IEEE NaN, otherwise result is false.
Int FindMsb(const Int &value)
Computes the bit number of the most-significant 1-bit in the binary representation of v...
Float Pow(const Float &x, const Float &y)
Computes x raised to the y power.
Float Ldexp(const Float &x, const Int &exp)
Builds a floating-point number from x and the corresponding integral exponent of two in exp...
Mat2 MatrixInverse(const Mat2 &x)
Computes a matrix that is the inverse of x.
Float Asinh(const Float &x)
Arc hyperbolic sine.
Float FaceForward(const Float &n, const Float &i, const Float &nref)
If the dot product of nref and i is negative, the result is n, otherwise it is -n.
Float Cos(const Float &x)
The standard trigonometric cosine of x radians.
Int Clamp(const Int &x, const Int &minVal, const Int &maxVal)
Computes the value of Min ( Max ( x, minVal ), maxVal ).
UVec2 UnpackDouble2x32(const Double &value)
Computes the two-component unsigned integer vector representation of v. The bit-level representation ...
Float Sqrt(const Float &x)
Computes the square root of x.
Vec2 UnpackSnorm2x16(const UInt &p)
Unpacks a single 32-bit unsigned integer p into a pair of 16-bit signed integers and converts them to...
std::pair< Float, Float > Modf(const Float &x)
Computes the fractional part of x (as the first result) and the whole number part (second result)...
Float Dot(const Vec2 &lhs, const Vec2 &rhs)
Computes dot product of two vectors.
Float Atan(const Float &x)
Arc tangent. Result is an angle, in radians, whose tangent is x. The range of result values is [-pi...
Float Distance(const Float &v1, const Float &v2)
Computes the distance between v1 and v2.
UInt PackHalf2x16(const Vec2 &v)
Converts the components of a two-component floating-point vector to the 16-bit float, then packs them into a 32-bit unsigned integer.
Bool IsInf(const Float &value)
Result is true if x is an IEEE Inf, otherwise result is false.
Float NClamp(const Float &x, const Float &minVal, const Float &maxVal)
Result is min ( max ( x, minVal), maxVal ).
Float Mix(const Float &x, const Float &y, const Float &a)
Computes the linear blend of x and y, i.e., x * (1 - a) + y * a.
Vec2 UnpackUnorm2x16(const UInt &p)
Unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers. and converts them to normalized floating-point values.
Float Tanh(const Float &x)
Hyperbolic tangent of x radians.
Float Round(const Float &x)
Computes nearest whole number to x.
Float Sin(const Float &x)
The standard trigonometric sine of x radians.
Float Fract(const Float &x)
Computes x - Floor(x).
Float Exp(const Float &x)
Computes the natural exponentiation of x (e^x).
TRMatrix< Float, COLS, ROWS > OuterProduct(const TRVector< Float, ROWS > &lhs, const TRVector< Float, COLS > &rhs)
Computes linear-algebraic outer product of two vectors.
Float Trunc(const Float &x)
Computes nearest whole number to x whose absolute value is not larger than the absolute value of x...
Float SmoothStep(const Float &edge0, const Float &edge1, const Float &x)
Result is 0 if x <= edge0, 1 if x >= edge1, or smooth Hermite interpolation between 0 and 1 when edge...
Float Cosh(const Float &x)
Hyperbolic cosine of x radians.
Float Radians(const Float &x)
Converts degrees to radians.
UInt PackUnorm4x8(const Vec4 &v)
Converts each component of the positive normalized floating-point value v into 8-bit integer values a...
Float Refract(const Float &i, const Float &n, const Float &eta)
Computes refracted vector to the vector i.
Float Normalize(const Float &x)
Computes the vector in the same direction as x but with a length of 1.
Double PackDouble2x32(const UVec2 &v)
Packs the components of v into a 64-bit value.
Bool IsAllComponentsTrue(const BVec2 &v)
Result is true if all components of the vector are true, otherwise false.