[Bf-blender-cvs] [1c769820304] cycles_path_guiding: Cleanup: add utility functions for converting to pgl vectors
Brecht Van Lommel
noreply at git.blender.org
Thu Aug 25 21:57:39 CEST 2022
Commit: 1c76982030425edcc1101fb5c6c823e7c8fb9484
Author: Brecht Van Lommel
Date: Thu Aug 25 20:12:57 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB1c76982030425edcc1101fb5c6c823e7c8fb9484
Cleanup: add utility functions for converting to pgl vectors
===================================================================
M intern/cycles/kernel/integrator/guiding.h
M intern/cycles/kernel/integrator/shade_surface.h
M intern/cycles/kernel/integrator/shade_volume.h
M intern/cycles/kernel/integrator/shader_eval.h
===================================================================
diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h
index dfeec9b3471..31e747a592a 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -11,6 +11,20 @@
CCL_NAMESPACE_BEGIN
+/* Utilities. */
+
+#if defined(__PATH_GUIDING__)
+static pgl_vec3f guiding_vec3f(const float3 v)
+{
+ return openpgl::cpp::Vector3(v.x, v.y, v.z);
+}
+
+static pgl_point3f guiding_point3f(const float3 v)
+{
+ return openpgl::cpp::Point3(v.x, v.y, v.z);
+}
+#endif
+
/* Path recording for guiding. */
ccl_device_forceinline void guiding_record_light_surface_segment(
@@ -21,26 +35,23 @@ ccl_device_forceinline void guiding_record_light_surface_segment(
return;
}
- const pgl_vec3f pglZero = openpgl::cpp::Vector3(0.f, 0.f, 0.f);
- const pgl_vec3f pglOne = openpgl::cpp::Vector3(1.f, 1.f, 1.f);
- float3 ray_P = INTEGRATOR_STATE(state, ray, P);
- float3 ray_D = INTEGRATOR_STATE(state, ray, D);
- float3 p = ray_P + isect->t * ray_D;
- pgl_point3f pglP = openpgl::cpp::Point3(p[0], p[1], p[2]);
- pgl_vec3f pglWi = openpgl::cpp::Vector3(-ray_D[0], -ray_D[1], -ray_D[2]);
- pgl_vec3f pglWo = openpgl::cpp::Vector3(ray_D[0], ray_D[1], ray_D[2]);
+ const pgl_vec3f zero = guiding_vec3f(zero_float3());
+ const pgl_vec3f one = guiding_vec3f(one_float3());
+ const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
+ const float3 ray_D = INTEGRATOR_STATE(state, ray, D);
+ const float3 P = ray_P + isect->t * ray_D;
state->guiding.path_segment = state->guiding.path_segment_storage->NextSegment();
- openpgl::cpp::SetPosition(state->guiding.path_segment, pglP);
- openpgl::cpp::SetDirectionOut(state->guiding.path_segment, pglWi);
- openpgl::cpp::SetNormal(state->guiding.path_segment, pglWi);
- openpgl::cpp::SetDirectionIn(state->guiding.path_segment, pglWo);
+ openpgl::cpp::SetPosition(state->guiding.path_segment, guiding_point3f(P));
+ openpgl::cpp::SetDirectionOut(state->guiding.path_segment, guiding_vec3f(-ray_D));
+ openpgl::cpp::SetNormal(state->guiding.path_segment, guiding_vec3f(-ray_D));
+ openpgl::cpp::SetDirectionIn(state->guiding.path_segment, guiding_vec3f(ray_D));
openpgl::cpp::SetPDFDirectionIn(state->guiding.path_segment, 1.0f);
openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, false);
- openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetDirectContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, pglOne);
- openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, pglOne);
+ openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetDirectContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, one);
+ openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, one);
openpgl::cpp::SetEta(state->guiding.path_segment, 1.0f);
#endif
}
@@ -54,18 +65,16 @@ ccl_device_forceinline void guiding_record_surface_segment(KernelGlobals kg,
return;
}
- const pgl_vec3f pglZero = openpgl::cpp::Vector3(0.f, 0.f, 0.f);
- const pgl_vec3f pglOne = openpgl::cpp::Vector3(1.f, 1.f, 1.f);
- pgl_point3f pglP = openpgl::cpp::Point3(sd->P.x, sd->P.y, sd->P.z);
- pgl_vec3f pglWi = openpgl::cpp::Vector3(sd->I.x, sd->I.y, sd->I.z);
+ const pgl_vec3f zero = guiding_vec3f(zero_float3());
+ const pgl_vec3f one = guiding_vec3f(one_float3());
state->guiding.path_segment = state->guiding.path_segment_storage->NextSegment();
- openpgl::cpp::SetPosition(state->guiding.path_segment, pglP);
- openpgl::cpp::SetDirectionOut(state->guiding.path_segment, pglWi);
+ openpgl::cpp::SetPosition(state->guiding.path_segment, guiding_point3f(sd->P));
+ openpgl::cpp::SetDirectionOut(state->guiding.path_segment, guiding_vec3f(sd->I));
openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, false);
- openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetDirectContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, pglOne);
+ openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetDirectContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, one);
openpgl::cpp::SetEta(state->guiding.path_segment, 1.0);
#endif
}
@@ -73,105 +82,84 @@ ccl_device_forceinline void guiding_record_surface_segment(KernelGlobals kg,
ccl_device_forceinline void guiding_record_surface_bounce(KernelGlobals kg,
IntegratorState state,
ccl_private const ShaderData *sd,
- const Spectrum bsdf_weight,
- const float bsdf_pdf,
- const float3 bsdf_shading_normal,
- const float3 bsdf_omega_in,
- const float2 bsdf_roughness,
- const float bsdf_eta)
+ const Spectrum weight,
+ const float pdf,
+ const float3 N,
+ const float3 omega_in,
+ const float2 roughness,
+ const float eta)
{
#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
if (!kernel_data.integrator.use_guiding) {
return;
}
- float roughness = fminf(bsdf_roughness.x, bsdf_roughness.y);
- if (roughness > 0.0f) {
- roughness = sqrt(roughness);
- }
-
- const bool bsdf_is_delta = roughness > 0.f ? false : true;
- const float3 bsdf_weight_rgb = spectrum_to_rgb(bsdf_weight);
-
- pgl_vec3f pglWo = openpgl::cpp::Vector3(bsdf_omega_in[0], bsdf_omega_in[1], bsdf_omega_in[2]);
- pgl_vec3f pglBSDFWeight = openpgl::cpp::Vector3(
- bsdf_weight_rgb[0], bsdf_weight_rgb[1], bsdf_weight_rgb[2]);
- pgl_vec3f pglNormal = openpgl::cpp::Vector3(clamp(bsdf_shading_normal[0], -1.f, 1.f),
- clamp(bsdf_shading_normal[1], -1.f, 1.f),
- clamp(bsdf_shading_normal[2], -1.f, 1.f));
+ const float min_roughness = safe_sqrtf(fminf(roughness.x, roughness.y));
+ const bool is_delta = (min_roughness == 0.0f);
+ const float3 weight_rgb = spectrum_to_rgb(weight);
+ const float3 normal = clamp(N, -one_float3(), one_float3());
kernel_assert(state->guiding.path_segment != nullptr);
- openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment,
- openpgl::cpp::Vector3(1.0f, 1.0f, 1.0f));
+ openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, guiding_vec3f(one_float3()));
openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, false);
- openpgl::cpp::SetNormal(state->guiding.path_segment, pglNormal);
- openpgl::cpp::SetDirectionIn(state->guiding.path_segment, pglWo);
- openpgl::cpp::SetPDFDirectionIn(state->guiding.path_segment, bsdf_pdf);
- openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, pglBSDFWeight);
- openpgl::cpp::SetIsDelta(state->guiding.path_segment, bsdf_is_delta);
- openpgl::cpp::SetEta(state->guiding.path_segment, bsdf_eta);
- openpgl::cpp::SetRoughness(state->guiding.path_segment, roughness);
+ openpgl::cpp::SetNormal(state->guiding.path_segment, guiding_vec3f(normal));
+ openpgl::cpp::SetDirectionIn(state->guiding.path_segment, guiding_vec3f(omega_in));
+ openpgl::cpp::SetPDFDirectionIn(state->guiding.path_segment, pdf);
+ openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, guiding_vec3f(weight_rgb));
+ openpgl::cpp::SetIsDelta(state->guiding.path_segment, is_delta);
+ openpgl::cpp::SetEta(state->guiding.path_segment, eta);
+ openpgl::cpp::SetRoughness(state->guiding.path_segment, min_roughness);
#endif
}
ccl_device_forceinline void guiding_record_bssrdf_segment(KernelGlobals kg,
IntegratorState state,
- const float3 &P,
- const float3 &I)
+ const float3 P,
+ const float3 I)
{
#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
if (!kernel_data.integrator.use_guiding) {
return;
}
- const pgl_vec3f pglZero = openpgl::cpp::Vector3(0.f, 0.f, 0.f);
- const pgl_vec3f pglOne = openpgl::cpp::Vector3(1.f, 1.f, 1.f);
- pgl_point3f pglP = openpgl::cpp::Point3(P.x, P.y, P.z);
- pgl_vec3f pglWi = openpgl::cpp::Vector3(I.x, I.y, I.z);
+ const pgl_vec3f zero = guiding_vec3f(zero_float3());
+ const pgl_vec3f one = guiding_vec3f(one_float3());
state->guiding.path_segment = state->guiding.path_segment_storage->NextSegment();
- openpgl::cpp::SetPosition(state->guiding.path_segment, pglP);
- openpgl::cpp::SetDirectionOut(state->guiding.path_segment, pglWi);
+ openpgl::cpp::SetPosition(state->guiding.path_segment, guiding_point3f(P));
+ openpgl::cpp::SetDirectionOut(state->guiding.path_segment, guiding_vec3f(I));
openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, true);
- openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetDirectContribution(state->guiding.path_segment, pglZero);
- openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, pglOne);
+ openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetDirectContribution(state->guiding.path_segment, zero);
+ openpgl::cpp::SetTransmittanceWeigh
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list