From 69f38199f1ccc6d9337f7abe0a870728b33d4d0b Mon Sep 17 00:00:00 2001 From: tvcastillod Date: Fri, 20 Sep 2024 10:51:34 -0500 Subject: [PATCH] fixed format --- fury/actor.py | 5 +- fury/actors/odf.py | 31 +++++----- fury/shaders/lighting/tonemap.frag | 5 ++ .../odf}/descoteaux/eval_sh_10.frag | 0 .../odf}/descoteaux/eval_sh_12.frag | 0 .../odf}/descoteaux/eval_sh_2.frag | 0 .../odf}/descoteaux/eval_sh_4.frag | 0 .../odf}/descoteaux/eval_sh_6.frag | 0 .../odf}/descoteaux/eval_sh_8.frag | 0 .../odf}/descoteaux/eval_sh_grad_10.frag | 0 .../odf}/descoteaux/eval_sh_grad_12.frag | 0 .../odf}/descoteaux/eval_sh_grad_2.frag | 0 .../odf}/descoteaux/eval_sh_grad_4.frag | 0 .../odf}/descoteaux/eval_sh_grad_6.frag | 0 .../odf}/descoteaux/eval_sh_grad_8.frag | 0 fury/shaders/ray_tracing/odf/eval_sh.frag | 57 ++++++++++++++++++ .../odf}/eval_sh_grad.frag | 2 +- .../odf}/get_inv_vandermonde.frag | 0 .../odf}/get_sh_glyph_normal.frag | 0 .../odf}/ray_sh_glyph_intersections.frag | 0 .../odf}/tournier/eval_sh_10.frag | 2 +- .../odf}/tournier/eval_sh_12.frag | 2 +- .../odf}/tournier/eval_sh_2.frag | 2 +- .../odf}/tournier/eval_sh_4.frag | 2 +- .../odf}/tournier/eval_sh_6.frag | 2 +- .../odf}/tournier/eval_sh_8.frag | 2 +- .../odf}/tournier/eval_sh_grad_10.frag | 0 .../odf}/tournier/eval_sh_grad_12.frag | 0 .../odf}/tournier/eval_sh_grad_2.frag | 0 .../odf}/tournier/eval_sh_grad_4.frag | 0 .../odf}/tournier/eval_sh_grad_6.frag | 0 .../odf}/tournier/eval_sh_grad_8.frag | 0 fury/shaders/rt_odfs/eval_sh.frag | 58 ------------------- fury/shaders/rt_odfs/tonemap.frag | 5 -- fury/shaders/utils/find_roots.frag | 26 ++++----- fury/utils.py | 10 ++-- 36 files changed, 108 insertions(+), 103 deletions(-) create mode 100644 fury/shaders/lighting/tonemap.frag rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_10.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_12.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_2.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_4.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_6.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_8.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_10.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_12.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_2.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_4.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_6.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/descoteaux/eval_sh_grad_8.frag (100%) create mode 100644 fury/shaders/ray_tracing/odf/eval_sh.frag rename fury/shaders/{rt_odfs => ray_tracing/odf}/eval_sh_grad.frag (99%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/get_inv_vandermonde.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/get_sh_glyph_normal.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/ray_sh_glyph_intersections.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_10.frag (98%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_12.frag (99%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_2.frag (90%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_4.frag (95%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_6.frag (97%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_8.frag (98%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_10.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_12.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_2.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_4.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_6.frag (100%) rename fury/shaders/{rt_odfs => ray_tracing/odf}/tournier/eval_sh_grad_8.frag (100%) delete mode 100644 fury/shaders/rt_odfs/eval_sh.frag delete mode 100644 fury/shaders/rt_odfs/tonemap.frag diff --git a/fury/actor.py b/fury/actor.py index d8d9f75a9..cf9c1fe74 100644 --- a/fury/actor.py +++ b/fury/actor.py @@ -4022,9 +4022,11 @@ def uncertainty_cone( return double_cone(centers, evecs, angles, colors, scales, opacity) +@warn_on_args_to_kwargs() def odf( centers, coeffs, + *, sh_basis='descoteaux', scales=1.0, opacity=1.0 @@ -4073,7 +4075,8 @@ def odf( coeffs_given = coeffs.shape[-1] degree = int((np.sqrt(8 * coeffs_given + 1) - 3) / 2) - if (degree%2 != 0): degree -= 1 + if (degree%2 != 0): + degree -= 1 coeffs = coeffs[:, :int(((degree + 1) * (degree + 2)) / 2)] if not isinstance(scales, np.ndarray): scales = np.array(scales) diff --git a/fury/actors/odf.py b/fury/actors/odf.py index 1502c48cc..470bcb64b 100644 --- a/fury/actors/odf.py +++ b/fury/actors/odf.py @@ -57,12 +57,12 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): attribute_to_actor(odf_actor, big_minmax, "minmax") odf_actor_pd = odf_actor.GetMapper().GetInput() - + n_glyphs = coeffs.shape[0] # Coordinates to locate the data of each glyph in the texture. uv_vals = np.array(uv_calculations(n_glyphs)) num_pnts = uv_vals.shape[0] - + # Definition of texture coordinates to be associated with the actor. t_coords = FloatArray() t_coords.SetNumberOfComponents(2) @@ -70,7 +70,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): [t_coords.SetTuple(i, uv_vals[i]) for i in range(num_pnts)] set_polydata_tcoords(odf_actor_pd, t_coords) - + # The coefficient data is stored in a texture to be passed to the shaders. # Data is normalized to a range of 0 to 1. @@ -92,7 +92,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): max_sh_degree = int((np.sqrt(8 * max_num_coeffs + 1) - 3) / 2) max_poly_degree = 2 * max_sh_degree + 2 viz_sh_degree = max_sh_degree - + # The number of coefficients is associated to the order of the SH odf_actor.GetShaderProperty().GetFragmentCustomUniforms().SetUniformf( "shDegree", viz_sh_degree @@ -103,7 +103,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): vs_dec = \ """ uniform float shDegree; - + in vec3 center; in vec2 minmax; @@ -185,11 +185,13 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): eval_sh_composed = "" for i in range(2, max_sh_degree + 1, 2): eval_sh = import_fury_shader( - os.path.join("rt_odfs", sh_basis, "eval_sh_" + str(i) + ".frag") + os.path.join("ray_tracing", "odf", sh_basis, "eval_sh_" + str(i) + + ".frag") ) eval_sh_grad = import_fury_shader( os.path.join( - "rt_odfs", sh_basis, "eval_sh_grad_" + str(i) + ".frag" + "ray_tracing", "odf", sh_basis, "eval_sh_grad_" + str(i) + + ".frag" ) ) eval_sh_composed = compose_shader( @@ -230,18 +232,18 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): # SH_DEGREE in this order. # param point The point on the unit sphere where the basis should be # evaluated. - eval_sh = import_fury_shader(os.path.join("rt_odfs", "eval_sh.frag")) + eval_sh = import_fury_shader(os.path.join("ray_tracing", "odf", "eval_sh.frag")) # Evaluates the gradient of each basis function given by eval_sh() and the # basis itself eval_sh_grad = import_fury_shader( - os.path.join("rt_odfs", "eval_sh_grad.frag") + os.path.join("ray_tracing", "odf", "eval_sh_grad.frag") ) # Outputs a matrix that turns equidistant samples on the unit circle of a # homogeneous polynomial into coefficients of that polynomial. get_inv_vandermonde = import_fury_shader( - os.path.join("rt_odfs", "get_inv_vandermonde.frag") + os.path.join("ray_tracing", "odf", "get_inv_vandermonde.frag") ) # Determines all intersections between a ray and a spherical harmonics @@ -255,7 +257,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): # param ray_origin The origin of the ray, relative to the glyph center. # param ray_dir The normalized direction vector of the ray. ray_sh_glyph_intersections = import_fury_shader( - os.path.join("rt_odfs", "ray_sh_glyph_intersections.frag") + os.path.join("ray_tracing", "odf", "ray_sh_glyph_intersections.frag") ) # Provides a normalized normal vector for a spherical harmonics glyph. @@ -266,7 +268,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): # # return A normalized surface normal pointing away from the origin. get_sh_glyph_normal = import_fury_shader( - os.path.join("rt_odfs", "get_sh_glyph_normal.frag") + os.path.join("ray_tracing", "odf", "get_sh_glyph_normal.frag") ) # Applies the non-linearity that maps linear RGB to sRGB @@ -290,7 +292,7 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): ) # Logarithmic tonemapping operator. Input and output are linear RGB. - tonemap = import_fury_shader(os.path.join("rt_odfs", "tonemap.frag")) + tonemap = import_fury_shader(os.path.join("lighting", "tonemap.frag")) # Blinn-Phong illumination model blinn_phong_model = import_fury_shader( @@ -368,7 +370,8 @@ def sh_odf(centers, coeffs, degree, sh_basis, scales, opacity): vec3 color = vec3(1.); if (firstRayParam != NO_INTERSECTION) { vec3 intersection = ro - centerMCVSOutput + firstRayParam * rd; - vec3 normal = getShGlyphNormal(shCoeffs, intersection, int(shDegree), int(numCoeffsVSOutput)); + vec3 normal = getShGlyphNormal(shCoeffs, intersection, + int(shDegree), int(numCoeffsVSOutput)); vec3 colorDir = srgbToLinearRgb(abs(normalize(intersection))); float attenuation = dot(ld, normal); color = blinnPhongIllumModel( diff --git a/fury/shaders/lighting/tonemap.frag b/fury/shaders/lighting/tonemap.frag new file mode 100644 index 000000000..aa6002331 --- /dev/null +++ b/fury/shaders/lighting/tonemap.frag @@ -0,0 +1,5 @@ +vec3 tonemap(vec3 linear) +{ + float maxChannel = max(max(1.0, linear.r), max(linear.g, linear.b)); + return linear * ((1.0 - 0.02 * log2(maxChannel)) / maxChannel); +} diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_10.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_10.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_10.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_10.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_12.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_12.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_12.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_12.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_2.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_2.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_2.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_2.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_4.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_4.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_4.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_4.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_6.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_6.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_6.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_6.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_8.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_8.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_8.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_8.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_10.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_10.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_10.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_10.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_12.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_12.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_12.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_12.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_2.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_2.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_2.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_2.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_4.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_4.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_4.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_4.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_6.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_6.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_6.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_6.frag diff --git a/fury/shaders/rt_odfs/descoteaux/eval_sh_grad_8.frag b/fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_8.frag similarity index 100% rename from fury/shaders/rt_odfs/descoteaux/eval_sh_grad_8.frag rename to fury/shaders/ray_tracing/odf/descoteaux/eval_sh_grad_8.frag diff --git a/fury/shaders/ray_tracing/odf/eval_sh.frag b/fury/shaders/ray_tracing/odf/eval_sh.frag new file mode 100644 index 000000000..61de21272 --- /dev/null +++ b/fury/shaders/ray_tracing/odf/eval_sh.frag @@ -0,0 +1,57 @@ +void evalSH(out float outSH[SH_COUNT], vec3 point, int shDegree, int numCoeffs) +{ + if (shDegree == 2) + { + float tmpOutSH[6]; + #if SH_DEGREE == 2 + evalSH2(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } + else if (shDegree == 4) + { + float tmpOutSH[15]; + #if SH_DEGREE == 4 + evalSH4(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } + else if (shDegree == 6) + { + float tmpOutSH[28]; + #if SH_DEGREE == 6 + evalSH6(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } + else if (shDegree == 8) + { + float tmpOutSH[45]; + #if SH_DEGREE == 8 + evalSH8(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } + else if (shDegree == 10) + { + float tmpOutSH[66]; + #if SH_DEGREE == 10 + evalSH10(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } + else if (shDegree == 12) + { + float tmpOutSH[91]; + #if SH_DEGREE == 12 + evalSH12(tmpOutSH, point); + #endif + for (int i = 0; i != numCoeffs; ++i) + outSH[i] = tmpOutSH[i]; + } +} diff --git a/fury/shaders/rt_odfs/eval_sh_grad.frag b/fury/shaders/ray_tracing/odf/eval_sh_grad.frag similarity index 99% rename from fury/shaders/rt_odfs/eval_sh_grad.frag rename to fury/shaders/ray_tracing/odf/eval_sh_grad.frag index cfb3fc862..30a2584e3 100644 --- a/fury/shaders/rt_odfs/eval_sh_grad.frag +++ b/fury/shaders/ray_tracing/odf/eval_sh_grad.frag @@ -10,7 +10,7 @@ void evalShGrad(out float outSH[SH_COUNT], out vec3 outGrads[SH_COUNT], vec3 poi #endif for (int i = 0; i != numCoeffs; ++i) outSH[i] = tmpOutSH[i]; - + } else if (shDegree == 4) { diff --git a/fury/shaders/rt_odfs/get_inv_vandermonde.frag b/fury/shaders/ray_tracing/odf/get_inv_vandermonde.frag similarity index 100% rename from fury/shaders/rt_odfs/get_inv_vandermonde.frag rename to fury/shaders/ray_tracing/odf/get_inv_vandermonde.frag diff --git a/fury/shaders/rt_odfs/get_sh_glyph_normal.frag b/fury/shaders/ray_tracing/odf/get_sh_glyph_normal.frag similarity index 100% rename from fury/shaders/rt_odfs/get_sh_glyph_normal.frag rename to fury/shaders/ray_tracing/odf/get_sh_glyph_normal.frag diff --git a/fury/shaders/rt_odfs/ray_sh_glyph_intersections.frag b/fury/shaders/ray_tracing/odf/ray_sh_glyph_intersections.frag similarity index 100% rename from fury/shaders/rt_odfs/ray_sh_glyph_intersections.frag rename to fury/shaders/ray_tracing/odf/ray_sh_glyph_intersections.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_10.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_10.frag similarity index 98% rename from fury/shaders/rt_odfs/tournier/eval_sh_10.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_10.frag index d47efb629..d5b33c189 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_10.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_10.frag @@ -1,4 +1,4 @@ -void eval_sh_10(out float outSH[66], vec3 point) +void evalSH10(out float outSH[66], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a, b; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_12.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_12.frag similarity index 99% rename from fury/shaders/rt_odfs/tournier/eval_sh_12.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_12.frag index bad475582..3994374e9 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_12.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_12.frag @@ -1,4 +1,4 @@ -void eval_sh_12(out float outSH[91], vec3 point) +void evalSH12(out float outSH[91], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a, b; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_2.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_2.frag similarity index 90% rename from fury/shaders/rt_odfs/tournier/eval_sh_2.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_2.frag index 98dfa2d0a..174ac5d62 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_2.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_2.frag @@ -1,4 +1,4 @@ -void eval_sh_2(out float outSH[6], vec3 point) +void evalSH2(out float outSH[6], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_4.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_4.frag similarity index 95% rename from fury/shaders/rt_odfs/tournier/eval_sh_4.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_4.frag index 0ea37caa4..77152bb6a 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_4.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_4.frag @@ -1,4 +1,4 @@ -void eval_sh_4(out float outSH[15], vec3 point) +void evalSH4(out float outSH[15], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a, b; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_6.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_6.frag similarity index 97% rename from fury/shaders/rt_odfs/tournier/eval_sh_6.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_6.frag index 1d17b9b8b..6e3d53307 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_6.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_6.frag @@ -1,4 +1,4 @@ -void eval_sh_6(out float outSH[28], vec3 point) +void evalSH6(out float outSH[28], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a, b; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_8.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_8.frag similarity index 98% rename from fury/shaders/rt_odfs/tournier/eval_sh_8.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_8.frag index 6550fc525..e68a3efba 100644 --- a/fury/shaders/rt_odfs/tournier/eval_sh_8.frag +++ b/fury/shaders/ray_tracing/odf/tournier/eval_sh_8.frag @@ -1,4 +1,4 @@ -void eval_sh_8(out float outSH[45], vec3 point) +void evalSH8(out float outSH[45], vec3 point) { float x, y, z, z2, c0, s0, c1, s1, d, a, b; x = point[0]; diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_10.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_10.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_10.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_10.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_12.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_12.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_12.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_12.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_2.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_2.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_2.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_2.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_4.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_4.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_4.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_4.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_6.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_6.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_6.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_6.frag diff --git a/fury/shaders/rt_odfs/tournier/eval_sh_grad_8.frag b/fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_8.frag similarity index 100% rename from fury/shaders/rt_odfs/tournier/eval_sh_grad_8.frag rename to fury/shaders/ray_tracing/odf/tournier/eval_sh_grad_8.frag diff --git a/fury/shaders/rt_odfs/eval_sh.frag b/fury/shaders/rt_odfs/eval_sh.frag deleted file mode 100644 index fac4b17d8..000000000 --- a/fury/shaders/rt_odfs/eval_sh.frag +++ /dev/null @@ -1,58 +0,0 @@ -void evalSH(out float outSH[SH_COUNT], vec3 point, int shDegree, - int numCoeffs) - { - if (shDegree == 2) - { - float tmpOutSH[6]; - #if SH_DEGREE == 2 - evalSH2(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - else if (shDegree == 4) - { - float tmpOutSH[15]; - #if SH_DEGREE == 4 - evalSH4(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - else if (shDegree == 6) - { - float tmpOutSH[28]; - #if SH_DEGREE == 6 - evalSH6(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - else if (shDegree == 8) - { - float tmpOutSH[45]; - #if SH_DEGREE == 8 - evalSH8(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - else if (shDegree == 10) - { - float tmpOutSH[66]; - #if SH_DEGREE == 10 - evalSH10(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - else if (shDegree == 12) - { - float tmpOutSH[91]; - #if SH_DEGREE == 12 - evalSH12(tmpOutSH, point); - #endif - for (int i = 0; i != numCoeffs; ++i) - outSH[i] = tmpOutSH[i]; - } - } \ No newline at end of file diff --git a/fury/shaders/rt_odfs/tonemap.frag b/fury/shaders/rt_odfs/tonemap.frag deleted file mode 100644 index dd6cdcacb..000000000 --- a/fury/shaders/rt_odfs/tonemap.frag +++ /dev/null @@ -1,5 +0,0 @@ -vec3 tonemap(vec3 linear) -{ - float max_channel = max(max(1.0, linear.r), max(linear.g, linear.b)); - return linear * ((1.0 - 0.02 * log2(max_channel)) / max_channel); -} diff --git a/fury/shaders/utils/find_roots.frag b/fury/shaders/utils/find_roots.frag index 9c69a4801..8b5377942 100644 --- a/fury/shaders/utils/find_roots.frag +++ b/fury/shaders/utils/find_roots.frag @@ -15,12 +15,12 @@ void findRoots(out float outRoots[MAX_DEGREE + 1], float poly[MAX_DEGREE + 1], f // Compute its two roots using the quadratic formula float discriminant = derivative[1] * derivative[1] - 4.0 * derivative[0] * derivative[2]; if (discriminant >= 0.0) { - float sqrt_discriminant = sqrt(discriminant); - float scaled_root = derivative[1] + ((derivative[1] > 0.0) ? sqrt_discriminant : (-sqrt_discriminant)); - float root_0 = clamp(-2.0 * derivative[0] / scaled_root, begin, end); - float root_1 = clamp(-0.5 * scaled_root / derivative[2], begin, end); - outRoots[maxPolyDegree - 2] = min(root_0, root_1); - outRoots[maxPolyDegree - 1] = max(root_0, root_1); + float sqrtDiscriminant = sqrt(discriminant); + float scaledRoot = derivative[1] + ((derivative[1] > 0.0) ? sqrtDiscriminant : (-sqrtDiscriminant)); + float root0 = clamp(-2.0 * derivative[0] / scaledRoot, begin, end); + float root1 = clamp(-0.5 * scaledRoot / derivative[2], begin, end); + outRoots[maxPolyDegree - 2] = min(root0, root1); + outRoots[maxPolyDegree - 1] = max(root0, root1); } else { // Indicate that the cubic derivative has a single root @@ -45,30 +45,30 @@ void findRoots(out float outRoots[MAX_DEGREE + 1], float poly[MAX_DEGREE + 1], f for (int degree = 3; degree != maxPolyDegree + 1; ++degree) { // Take the integral of the previous derivative (scaled such that the // constant coefficient can still be copied directly from poly) - float prev_derivative_order = float(maxPolyDegree + 1 - degree); + float prevDerivativeOrder = float(maxPolyDegree + 1 - degree); _unroll_ for (int i = maxPolyDegree; i != 0; --i) - derivative[i] = derivative[i - 1] * (prev_derivative_order * (1.0 / float(i))); + derivative[i] = derivative[i - 1] * (prevDerivativeOrder * (1.0 / float(i))); // Copy the constant coefficient without causing spilling. This part // would be harder if the derivative were not scaled the way it is. _unroll_ for (int i = 0; i != maxPolyDegree - 2; ++i) derivative[0] = (degree == maxPolyDegree - i) ? poly[i] : derivative[0]; // Determine the value of this derivative at begin - float begin_value = derivative[maxPolyDegree]; + float beginValue = derivative[maxPolyDegree]; _unroll_ for (int i = maxPolyDegree - 1; i != -1; --i) - begin_value = begin_value * begin + derivative[i]; + beginValue = beginValue * begin + derivative[i]; // Iterate over the intervals where roots may be found _unroll_ for (int i = 0; i != maxPolyDegree; ++i) { if (i < maxPolyDegree - degree) continue; - float current_begin = outRoots[i]; - float current_end = outRoots[i + 1]; + float currentBegin = outRoots[i]; + float currentEnd = outRoots[i + 1]; // Try to find a root float root; - if (newtonBisection(root, begin_value, derivative, current_begin, current_end, begin_value, tolerance, maxPolyDegree)) + if (newtonBisection(root, beginValue, derivative, currentBegin, currentEnd, beginValue, tolerance, maxPolyDegree)) outRoots[i] = root; else if (degree < maxPolyDegree) // Create an empty interval for the next iteration diff --git a/fury/utils.py b/fury/utils.py index 2b170a2a2..6ee13a489 100644 --- a/fury/utils.py +++ b/fury/utils.py @@ -1645,13 +1645,13 @@ def minmax_norm(data, axis=1): if data.ndim == 1: data = np.array([data]) elif data.ndim > 2: - raise ValueError('the dimension of the array must be 2.') + raise ValueError("the dimension of the array dimension must be 2.") minimum = data.min(axis=axis) maximum = data.max(axis=axis) if np.array_equal(minimum, maximum): return data - if (axis == 0): - return (data - minimum)/(maximum - minimum) - if (axis == 1): - return (data - minimum[:, None])/(maximum - minimum)[:, None] + if axis == 0: + return (data - minimum) / (maximum - minimum) + if axis == 1: + return (data - minimum[:, None]) / (maximum - minimum)[:, None]