Blender V5.3
gpu_shader_math_matrix_construct.bsl.hh File Reference

Go to the source code of this file.

Functions

Static constructors
float2x2 mat2x2_diagonal (float v)
float3x3 mat3x3_diagonal (float v)
float4x4 mat4x4_diagonal (float v)
float2x2 mat2x2_all (float v)
float3x3 mat3x3_all (float v)
float4x4 mat4x4_all (float v)
float2x2 mat2x2_zero ()
float3x3 mat3x3_zero ()
float4x4 mat4x4_zero ()
float2x2 mat2x2_identity ()
float3x3 mat3x3_identity ()
float4x4 mat4x4_identity ()
Init helpers.
float4x4 from_location (float3 location)
float2x2 from_scale (float2 scale)
float3x3 from_scale (float3 scale)
float4x4 from_scale (float4 scale)
float2x2 from_rotation (AngleRadian rotation)
float3x3 from_rotation (EulerXYZ rotation)
float3x3 from_rotation (Quaternion rotation)
float3x3 from_rotation (AxisAngle rotation)
float3x3 from_rot_scale (EulerXYZ rotation, float3 scale)
float3x3 from_rot_scale (Quaternion rotation, float3 scale)
float3x3 from_rot_scale (AxisAngle rotation, float3 scale)
float4x4 from_loc_rot (float3 location, EulerXYZ rotation)
float4x4 from_loc_rot (float3 location, Quaternion rotation)
float4x4 from_loc_rot (float3 location, AxisAngle rotation)
float4x4 from_loc_rot_scale (float3 location, EulerXYZ rotation, float3 scale)
float4x4 from_loc_rot_scale (float3 location, Quaternion rotation, float3 scale)
float4x4 from_loc_rot_scale (float3 location, AxisAngle rotation, float3 scale)
float2x2 from_direction (float2 direction)
float3x3 from_up_axis (float3 up)
float3x3 from_incident_vector (float3 up, float3 forward)

Function Documentation

◆ from_direction()

float2x2 from_direction ( float2 direction)

Creates a 2D rotation matrix with the angle that the given direction makes with the x axis. Assumes the direction vector is normalized.

Definition at line 305 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_direction(), float2::x, and float2::y.

Referenced by from_direction().

◆ from_incident_vector()

float3x3 from_incident_vector ( float3 up,
float3 forward )

Create a rotation matrix from an up axis, and an incident vector I. The other axes are chosen to always be orthogonal. The resulting matrix is a basis matrix.

Note
forward and up must be normalized.
This can be used to create a tangent basis from a normal vector and a light/view vector.

Definition at line 353 of file gpu_shader_math_matrix_construct.bsl.hh.

References cos_theta(), cross, dot(), from_incident_vector(), from_up_axis(), and normalize.

Referenced by from_incident_vector(), eevee::LTCData::identity(), and eevee::LTCData::sample_ltc_lut().

◆ from_loc_rot() [1/3]

float4x4 from_loc_rot ( float3 location,
AxisAngle rotation )

Create a transform matrix with translation and rotation applied in this order.

Definition at line 266 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_loc_rot(), and from_rotation().

◆ from_loc_rot() [2/3]

float4x4 from_loc_rot ( float3 location,
EulerXYZ rotation )

Create a transform matrix with translation and rotation applied in this order.

Definition at line 248 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_loc_rot(), and from_rotation().

Referenced by from_loc_rot(), from_loc_rot(), from_loc_rot(), gpu_math_test_main(), blender::tests::TEST(), and blender::tests::TEST().

◆ from_loc_rot() [3/3]

float4x4 from_loc_rot ( float3 location,
Quaternion rotation )

Create a transform matrix with translation and rotation applied in this order.

Definition at line 257 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_loc_rot(), and from_rotation().

◆ from_loc_rot_scale() [1/3]

float4x4 from_loc_rot_scale ( float3 location,
AxisAngle rotation,
float3 scale )

Create a transform matrix with translation, rotation and scale applied in this order.

Definition at line 294 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_loc_rot_scale(), from_rot_scale(), and scale().

◆ from_loc_rot_scale() [2/3]

◆ from_loc_rot_scale() [3/3]

float4x4 from_loc_rot_scale ( float3 location,
Quaternion rotation,
float3 scale )

Create a transform matrix with translation, rotation and scale applied in this order.

Definition at line 285 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_loc_rot_scale(), from_rot_scale(), and scale().

◆ from_location()

float4x4 from_location ( float3 location)

Create a translation only matrix. Matrix dimensions should be at least 4 col x 3 row.

Definition at line 81 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_location().

Referenced by from_location(), gpu_math_test_main(), and blender::tests::TEST().

◆ from_rot_scale() [1/3]

float3x3 from_rot_scale ( AxisAngle rotation,
float3 scale )

Create a transform matrix with rotation and scale applied in this order.

Definition at line 240 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_rot_scale(), from_rotation(), from_scale(), and scale().

◆ from_rot_scale() [2/3]

float3x3 from_rot_scale ( EulerXYZ rotation,
float3 scale )

Create a transform matrix with rotation and scale applied in this order.

