Blender V5.3
gpu_shader_math_vector_safe.bsl.hh File Reference

Go to the source code of this file.

Functions

template<typename VecT>
VecT safe_mod (VecT a, VecT b)
template float2 safe_mod< float2 > (float2, float2)
template float3 safe_mod< float3 > (float3, float3)
template float4 safe_mod< float4 > (float4, float4)
float2 safe_mod (float2 a, float b)
float3 safe_mod (float3 a, float b)
float4 safe_mod (float4 a, float b)
float2 compatible_mod (float2 a, float b)
float3 compatible_mod (float3 a, float b)
float4 compatible_mod (float4 a, float b)
float2 compatible_mod (float2 a, float2 b)
float3 compatible_mod (float3 a, float3 b)
float4 compatible_mod (float4 a, float4 b)
template<typename VecT>
VecT safe_divide (VecT a, VecT b)
template float2 safe_divide< float2 > (float2, float2)
template float3 safe_divide< float3 > (float3, float3)
template float4 safe_divide< float4 > (float4, float4)
float2 safe_divide (float2 a, float b)
float3 safe_divide (float3 a, float b)
float4 safe_divide (float4 a, float b)
template<typename VecT>
VecT safe_normalize_and_get_length (VecT vector, float &out_length)
template float2 safe_normalize_and_get_length< float2 > (float2, float &)
template float3 safe_normalize_and_get_length< float3 > (float3, float &)
template float4 safe_normalize_and_get_length< float4 > (float4, float &)
template<typename VecT>
VecT safe_normalize (VecT vector)
template float2 safe_normalize< float2 > (float2)
template float3 safe_normalize< float3 > (float3)
template float4 safe_normalize< float4 > (float4)
template<typename VecT>
VecT normalize_fallback (VecT vector, VecT fallback)
template float2 normalize_fallback< float2 > (float2, float2)
template float3 normalize_fallback< float3 > (float3, float3)
template float4 normalize_fallback< float4 > (float4, float4)
template<typename VecT>
VecT safe_rcp (VecT a)
template float2 safe_rcp< float2 > (float2)
template float3 safe_rcp< float3 > (float3)
template float4 safe_rcp< float4 > (float4)
float2 fallback_pow (float2 a, float b, float2 fallback)
float3 fallback_pow (float3 a, float b, float3 fallback)
float4 fallback_pow (float4 a, float b, float4 fallback)
float2 compatible_pow (float2 a, float2 b)
float3 compatible_pow (float3 a, float3 b)
float4 compatible_pow (float4 a, float4 b)
float2 wrap (float2 a, float2 b, float2 c)
float3 wrap (float3 a, float3 b, float3 c)
float4 wrap (float4 a, float4 b, float4 c)

Function Documentation

◆ compatible_mod() [1/6]

