Skip to content

Commit b30a335

Browse files
authored
Update Readme.md
1 parent fbe24b7 commit b30a335

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Readme.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# HLSL++
55

6-
Small header-only math library for C++ with the same syntax as the hlsl shading language. It features swizzling and all the operators and functions from the [hlsl documentation](https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-reference). The library is aimed mainly at game developers as it's meant to ease the C++ to shader bridge by providing common syntax, but can be used for any application requiring fast, portable math. It also adds some functionality that hlsl doesn't natively provide, such as convenient matrix functions, quaternions and extended vectors such as float8 (8-component float) that take advantage of wide SIMD registers.
6+
Small header-only math library for C++ with the same syntax as the hlsl shading language. It features swizzling and all the operators and functions from the [hlsl documentation](https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-reference). The library is aimed mainly at game developers as it's meant to ease the C++ to shader bridge by providing common syntax, but can be used for any application requiring fast, portable math. It also adds some functionality that hlsl doesn't natively provide, such as convenient matrix functions, quaternions, data packing functions and extended vectors such as float8 (8-component float) that take advantage of wide SIMD registers.
77

88
## Platforms
99

@@ -16,24 +16,45 @@ Small header-only math library for C++ with the same syntax as the hlsl shading
1616
hlsl++ allows you to be as expressive in C++ as when programming in the shader language. Constructs such as the following are possible.
1717

1818
```hlsl
19+
// Native types
1920
float4 foo4 = float4(1, 2, 3, 4);
21+
22+
// Swizzling
2023
float3 bar3 = foo4.xzy;
24+
25+
// HLSL functions
2126
float2 logFoo2 = log(bar3.xz);
27+
28+
// Swizzle of swizzle
2229
foo4.wx = logFoo2.yx;
30+
31+
// Combined constructors
2332
float4 baz4 = float4(logFoo2, foo4.zz);
33+
34+
// Matrices
2435
float4x4 fooMatrix4x4 = float4x4( 1, 2, 3, 4,
2536
5, 6, 7, 8,
2637
8, 7, 6, 5,
2738
4, 3, 2, 1);
39+
40+
// Matrix transformations
2841
float4 myTransformedVector = mul(fooMatrix4x4, baz4);
42+
43+
// Integer operations
2944
int2 ifoo2 = int2(1, 2);
3045
int4 ifoo4 = int4(1, 2, 3, 4) + ifoo2.xyxy;
46+
47+
// Casts
3148
float4 fooCast4 = ifoo4.wwyx;
3249
50+
// Float8
3351
float8 foo8 = float8(1, 2, 3, 4, 5, 6, 7, 8);
3452
float8 bar8 = float8(1, 2, 3, 4, 5, 6, 7, 8);
3553
float8 add8 = foo8 + bar8;
3654
55+
// Data packing
56+
uint rgba8Packed = pack_float4_rgba8_unorm(foo4);
57+
float4 rgba8Unpacked = unpack_rgba8_unorm_float4(rgba8Packed);
3758
```
3859

3960
The natvis files provided for Visual Studio debugging allow you to see both vectors and the result of the swizzling in the debugging window in a programmer-friendly way.
@@ -84,6 +105,7 @@ The only required features are a C++ compiler supporting anonymous unions, and S
84105
* hlsl vector functions: abs, acos, all, any, asin, atan, atan2, ceil, clamp, cos, cosh, cross, degrees, distance, dot, floor, fmod, frac, exp, exp2, isfinite, isinf, isnan, length, lerp, log, log2, log10, max, mad, min, modf, normalize, pow, radians, reflect, refract, round, rsqrt, saturate, sign, sin, sincos, sinh, smoothstep, sqrt, step, trunc, tan, tanh
85106
* Additional matrix functions: determinant, transpose, inverse (not in hlsl but very useful)
86107
* Matrix multiplication for all NxM matrix combinations
108+
* Data packing functions such as pack_float4_rgba8_unorm or pack_float3_rg11b10f
87109
* Transformation matrices for scale, rotation and translation, as well as world-to-view look_at and view-to-projection orthographic/perspective coordinate transformations. These static functions are optionally available for matrix types float2x2, float3x3, float4x4 when hlsl++.h is compiled with HLSLPP_FEATURE_TRANSFORM definition.
88110
* Native visualizers for Visual Studio (.natvis files) which correctly parse with both MSVC and Clang in Windows
89111

0 commit comments

Comments
 (0)