Definition at line 226 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_rot_scale(), from_rotation(), from_scale(), and scale().

Referenced by from_loc_rot_scale(), from_loc_rot_scale(), from_loc_rot_scale(), from_rot_scale(), from_rot_scale(), from_rot_scale(), and blender::tests::TEST().

◆ from_rot_scale() [3/3]

float3x3 from_rot_scale ( Quaternion rotation,
float3 scale )

Create a transform matrix with rotation and scale applied in this order.

Definition at line 233 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_rot_scale(), from_rotation(), from_scale(), and scale().

◆ from_rotation() [1/4]

◆ from_rotation() [2/4]

float3x3 from_rotation ( AxisAngle rotation)

Create a rotation only matrix.

Definition at line 199 of file gpu_shader_math_matrix_construct.bsl.hh.

References cos, float, from_rotation(), from_scale(), and sin.

◆ from_rotation() [3/4]

float3x3 from_rotation ( EulerXYZ rotation)

Create a rotation only matrix.

Definition at line 134 of file gpu_shader_math_matrix_construct.bsl.hh.

References cos, from_rotation(), and sin.

◆ from_rotation() [4/4]

float3x3 from_rotation ( Quaternion rotation)

Create a rotation only matrix.

Definition at line 164 of file gpu_shader_math_matrix_construct.bsl.hh.

References float, from_rotation(), and M_SQRT2.

◆ from_scale() [1/3]

◆ from_scale() [2/3]

float3x3 from_scale ( float3 scale)

Create a matrix whose diagonal is defined by the given scale vector.

Definition at line 101 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_scale(), and scale().

◆ from_scale() [3/3]

float4x4 from_scale ( float4 scale)

Create a matrix whose diagonal is defined by the given scale vector.

Definition at line 112 of file gpu_shader_math_matrix_construct.bsl.hh.

References from_scale(), and scale().

◆ from_up_axis()

float3x3 from_up_axis ( float3 up)

Create a rotation matrix from 2 basis vectors. The matrix determinant is given to be positive and it can be converted to other rotation types.

Note
forward and up must be normalized. Create a transform matrix with translation and rotation from 2 basis vectors and a translation.
forward and up must be normalized. Create a rotation matrix from only one up axis. The other axes are chosen to always be orthogonal. The resulting matrix is a basis matrix.
up must be normalized.
This can be used to create a tangent basis from a normal vector.
The output of this function is not given to be same across blender version. Prefer using from_orthonormal_axes for more stable output.

Definition at line 333 of file gpu_shader_math_matrix_construct.bsl.hh.

References b, from_up_axis(), square(), float3::x, float3::y, and float3::z.

Referenced by from_incident_vector(), from_up_axis(), eevee::ray_generate_direction(), eevee::shadow_pcf_offset(), eevee::light::shadow_setup_main(), eevee::lightprobe::sphere::sun_extraction(), eevee::lightprobe::sphere::tangent_basis(), blender::tests::TEST(), and eevee::debug::surfels::vert_main().

◆ mat2x2_all()

float2x2 mat2x2_all ( float v)

Definition at line 33 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat2x2_all().

Referenced by mat2x2_all(), and mat2x2_zero().

◆ mat2x2_diagonal()

float2x2 mat2x2_diagonal ( float v)

Definition at line 17 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat2x2_diagonal().

Referenced by mat2x2_diagonal(), and mat2x2_identity().

◆ mat2x2_identity()

float2x2 mat2x2_identity ( )

Definition at line 59 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat2x2_diagonal(), and mat2x2_identity().

Referenced by mat2x2_identity().

◆ mat2x2_zero()

float2x2 mat2x2_zero ( )

Definition at line 46 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat2x2_all(), and mat2x2_zero().

Referenced by mat2x2_zero().

◆ mat3x3_all()

float3x3 mat3x3_all ( float v)

Definition at line 37 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat3x3_all().

Referenced by gpu_math_test_main(), mat3x3_all(), and mat3x3_zero().

◆ mat3x3_diagonal()

float3x3 mat3x3_diagonal ( float v)

◆ mat3x3_identity()

float3x3 mat3x3_identity ( )

Definition at line 63 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat3x3_diagonal(), and mat3x3_identity().

Referenced by jacobi_svd_3x3(), and mat3x3_identity().

◆ mat3x3_zero()

float3x3 mat3x3_zero ( )

Definition at line 50 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat3x3_all(), and mat3x3_zero().

Referenced by mat3x3_zero().

◆ mat4x4_all()

float4x4 mat4x4_all ( float v)

Definition at line 41 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat4x4_all().

Referenced by mat4x4_all(), and mat4x4_zero().

◆ mat4x4_diagonal()

float4x4 mat4x4_diagonal ( float v)

Definition at line 25 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat4x4_diagonal().

Referenced by mat4x4_diagonal(), and mat4x4_identity().

◆ mat4x4_identity()

float4x4 mat4x4_identity ( )

◆ mat4x4_zero()

float4x4 mat4x4_zero ( )

Definition at line 54 of file gpu_shader_math_matrix_construct.bsl.hh.

References mat4x4_all(), and mat4x4_zero().

Referenced by mat4x4_zero().