float2 compatible_mod ( float2 a,
float b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

Definition at line 42 of file gpu_shader_math_vector_safe.bsl.hh.

References b, compatible_mod(), float2::x, and float2::y.

◆ compatible_mod() [2/6]

float2 compatible_mod ( float2 a,
float2 b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

Definition at line 70 of file gpu_shader_math_vector_safe.bsl.hh.

References b, compatible_mod(), float2::x, and float2::y.

◆ compatible_mod() [3/6]

float3 compatible_mod ( float3 a,
float b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

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

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

◆ compatible_mod() [4/6]

float3 compatible_mod ( float3 a,
float3 b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

Definition at line 78 of file gpu_shader_math_vector_safe.bsl.hh.

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

◆ compatible_mod() [5/6]

float4 compatible_mod ( float4 a,
float b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

Definition at line 58 of file gpu_shader_math_vector_safe.bsl.hh.

References b, compatible_mod(), float4::w, float4::x, float4::y, and float4::z.

◆ compatible_mod() [6/6]

float4 compatible_mod ( float4 a,
float4 b )

A version of mod that behaves similar to C++ std::modf, and is safe such that it returns 0 when b is also 0.

Definition at line 86 of file gpu_shader_math_vector_safe.bsl.hh.

References b, compatible_mod(), float4::w, float4::x, float4::y, and float4::z.

◆ compatible_pow() [1/3]

float2 compatible_pow ( float2 a,
float2 b )

Definition at line 210 of file gpu_shader_math_vector_safe.bsl.hh.

References b, compatible_pow(), float2::x, and float2::y.

◆ compatible_pow() [2/3]

float3 compatible_pow ( float3 a,
float3 b )

Definition at line 214 of file gpu_shader_math_vector_safe.bsl.hh.

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

◆ compatible_pow() [3/3]

float4 compatible_pow ( float4 a,
float4 b )

◆ fallback_pow() [1/3]

float2 fallback_pow ( float2 a,
float b,
float2 fallback )

A version of pow that returns a fallback value if the computation is undefined. From the spec: The result is undefined if x < 0 or if x = 0 and y is less than or equal 0.

Definition at line 192 of file gpu_shader_math_vector_safe.bsl.hh.

References b, fallback_pow(), float2::x, and float2::y.

◆ fallback_pow() [2/3]

float3 fallback_pow ( float3 a,
float b,
float3 fallback )

Definition at line 196 of file gpu_shader_math_vector_safe.bsl.hh.

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

◆ fallback_pow() [3/3]

float4 fallback_pow ( float4 a,
float b,
float4 fallback )

◆ normalize_fallback()

template<typename VecT>
VecT normalize_fallback ( VecT vector,
VecT fallback )

◆ normalize_fallback< float2 >()

◆ normalize_fallback< float3 >()

◆ normalize_fallback< float4 >()

◆ safe_divide() [1/4]

float2 safe_divide ( float2 a,
float b )

Safe divide a by b. If b equal 0 the result will be 0.

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

References b, and safe_divide().

◆ safe_divide() [2/4]

float3 safe_divide ( float3 a,
float b )

Definition at line 116 of file gpu_shader_math_vector_safe.bsl.hh.

References b, and safe_divide().

◆ safe_divide() [3/4]

float4 safe_divide ( float4 a,
float b )

Definition at line 120 of file gpu_shader_math_vector_safe.bsl.hh.

References b, and safe_divide().

◆ safe_divide() [4/4]

template<typename VecT>
VecT safe_divide ( VecT a,
VecT b )

Safe divide a by b. If b equal 0 the result will be 0.

Definition at line 98 of file gpu_shader_math_vector_safe.bsl.hh.

References b, notEqual, safe_divide(), and select.

◆ safe_divide< float2 >()

template float2 safe_divide< float2 > ( float2 ,
float2  )

References safe_divide().

◆ safe_divide< float3 >()

template float3 safe_divide< float3 > ( float3 ,
float3  )

References safe_divide().

◆ safe_divide< float4 >()

template float4 safe_divide< float4 > ( float4 ,
float4  )

References safe_divide().

◆ safe_mod() [1/4]

float2 safe_mod ( float2 a,
float b )

Safe a modulo b. If b equal 0 the result will be 0.

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

References b, mod, and safe_mod().

◆ safe_mod() [2/4]

float3 safe_mod ( float3 a,
float b )

Definition at line 29 of file gpu_shader_math_vector_safe.bsl.hh.

References b, mod, and safe_mod().

◆ safe_mod() [3/4]

float4 safe_mod ( float4 a,
float b )

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

References b, mod, and safe_mod().

◆ safe_mod() [4/4]

template<typename VecT>
VecT safe_mod ( VecT a,
VecT b )

Safe a modulo b. If b equal 0 the result will be 0.

Definition at line 13 of file gpu_shader_math_vector_safe.bsl.hh.

References b, mod, notEqual, safe_mod(), and select.

◆ safe_mod< float2 >()

template float2 safe_mod< float2 > ( float2 ,
float2  )

References safe_mod().

◆ safe_mod< float3 >()

template float3 safe_mod< float3 > ( float3 ,
float3  )

References safe_mod().

◆ safe_mod< float4 >()

template float4 safe_mod< float4 > ( float4 ,
float4  )

References safe_mod().

◆ safe_normalize()

template<typename VecT>
VecT safe_normalize ( VecT vector)

Return normalized version of the vector or a default normalized vector if vector is invalid.

Definition at line 150 of file gpu_shader_math_vector_safe.bsl.hh.

References safe_normalize(), and safe_normalize_and_get_length().

Referenced by apply_corner_normal_delta(), attr_create_pointiness(), attr_load_tangent(), bsdf_hair_chiang_albedo(), bsdf_hair_chiang_eval(), bsdf_hair_chiang_sample(), bsdf_ray_portal_setup(), bxdf_ggx_eval_reflection(), compute_emitter_centroid_and_dir(), eevee::motion_blur::dilate::Resources::compute_motion_line(), AreaLight::copy_to_kernel(), SpotLight::copy_to_kernel(), SunLight::copy_to_kernel(), direction_to_fisheye_equidistant(), direction_to_fisheye_equisolid(), eevee::camera::fisheye_equisolid_from_direction(), eevee::camera::fisheye_lens_polynomial_from_direction(), eevee::forward_lighting_eval(), eevee::lightprobe::planar::display::frag_main(), eevee::init_globals(), eevee::init_globals_curves(), eevee::lightprobe::volume::RayCapture::irradiance_capture_surfel(), LightTreeEmitter::LightTreeEmitter(), make_orthonormals_safe_tangent(), merge(), motion_triangle_smooth_normal(), motion_triangle_smooth_normal(), node_ambient_occlusion(), node_bsdf_diffuse(), node_bsdf_glass(), node_bsdf_glossy(), node_bsdf_metallic(), node_bsdf_refraction(), node_bsdf_sheen(), node_bsdf_toon(), node_bsdf_translucent(), node_eevee_specular(), node_subsurface_scattering(), node_vector_displacement_tangent(), Mesh::SubdFace::normal(), object_inverse_normal_transform(), openpbr_eval_fuzz(), primitive_normal_set_undisplaced(), principled_bsdf_emission(), eevee::surfel::SurfelRay::radiance_transfer_surfel(), safe_normalize(), safe_normalize(), safe_normalize(), safe_normalize(), safe_normalize(), safe_normalize< float2 >(), safe_normalize< float3 >(), safe_normalize< float4 >(), save_pre_displacement_normals(), eevee::shadow_ray_generate_directional(), eevee::shadow_ray_generate_punctual(), eevee::raytracing::denoise::spatial_main(), spot_light_to_local(), store_vertex_normals(), svm_mapping(), svm_node_normal_map(), svm_node_set_bump(), svm_node_tex_coord_derivative(), svm_node_tex_environment_projection(), svm_node_vector_displacement(), svm_vector_math(), triangle_light_pdf(), triangle_light_sample(), triangle_smooth_normal(), triangle_smooth_normal(), triangle_smooth_normal_unnormalized_object_space(), and eevee::lightprobe::volume::RayCapture::validity_capture_surfel().

◆ safe_normalize< float2 >()

References safe_normalize().

◆ safe_normalize< float3 >()

References safe_normalize().

◆ safe_normalize< float4 >()

References safe_normalize().

◆ safe_normalize_and_get_length()

template<typename VecT>
VecT safe_normalize_and_get_length ( VecT vector,
float & out_length )

◆ safe_normalize_and_get_length< float2 >()

◆ safe_normalize_and_get_length< float3 >()

◆ safe_normalize_and_get_length< float4 >()

◆ safe_rcp()

template<typename VecT>
VecT safe_rcp ( VecT a)

Safe reciprocal function. Returns 1/a. If a equal 0 the result will be 0.

Definition at line 180 of file gpu_shader_math_vector_safe.bsl.hh.

References notEqual, safe_rcp(), and select.

◆ safe_rcp< float2 >()

template float2 safe_rcp< float2 > ( float2 )

References safe_rcp().

◆ safe_rcp< float3 >()

template float3 safe_rcp< float3 > ( float3 )

References safe_rcp().

◆ safe_rcp< float4 >()

template float4 safe_rcp< float4 > ( float4 )

References safe_rcp().

◆ wrap() [1/3]

float2 wrap ( float2 a,
float2 b,
float2 c )

Wrap the given value a to fall within the range [b, c].

Definition at line 229 of file gpu_shader_math_vector_safe.bsl.hh.

References b, wrap(), float2::x, and float2::y.

◆ wrap() [2/3]

float3 wrap ( float3 a,
float3 b,
float3 c )

Wrap the given value a to fall within the range [b, c].

Definition at line 236 of file gpu_shader_math_vector_safe.bsl.hh.

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

◆ wrap() [3/3]

float4 wrap ( float4 a,
float4 b,
float4 c )

Wrap the given value a to fall within the range [b, c].

Definition at line 243 of file gpu_shader_math_vector_safe.bsl.hh.

References b, float4::w, wrap(), float4::x, float4::y, and float4::z.