diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-02-17 03:47:18 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-02-17 18:26:24 +0300 |
commit | 68dd7617d705dd255b29b99074afa107ce38031e (patch) | |
tree | 1e253ab76b87e7f22a09db2f1137db3a1b8ecb6c /intern/cycles/kernel | |
parent | 8119f0aad21c3ce88e82d68ed20cd5a8edc99703 (diff) |
Cycles: add utility functions for zero float2/float3/float4/transform
Ref D8237, T78710
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/kernel_accumulate.h | 104 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 14 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_camera.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_differential.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_emission.h | 16 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_light_background.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_montecarlo.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_passes.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_state.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_projection.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_shader.h | 66 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_shadow.h | 6 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_subsurface.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_volume.h | 50 |
16 files changed, 151 insertions, 157 deletions
diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index 7a57a2f33ff..76e0f2be02c 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -32,11 +32,11 @@ ccl_device_inline void bsdf_eval_init(BsdfEval *eval, eval->use_light_pass = use_light_pass; if (eval->use_light_pass) { - eval->diffuse = make_float3(0.0f, 0.0f, 0.0f); - eval->glossy = make_float3(0.0f, 0.0f, 0.0f); - eval->transmission = make_float3(0.0f, 0.0f, 0.0f); - eval->transparent = make_float3(0.0f, 0.0f, 0.0f); - eval->volume = make_float3(0.0f, 0.0f, 0.0f); + eval->diffuse = zero_float3(); + eval->glossy = zero_float3(); + eval->transmission = zero_float3(); + eval->transparent = zero_float3(); + eval->volume = zero_float3(); if (type == CLOSURE_BSDF_TRANSPARENT_ID) eval->transparent = value; @@ -55,7 +55,7 @@ ccl_device_inline void bsdf_eval_init(BsdfEval *eval, eval->diffuse = value; } #ifdef __SHADOW_TRICKS__ - eval->sum_no_mis = make_float3(0.0f, 0.0f, 0.0f); + eval->sum_no_mis = zero_float3(); #endif } @@ -174,55 +174,55 @@ ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L) L->use_light_pass = kernel_data.film.use_light_pass; if (kernel_data.film.use_light_pass) { - L->indirect = make_float3(0.0f, 0.0f, 0.0f); - L->direct_emission = make_float3(0.0f, 0.0f, 0.0f); + L->indirect = zero_float3(); + L->direct_emission = zero_float3(); - L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->color_glossy = make_float3(0.0f, 0.0f, 0.0f); - L->color_transmission = make_float3(0.0f, 0.0f, 0.0f); + L->color_diffuse = zero_float3(); + L->color_glossy = zero_float3(); + L->color_transmission = zero_float3(); - L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f); - L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f); - L->direct_volume = make_float3(0.0f, 0.0f, 0.0f); + L->direct_diffuse = zero_float3(); + L->direct_glossy = zero_float3(); + L->direct_transmission = zero_float3(); + L->direct_volume = zero_float3(); - L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_volume = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_diffuse = zero_float3(); + L->indirect_glossy = zero_float3(); + L->indirect_transmission = zero_float3(); + L->indirect_volume = zero_float3(); L->transparent = 0.0f; - L->emission = make_float3(0.0f, 0.0f, 0.0f); - L->background = make_float3(0.0f, 0.0f, 0.0f); - L->ao = make_float3(0.0f, 0.0f, 0.0f); - L->shadow = make_float3(0.0f, 0.0f, 0.0f); + L->emission = zero_float3(); + L->background = zero_float3(); + L->ao = zero_float3(); + L->shadow = zero_float3(); L->mist = 0.0f; - L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->state.glossy = make_float3(0.0f, 0.0f, 0.0f); - L->state.transmission = make_float3(0.0f, 0.0f, 0.0f); - L->state.volume = make_float3(0.0f, 0.0f, 0.0f); - L->state.direct = make_float3(0.0f, 0.0f, 0.0f); + L->state.diffuse = zero_float3(); + L->state.glossy = zero_float3(); + L->state.transmission = zero_float3(); + L->state.volume = zero_float3(); + L->state.direct = zero_float3(); } else #endif { L->transparent = 0.0f; - L->emission = make_float3(0.0f, 0.0f, 0.0f); + L->emission = zero_float3(); } #ifdef __SHADOW_TRICKS__ - L->path_total = make_float3(0.0f, 0.0f, 0.0f); - L->path_total_shaded = make_float3(0.0f, 0.0f, 0.0f); - L->shadow_background_color = make_float3(0.0f, 0.0f, 0.0f); + L->path_total = zero_float3(); + L->path_total_shaded = zero_float3(); + L->shadow_background_color = zero_float3(); L->shadow_throughput = 0.0f; L->shadow_transparency = 1.0f; L->has_shadow_catcher = 0; #endif #ifdef __DENOISING_FEATURES__ - L->denoising_normal = make_float3(0.0f, 0.0f, 0.0f); - L->denoising_albedo = make_float3(0.0f, 0.0f, 0.0f); + L->denoising_normal = zero_float3(); + L->denoising_albedo = zero_float3(); L->denoising_depth = 0.0f; #endif @@ -561,13 +561,13 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L) { #ifdef __PASSES__ if (L->use_light_pass) { - L->state.diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->state.glossy = make_float3(0.0f, 0.0f, 0.0f); - L->state.transmission = make_float3(0.0f, 0.0f, 0.0f); - L->state.volume = make_float3(0.0f, 0.0f, 0.0f); + L->state.diffuse = zero_float3(); + L->state.glossy = zero_float3(); + L->state.transmission = zero_float3(); + L->state.volume = zero_float3(); - L->direct_emission = make_float3(0.0f, 0.0f, 0.0f); - L->indirect = make_float3(0.0f, 0.0f, 0.0f); + L->direct_emission = zero_float3(); + L->indirect = zero_float3(); } #endif } @@ -642,19 +642,19 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, /* Reject invalid value */ if (!isfinite_safe(sum)) { kernel_assert(!"Non-finite sum in path_radiance_clamp_and_sum!"); - L_sum = make_float3(0.0f, 0.0f, 0.0f); + L_sum = zero_float3(); - L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f); - L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f); - L->direct_volume = make_float3(0.0f, 0.0f, 0.0f); + L->direct_diffuse = zero_float3(); + L->direct_glossy = zero_float3(); + L->direct_transmission = zero_float3(); + L->direct_volume = zero_float3(); - L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f); - L->indirect_volume = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_diffuse = zero_float3(); + L->indirect_glossy = zero_float3(); + L->indirect_transmission = zero_float3(); + L->indirect_volume = zero_float3(); - L->emission = make_float3(0.0f, 0.0f, 0.0f); + L->emission = zero_float3(); } } @@ -668,7 +668,7 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z); if (!isfinite_safe(sum)) { kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!"); - L_sum = make_float3(0.0f, 0.0f, 0.0f); + L_sum = zero_float3(); } } @@ -711,7 +711,7 @@ ccl_device_inline void path_radiance_split_denoising(KernelGlobals *kg, # undef ADD_COMPONENT #else *noisy = L->emission; - *clean = make_float3(0.0f, 0.0f, 0.0f); + *clean = zero_float3(); #endif #ifdef __SHADOW_TRICKS__ diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index ded914c05d7..bdedf0c20a8 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -23,7 +23,7 @@ ccl_device_noinline void compute_light_pass( { kernel_assert(kernel_data.film.use_light_pass); - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); /* Emission and indirect shader data memory used by various functions. */ ShaderDataTinyStorage emission_sd_storage; @@ -176,7 +176,7 @@ ccl_device_inline float3 kernel_bake_shader_bsdf(KernelGlobals *kg, return shader_bsdf_transmission(kg, sd); default: kernel_assert(!"Unknown bake type passed to BSDF evaluate"); - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } } @@ -192,12 +192,12 @@ ccl_device float3 kernel_bake_evaluate_direct_indirect(KernelGlobals *kg, const bool is_color = (pass_filter & BAKE_FILTER_COLOR) != 0; const bool is_direct = (pass_filter & BAKE_FILTER_DIRECT) != 0; const bool is_indirect = (pass_filter & BAKE_FILTER_INDIRECT) != 0; - float3 out = make_float3(0.0f, 0.0f, 0.0f); + float3 out = zero_float3(); if (is_color) { if (is_direct || is_indirect) { /* Leave direct and diffuse channel colored. */ - color = make_float3(1.0f, 1.0f, 1.0f); + color = one_float3(); } else { /* surface color of the pass only */ @@ -315,7 +315,7 @@ ccl_device void kernel_bake_evaluate( if (kernel_data.bake.pass_filter & ~BAKE_FILTER_COLOR) compute_light_pass(kg, &sd, &L, rng_hash, pass_filter, sample); - float3 out = make_float3(0.0f, 0.0f, 0.0f); + float3 out = zero_float3(); ShaderEvalType type = (ShaderEvalType)kernel_data.bake.type; switch (type) { @@ -409,7 +409,7 @@ ccl_device void kernel_bake_evaluate( /* setup ray */ Ray ray; - ray.P = make_float3(0.0f, 0.0f, 0.0f); + ray.P = zero_float3(); ray.D = normalize(P); ray.t = 0.0f; # ifdef __CAMERA_MOTION__ @@ -486,7 +486,7 @@ ccl_device void kernel_background_evaluate(KernelGlobals *kg, float u = __uint_as_float(in.x); float v = __uint_as_float(in.y); - ray.P = make_float3(0.0f, 0.0f, 0.0f); + ray.P = zero_float3(); ray.D = equirectangular_to_direction(u, v); ray.t = 0.0f; #ifdef __CAMERA_MOTION__ diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index efe46d5b0dd..1bfac37158d 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -71,7 +71,7 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, } #endif - float3 P = make_float3(0.0f, 0.0f, 0.0f); + float3 P = zero_float3(); float3 D = Pcamera; /* modify ray for depth of field */ @@ -130,7 +130,7 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, * because we don't want to be affected by depth of field. We compute * ray origin and direction for the center and two neighboring pixels * and simply take their differences. */ - float3 Pnostereo = transform_point(&cameratoworld, make_float3(0.0f, 0.0f, 0.0f)); + float3 Pnostereo = transform_point(&cameratoworld, zero_float3()); float3 Pcenter = Pnostereo; float3 Dcenter = Pcamera; @@ -250,7 +250,7 @@ ccl_device_inline void camera_sample_panorama(ccl_constant KernelCamera *cam, float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); /* create ray form raster position */ - float3 P = make_float3(0.0f, 0.0f, 0.0f); + float3 P = zero_float3(); float3 D = panorama_to_direction(cam, Pcamera.x, Pcamera.y); /* indicates ray should not receive any light, outside of the lens */ diff --git a/intern/cycles/kernel/kernel_differential.h b/intern/cycles/kernel/kernel_differential.h index 8513de0d843..3ec0cdbaccc 100644 --- a/intern/cycles/kernel/kernel_differential.h +++ b/intern/cycles/kernel/kernel_differential.h @@ -106,8 +106,8 @@ ccl_device differential differential_zero() ccl_device differential3 differential3_zero() { differential3 d; - d.dx = make_float3(0.0f, 0.0f, 0.0f); - d.dy = make_float3(0.0f, 0.0f, 0.0f); + d.dx = zero_float3(); + d.dy = zero_float3(); return d; } diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 4ac07d86dda..96ecc624067 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -27,7 +27,7 @@ ccl_device_noinline_cpu float3 direct_emissive_eval(KernelGlobals *kg, float time) { /* setup shading at emitter */ - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); if (shader_constant_emission_eval(kg, ls->shader, &eval)) { if ((ls->prim != PRIM_NONE) && dot(ls->Ng, I) < 0.0f) { @@ -146,13 +146,13 @@ ccl_device_noinline_cpu bool direct_emission(KernelGlobals *kg, /* use visibility flag to skip lights */ if (ls->shader & SHADER_EXCLUDE_ANY) { if (ls->shader & SHADER_EXCLUDE_DIFFUSE) - eval->diffuse = make_float3(0.0f, 0.0f, 0.0f); + eval->diffuse = zero_float3(); if (ls->shader & SHADER_EXCLUDE_GLOSSY) - eval->glossy = make_float3(0.0f, 0.0f, 0.0f); + eval->glossy = zero_float3(); if (ls->shader & SHADER_EXCLUDE_TRANSMIT) - eval->transmission = make_float3(0.0f, 0.0f, 0.0f); + eval->transmission = zero_float3(); if (ls->shader & SHADER_EXCLUDE_SCATTER) - eval->volume = make_float3(0.0f, 0.0f, 0.0f); + eval->volume = zero_float3(); } #endif @@ -266,7 +266,7 @@ ccl_device_noinline_cpu void indirect_lamp_emission(KernelGlobals *kg, /* shadow attenuation */ Ray volume_ray = *ray; volume_ray.t = ls.t; - float3 volume_tp = make_float3(1.0f, 1.0f, 1.0f); + float3 volume_tp = one_float3(); kernel_volume_shadow(kg, emission_sd, state, &volume_ray, &volume_tp); lamp_L *= volume_tp; } @@ -303,11 +303,11 @@ ccl_device_noinline_cpu float3 indirect_background(KernelGlobals *kg, ((shader & SHADER_EXCLUDE_TRANSMIT) && (state->flag & PATH_RAY_TRANSMIT)) || ((shader & SHADER_EXCLUDE_CAMERA) && (state->flag & PATH_RAY_CAMERA)) || ((shader & SHADER_EXCLUDE_SCATTER) && (state->flag & PATH_RAY_VOLUME_SCATTER))) - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } /* Evaluate background shader. */ - float3 L = make_float3(0.0f, 0.0f, 0.0f); + float3 L = zero_float3(); if (!shader_constant_emission_eval(kg, shader, &L)) { # ifdef __SPLIT_KERNEL__ Ray priv_ray = *ray; diff --git a/intern/cycles/kernel/kernel_light_background.h b/intern/cycles/kernel/kernel_light_background.h index 2a685c0adfa..f0f64ce8704 100644 --- a/intern/cycles/kernel/kernel_light_background.h +++ b/intern/cycles/kernel/kernel_light_background.h @@ -277,7 +277,7 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg, portal--; } - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } ccl_device_inline float3 background_sun_sample(KernelGlobals *kg, diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 0edcc1a5a14..ce37bd0b15e 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -154,7 +154,7 @@ ccl_device float2 concentric_sample_disk(float u1, float u2) float b = 2.0f * u2 - 1.0f; if (a == 0.0f && b == 0.0f) { - return make_float2(0.0f, 0.0f); + return zero_float2(); } else if (a * a > b * b) { r = a; diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 239c01fc57a..52be2ed87b7 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -59,9 +59,9 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg, return; } - float3 normal = make_float3(0.0f, 0.0f, 0.0f); - float3 diffuse_albedo = make_float3(0.0f, 0.0f, 0.0f); - float3 specular_albedo = make_float3(0.0f, 0.0f, 0.0f); + float3 normal = zero_float3(); + float3 diffuse_albedo = zero_float3(); + float3 specular_albedo = zero_float3(); float sum_weight = 0.0f, sum_nonspecular_weight = 0.0f; for (int i = 0; i < sd->num_closure; i++) { diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index c332d5ad3ec..5681510fc25 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -267,7 +267,7 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg, if (state->flag & PATH_RAY_TRANSPARENT_BACKGROUND) { state->flag |= (PATH_RAY_SHADOW_CATCHER | PATH_RAY_STORE_SHADOW_INFO); - float3 bg = make_float3(0.0f, 0.0f, 0.0f); + float3 bg = zero_float3(); if (!kernel_data.background.transparent) { bg = indirect_background(kg, emission_sd, state, NULL, ray); } @@ -288,7 +288,7 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg, if (kernel_data.background.transparent) { L->transparent += average(holdout_weight * throughput); } - if (isequal_float3(holdout_weight, make_float3(1.0f, 1.0f, 1.0f))) { + if (isequal_float3(holdout_weight, one_float3())) { return false; } } @@ -460,7 +460,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, # ifdef __AO__ /* ambient occlusion */ if (kernel_data.integrator.use_ambient_occlusion) { - kernel_path_ao(kg, sd, emission_sd, L, state, throughput, make_float3(0.0f, 0.0f, 0.0f)); + kernel_path_ao(kg, sd, emission_sd, L, state, throughput, zero_float3()); } # endif /* __AO__ */ @@ -670,7 +670,7 @@ ccl_device void kernel_path_trace( } /* Initialize state. */ - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); PathRadiance L; path_radiance_init(kg, &L); diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 9ce7a147369..5ea7687ec3b 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -374,7 +374,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, PathRadiance *L) { /* initialize */ - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); path_radiance_init(kg, L); diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index c389c815ae2..bf601580cd0 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -41,11 +41,11 @@ ccl_device_inline void path_state_init(KernelGlobals *kg, if (kernel_data.film.pass_denoising_data) { state->flag |= PATH_RAY_STORE_SHADOW_INFO; state->denoising_feature_weight = 1.0f; - state->denoising_feature_throughput = make_float3(1.0f, 1.0f, 1.0f); + state->denoising_feature_throughput = one_float3(); } else { state->denoising_feature_weight = 0.0f; - state->denoising_feature_throughput = make_float3(0.0f, 0.0f, 0.0f); + state->denoising_feature_throughput = zero_float3(); } #endif /* __DENOISING_FEATURES__ */ diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index f74ced45fd5..387af54cf27 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -56,7 +56,7 @@ ccl_device float3 spherical_to_direction(float theta, float phi) ccl_device float2 direction_to_equirectangular_range(float3 dir, float4 range) { if (is_zero(dir)) - return make_float2(0.0f, 0.0f); + return zero_float2(); float u = (atan2f(dir.y, dir.x) - range.y) / range.x; float v = (acosf(dir.z / len(dir)) - range.w) / range.z; @@ -103,7 +103,7 @@ ccl_device float3 fisheye_to_direction(float u, float v, float fov) float r = sqrtf(u * u + v * v); if (r > 1.0f) - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); float phi = safe_acosf((r != 0.0f) ? u / r : 0.0f); float theta = r * fov * 0.5f; @@ -136,7 +136,7 @@ fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float wi float r = sqrtf(u * u + v * v); if (r > rmax) - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); float phi = safe_acosf((r != 0.0f) ? u / r : 0.0f); float theta = 2.0f * asinf(r / (2.0f * lens)); @@ -158,7 +158,7 @@ ccl_device float3 mirrorball_to_direction(float u, float v) dir.z = 2.0f * v - 1.0f; if (dir.x * dir.x + dir.z * dir.z > 1.0f) - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); dir.y = -sqrtf(max(1.0f - dir.x * dir.x - dir.z * dir.z, 0.0f)); diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index e461e1642b6..e6bd99414cc 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -330,8 +330,8 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg, } else { #ifdef __DPDU__ - sd->dPdu = make_float3(0.0f, 0.0f, 0.0f); - sd->dPdv = make_float3(0.0f, 0.0f, 0.0f); + sd->dPdu = zero_float3(); + sd->dPdv = zero_float3(); #endif } @@ -367,7 +367,7 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg, ccl_device void shader_setup_from_displace( KernelGlobals *kg, ShaderData *sd, int object, int prim, float u, float v) { - float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f); + float3 P, Ng, I = zero_float3(); int shader; triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader); @@ -419,8 +419,8 @@ ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, #ifdef __DPDU__ /* dPdu/dPdv */ - sd->dPdu = make_float3(0.0f, 0.0f, 0.0f); - sd->dPdv = make_float3(0.0f, 0.0f, 0.0f); + sd->dPdu = zero_float3(); + sd->dPdv = zero_float3(); #endif #ifdef __RAY_DIFFERENTIALS__ @@ -466,8 +466,8 @@ ccl_device_inline void shader_setup_from_volume(KernelGlobals *kg, ShaderData *s # ifdef __DPDU__ /* dPdu/dPdv */ - sd->dPdu = make_float3(0.0f, 0.0f, 0.0f); - sd->dPdv = make_float3(0.0f, 0.0f, 0.0f); + sd->dPdu = zero_float3(); + sd->dPdv = zero_float3(); # endif # ifdef __RAY_DIFFERENTIALS__ @@ -617,8 +617,7 @@ ccl_device_inline { PROFILING_INIT(kg, PROFILING_CLOSURE_EVAL); - bsdf_eval_init( - eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass); + bsdf_eval_init(eval, NBUILTIN_CLOSURES, zero_float3(), kernel_data.film.use_light_pass); #ifdef __BRANCHED_PATH__ if (kernel_data.integrator.branched) @@ -757,7 +756,7 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg, kernel_assert(CLOSURE_IS_BSDF(sc->type)); int label; - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); *pdf = 0.0f; label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); @@ -787,7 +786,7 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, PROFILING_INIT(kg, PROFILING_CLOSURE_SAMPLE); int label; - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); *pdf = 0.0f; label = bsdf_sample(kg, sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); @@ -831,13 +830,13 @@ ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughn ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, const ShaderData *sd) { if (sd->flag & SD_HAS_ONLY_VOLUME) { - return make_float3(1.0f, 1.0f, 1.0f); + return one_float3(); } else if (sd->flag & SD_TRANSPARENT) { return sd->closure_transparent_extinction; } else { - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } } @@ -849,7 +848,7 @@ ccl_device void shader_bsdf_disable_transparency(KernelGlobals *kg, ShaderData * if (sc->type == CLOSURE_BSDF_TRANSPARENT_ID) { sc->sample_weight = 0.0f; - sc->weight = make_float3(0.0f, 0.0f, 0.0f); + sc->weight = zero_float3(); } } @@ -859,17 +858,17 @@ ccl_device void shader_bsdf_disable_transparency(KernelGlobals *kg, ShaderData * ccl_device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd) { - float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd); + float3 alpha = one_float3() - shader_bsdf_transparency(kg, sd); - alpha = max(alpha, make_float3(0.0f, 0.0f, 0.0f)); - alpha = min(alpha, make_float3(1.0f, 1.0f, 1.0f)); + alpha = max(alpha, zero_float3()); + alpha = min(alpha, one_float3()); return alpha; } ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) { - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -884,7 +883,7 @@ ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) { - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -898,7 +897,7 @@ ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) { - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -912,7 +911,7 @@ ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) ccl_device float3 shader_bsdf_average_normal(KernelGlobals *kg, ShaderData *sd) { - float3 N = make_float3(0.0f, 0.0f, 0.0f); + float3 N = zero_float3(); for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -925,8 +924,8 @@ ccl_device float3 shader_bsdf_average_normal(KernelGlobals *kg, ShaderData *sd) ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_factor, float3 *N_) { - float3 eval = make_float3(0.0f, 0.0f, 0.0f); - float3 N = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); + float3 N = zero_float3(); for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -945,8 +944,8 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac #ifdef __SUBSURFACE__ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_blur_) { - float3 eval = make_float3(0.0f, 0.0f, 0.0f); - float3 N = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); + float3 N = zero_float3(); float texture_blur = 0.0f, weight_sum = 0.0f; for (int i = 0; i < sd->num_closure; i++) { @@ -999,7 +998,7 @@ ccl_device float3 shader_background_eval(ShaderData *sd) return sd->closure_emission_background; } else { - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } } @@ -1011,7 +1010,7 @@ ccl_device float3 shader_emissive_eval(ShaderData *sd) return emissive_simple_eval(sd->Ng, sd->I) * sd->closure_emission_background; } else { - return make_float3(0.0f, 0.0f, 0.0f); + return zero_float3(); } } @@ -1019,13 +1018,13 @@ ccl_device float3 shader_emissive_eval(ShaderData *sd) ccl_device float3 shader_holdout_apply(KernelGlobals *kg, ShaderData *sd) { - float3 weight = make_float3(0.0f, 0.0f, 0.0f); + float3 weight = zero_float3(); /* For objects marked as holdout, preserve transparency and remove all other * closures, replacing them with a holdout weight. */ if (sd->object_flag & SD_OBJECT_HOLDOUT_MASK) { if ((sd->flag & SD_TRANSPARENT) && !(sd->flag & SD_HAS_ONLY_VOLUME)) { - weight = make_float3(1.0f, 1.0f, 1.0f) - sd->closure_transparent_extinction; + weight = one_float3() - sd->closure_transparent_extinction; for (int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; @@ -1037,7 +1036,7 @@ ccl_device float3 shader_holdout_apply(KernelGlobals *kg, ShaderData *sd) sd->flag &= ~(SD_CLOSURE_FLAGS - (SD_TRANSPARENT | SD_BSDF)); } else { - weight = make_float3(1.0f, 1.0f, 1.0f); + weight = one_float3(); } } else { @@ -1150,8 +1149,7 @@ ccl_device void shader_volume_phase_eval( { PROFILING_INIT(kg, PROFILING_CLOSURE_VOLUME_EVAL); - bsdf_eval_init( - eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass); + bsdf_eval_init(eval, NBUILTIN_CLOSURES, zero_float3(), kernel_data.film.use_light_pass); _shader_volume_phase_multi_eval(sd, omega_in, pdf, -1, eval, 0.0f, 0.0f); } @@ -1209,7 +1207,7 @@ ccl_device int shader_volume_phase_sample(KernelGlobals *kg, * depending on color channels, even if this is perhaps not a common case */ const ShaderClosure *sc = &sd->closure[sampled]; int label; - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); *pdf = 0.0f; label = volume_phase_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); @@ -1234,7 +1232,7 @@ ccl_device int shader_phase_sample_closure(KernelGlobals *kg, PROFILING_INIT(kg, PROFILING_CLOSURE_VOLUME_SAMPLE); int label; - float3 eval = make_float3(0.0f, 0.0f, 0.0f); + float3 eval = zero_float3(); *pdf = 0.0f; label = volume_phase_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h index 07043e6a769..3b124122fba 100644 --- a/intern/cycles/kernel/kernel_shadow.h +++ b/intern/cycles/kernel/kernel_shadow.h @@ -165,7 +165,7 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg, * shade them. */ if (!blocked && num_hits > 0) { - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); float3 Pend = ray->P + ray->D * ray->t; float last_t = 0.0f; int bounce = state->transparent_bounce; @@ -305,7 +305,7 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(KernelGlobals *kg, # endif # endif if (blocked && is_transparent_isect) { - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); float3 Pend = ray->P + ray->D * ray->t; int bounce = state->transparent_bounce; # ifdef __VOLUME__ @@ -390,7 +390,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, Ray *ray, float3 *shadow) { - *shadow = make_float3(1.0f, 1.0f, 1.0f); + *shadow = one_float3(); #if !defined(__KERNEL_OPTIX__) /* Some common early checks. * Avoid conditional trace call in OptiX though, since those hurt performance there. diff --git a/intern/cycles/kernel/kernel_subsurface.h b/intern/cycles/kernel/kernel_subsurface.h index d8258a8336c..55bbe7f95db 100644 --- a/intern/cycles/kernel/kernel_subsurface.h +++ b/intern/cycles/kernel/kernel_subsurface.h @@ -27,7 +27,7 @@ subsurface_scatter_eval(ShaderData *sd, const ShaderClosure *sc, float disk_r, f { /* this is the veach one-sample model with balance heuristic, some pdf * factors drop out when using balance heuristic weighting */ - float3 eval_sum = make_float3(0.0f, 0.0f, 0.0f); + float3 eval_sum = zero_float3(); float pdf_sum = 0.0f; float sample_weight_inv = 0.0f; @@ -62,7 +62,7 @@ subsurface_scatter_eval(ShaderData *sd, const ShaderClosure *sc, float disk_r, f } } - return (pdf_sum > 0.0f) ? eval_sum / pdf_sum : make_float3(0.0f, 0.0f, 0.0f); + return (pdf_sum > 0.0f) ? eval_sum / pdf_sum : zero_float3(); } /* replace closures with a single diffuse bsdf closure after scatter step */ @@ -107,7 +107,7 @@ ccl_device void subsurface_scatter_setup_diffuse_bsdf( /* optionally do blurring of color and/or bump mapping, at the cost of a shader evaluation */ ccl_device float3 subsurface_color_pow(float3 color, float exponent) { - color = max(color, make_float3(0.0f, 0.0f, 0.0f)); + color = max(color, zero_float3()); if (exponent == 1.0f) { /* nothing to do */ @@ -243,7 +243,7 @@ ccl_device_inline int subsurface_scatter_disk(KernelGlobals *kg, } #endif /* __OBJECT_MOTION__ */ else { - ss_isect->weight[hit] = make_float3(0.0f, 0.0f, 0.0f); + ss_isect->weight[hit] = zero_float3(); continue; } @@ -450,7 +450,7 @@ ccl_device_noinline /* Convert subsurface to volume coefficients. * The single-scattering albedo is named alpha to avoid confusion with the surface albedo. */ float3 sigma_t, alpha; - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float3 throughput = one_float3(); subsurface_random_walk_coefficients(sc, &sigma_t, &alpha, &throughput); float3 sigma_s = sigma_t * alpha; diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h index fdf712293e7..2e73da166b9 100644 --- a/intern/cycles/kernel/kernel_volume.h +++ b/intern/cycles/kernel/kernel_volume.h @@ -70,11 +70,9 @@ ccl_device_inline bool volume_shader_sample(KernelGlobals *kg, if (!(sd->flag & (SD_EXTINCTION | SD_SCATTER | SD_EMISSION))) return false; - coeff->sigma_s = make_float3(0.0f, 0.0f, 0.0f); - coeff->sigma_t = (sd->flag & SD_EXTINCTION) ? sd->closure_transparent_extinction : - make_float3(0.0f, 0.0f, 0.0f); - coeff->emission = (sd->flag & SD_EMISSION) ? sd->closure_emission_background : - make_float3(0.0f, 0.0f, 0.0f); + coeff->sigma_s = zero_float3(); + coeff->sigma_t = (sd->flag & SD_EXTINCTION) ? sd->closure_transparent_extinction : zero_float3(); + coeff->emission = (sd->flag & SD_EMISSION) ? sd->closure_emission_background : zero_float3(); if (sd->flag & SD_SCATTER) { for (int i = 0; i < sd->num_closure; i++) { @@ -204,7 +202,7 @@ ccl_device void kernel_volume_shadow_homogeneous(KernelGlobals *kg, ShaderData *sd, float3 *throughput) { - float3 sigma_t = make_float3(0.0f, 0.0f, 0.0f); + float3 sigma_t = zero_float3(); if (volume_shader_extinction_sample(kg, sd, state, ray->P, &sigma_t)) *throughput *= volume_color_transmittance(sigma_t, ray->t); @@ -230,7 +228,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg, /* compute extinction at the start */ float t = 0.0f; - float3 sum = make_float3(0.0f, 0.0f, 0.0f); + float3 sum = zero_float3(); for (int i = 0; i < max_steps; i++) { /* advance to new position */ @@ -243,7 +241,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg, } float3 new_P = ray->P + ray->D * (t + step_offset); - float3 sigma_t = make_float3(0.0f, 0.0f, 0.0f); + float3 sigma_t = zero_float3(); /* compute attenuation over segment */ if (volume_shader_extinction_sample(kg, sd, state, new_P, &sigma_t)) { @@ -365,8 +363,7 @@ ccl_device float kernel_volume_distance_sample( float sample_t = min(max_t, -logf(1.0f - xi * (1.0f - sample_transmittance)) / sample_sigma_t); *transmittance = volume_color_transmittance(sigma_t, sample_t); - *pdf = safe_divide_color(sigma_t * *transmittance, - make_float3(1.0f, 1.0f, 1.0f) - full_transmittance); + *pdf = safe_divide_color(sigma_t * *transmittance, one_float3() - full_transmittance); /* todo: optimization: when taken together with hit/miss decision, * the full_transmittance cancels out drops out and xi does not @@ -380,8 +377,7 @@ ccl_device float3 kernel_volume_distance_pdf(float max_t, float3 sigma_t, float float3 full_transmittance = volume_color_transmittance(sigma_t, max_t); float3 transmittance = volume_color_transmittance(sigma_t, sample_t); - return safe_divide_color(sigma_t * transmittance, - make_float3(1.0f, 1.0f, 1.0f) - full_transmittance); + return safe_divide_color(sigma_t * transmittance, one_float3() - full_transmittance); } /* Emission */ @@ -508,7 +504,7 @@ kernel_volume_integrate_homogeneous(KernelGlobals *kg, /* modify pdf for hit/miss decision */ if (probalistic_scatter) - pdf *= make_float3(1.0f, 1.0f, 1.0f) - volume_color_transmittance(coeff.sigma_t, t); + pdf *= one_float3() - volume_color_transmittance(coeff.sigma_t, t); new_tp = *throughput * coeff.sigma_s * transmittance / dot(channel_pdf, pdf); t = sample_t; @@ -578,7 +574,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg, /* compute coefficients at the start */ float t = 0.0f; - float3 accum_transmittance = make_float3(1.0f, 1.0f, 1.0f); + float3 accum_transmittance = one_float3(); /* pick random color channel, we use the Veach one-sample * model with balance heuristic for the channels */ @@ -654,7 +650,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg, new_tp = tp * transmittance; } else { - transmittance = make_float3(0.0f, 0.0f, 0.0f); + transmittance = zero_float3(); new_tp = tp; } @@ -671,7 +667,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg, /* stop if nearly all light blocked */ if (tp.x < tp_eps && tp.y < tp_eps && tp.z < tp_eps) { - tp = make_float3(0.0f, 0.0f, 0.0f); + tp = zero_float3(); break; } } @@ -811,10 +807,10 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, } /* init accumulation variables */ - float3 accum_emission = make_float3(0.0f, 0.0f, 0.0f); - float3 accum_transmittance = make_float3(1.0f, 1.0f, 1.0f); - float3 accum_albedo = make_float3(0.0f, 0.0f, 0.0f); - float3 cdf_distance = make_float3(0.0f, 0.0f, 0.0f); + float3 accum_emission = zero_float3(); + float3 accum_transmittance = one_float3(); + float3 accum_albedo = zero_float3(); + float3 cdf_distance = zero_float3(); float t = 0.0f; segment->numsteps = 0; @@ -880,8 +876,8 @@ ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, } else { /* store empty step */ - step->sigma_t = make_float3(0.0f, 0.0f, 0.0f); - step->sigma_s = make_float3(0.0f, 0.0f, 0.0f); + step->sigma_t = zero_float3(); + step->sigma_s = zero_float3(); step->closure_flag = 0; segment->numsteps++; @@ -1011,12 +1007,12 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(KernelGlobals * step = segment->steps; float prev_t = 0.0f; - float3 step_pdf_distance = make_float3(1.0f, 1.0f, 1.0f); + float3 step_pdf_distance = one_float3(); if (segment->numsteps > 1) { float prev_cdf = 0.0f; float step_cdf = 1.0f; - float3 prev_cdf_distance = make_float3(0.0f, 0.0f, 0.0f); + float3 prev_cdf_distance = zero_float3(); for (int i = 0;; i++, step++) { /* todo: optimize using binary search */ @@ -1047,7 +1043,7 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(KernelGlobals * /* modify pdf for hit/miss decision */ if (probalistic_scatter) - distance_pdf *= make_float3(1.0f, 1.0f, 1.0f) - segment->accum_transmittance; + distance_pdf *= one_float3() - segment->accum_transmittance; pdf = dot(channel_pdf, distance_pdf * step_pdf_distance); @@ -1066,10 +1062,10 @@ ccl_device VolumeIntegrateResult kernel_volume_decoupled_scatter(KernelGlobals * step = segment->steps; float prev_t = 0.0f; - float3 step_pdf_distance = make_float3(1.0f, 1.0f, 1.0f); + float3 step_pdf_distance = one_float3(); if (segment->numsteps > 1) { - float3 prev_cdf_distance = make_float3(0.0f, 0.0f, 0.0f); + float3 prev_cdf_distance = zero_float3(); int numsteps = segment->numsteps; int high = numsteps - 1; |