[Bf-blender-cvs] [a501a2dbff7] master: Images: add mirror extension type

2022-12-14 Thread Hallam Roberts
Commit: a501a2dbff797829b61f21c5aeb9d19dba3e3874
Author: Hallam Roberts
Date:   Wed Dec 14 19:19:52 2022 +0100
Branches: master
https://developer.blender.org/rBa501a2dbff797829b61f21c5aeb9d19dba3e3874

Images: add mirror extension type

This adds a new mirror image extension type for shaders and
geometry nodes (next to the existing repeat, extend and clip
options).

See D16432 for a more detailed explanation of `wrap_mirror`.

This also adds a new sampler flag `GPU_SAMPLER_MIRROR_REPEAT`.
It acts as a modifier to `GPU_SAMPLER_REPEAT`, so any `REPEAT`
flag must be set for the `MIRROR` flag to have an effect.

Differential Revision: https://developer.blender.org/D16432

===

M   intern/cycles/device/cuda/device_impl.cpp
M   intern/cycles/device/hip/device_impl.cpp
M   intern/cycles/device/metal/device_impl.mm
M   intern/cycles/kernel/device/cpu/image.h
M   intern/cycles/kernel/device/metal/compat.h
M   intern/cycles/kernel/device/metal/context_begin.h
M   intern/cycles/kernel/device/oneapi/image.h
M   intern/cycles/scene/shader_nodes.cpp
M   intern/cycles/util/texture.h
M   source/blender/draw/engines/workbench/workbench_materials.cc
M   source/blender/gpu/GPU_texture.h
M   source/blender/gpu/metal/mtl_context.mm
M   source/blender/gpu/opengl/gl_texture.cc
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/geometry/nodes/node_geo_image_texture.cc
M   source/blender/nodes/shader/nodes/node_shader_tex_image.cc

===

diff --git a/intern/cycles/device/cuda/device_impl.cpp 
b/intern/cycles/device/cuda/device_impl.cpp
index c9764d1c21b..f354ba6aee1 100644
--- a/intern/cycles/device/cuda/device_impl.cpp
+++ b/intern/cycles/device/cuda/device_impl.cpp
@@ -952,6 +952,9 @@ void CUDADevice::tex_alloc(device_texture )
 case EXTENSION_CLIP:
   address_mode = CU_TR_ADDRESS_MODE_BORDER;
   break;
+case EXTENSION_MIRROR:
+  address_mode = CU_TR_ADDRESS_MODE_MIRROR;
+  break;
 default:
   assert(0);
   break;
diff --git a/intern/cycles/device/hip/device_impl.cpp 
b/intern/cycles/device/hip/device_impl.cpp
index a84f1edd70e..04de8619697 100644
--- a/intern/cycles/device/hip/device_impl.cpp
+++ b/intern/cycles/device/hip/device_impl.cpp
@@ -909,6 +909,9 @@ void HIPDevice::tex_alloc(device_texture )
* because it's unsupported in HIP. */
   address_mode = hipAddressModeClamp;
   break;
+case EXTENSION_MIRROR:
+  address_mode = hipAddressModeMirror;
+  break;
 default:
   assert(0);
   break;
diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index 24836e88755..95935ce2a3a 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -856,7 +856,7 @@ void MetalDevice::tex_alloc(device_texture )
   /* sampler_index maps into the GPU's constant 'metal_samplers' array */
   uint64_t sampler_index = mem.info.extension;
   if (mem.info.interpolation != INTERPOLATION_CLOSEST) {
-sampler_index += 3;
+sampler_index += 4;
   }
 
   /* Image Texture Storage */
diff --git a/intern/cycles/kernel/device/cpu/image.h 
b/intern/cycles/kernel/device/cpu/image.h
index 320e6309128..eb50ac8217f 100644
--- a/intern/cycles/kernel/device/cpu/image.h
+++ b/intern/cycles/kernel/device/cpu/image.h
@@ -202,6 +202,14 @@ template struct 
TextureInterpolator {
 return clamp(x, 0, width - 1);
   }
 
+  static ccl_always_inline int wrap_mirror(int x, int width)
+  {
+const int m = abs(x + (x < 0)) % (2 * width);
+if (m >= width)
+  return 2 * width - m - 1;
+return m;
+  }
+
   /*   2D interpolation  */
 
   static ccl_always_inline OutT interp_closest(const TextureInfo , float 
x, float y)
@@ -226,6 +234,10 @@ template struct 
TextureInterpolator {
 ix = wrap_clamp(ix, width);
 iy = wrap_clamp(iy, height);
 break;
+  case EXTENSION_MIRROR:
+ix = wrap_mirror(ix, width);
+iy = wrap_mirror(iy, height);
+break;
   default:
 kernel_assert(0);
 return zero();
@@ -268,6 +280,12 @@ template struct 
TextureInterpolator {
 niy = wrap_clamp(iy + 1, height);
 iy = wrap_clamp(iy, height);
 break;
+  case EXTENSION_MIRROR:
+nix = wrap_mirror(ix + 1, width);
+ix = wrap_mirror(ix, width);
+niy = wrap_mirror(iy + 1, height);
+iy = wrap_mirror(iy, height);
+break;
   default:
 kernel_assert(0);
 return zero();
@@ -331,6 +349,17 @@ template struct 
TextureInterpolator {
 nniy = wrap_clamp(iy + 2, height);
 iy = wrap_clamp(iy, height);
 break;
+  case EXTENSION_MIRROR:
+pix = wrap_mirror(ix - 1, width);
+ 

[Bf-blender-cvs] [8799ab201d3] blender-v3.4-release: Fix T96481: make color picker RGB display consistent

2022-11-11 Thread Hallam Roberts
Commit: 8799ab201d332ff2fe1a52815b595152639fdcb7
Author: Hallam Roberts
Date:   Fri Nov 11 15:50:35 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB8799ab201d332ff2fe1a52815b595152639fdcb7

Fix T96481: make color picker RGB display consistent

Show RGB value "1.000" instead of "1", jus like HSV mode. Also uses full labels
"Red", "Green" and "Blue" rather than the shortened labels "R", "G" and "B",
for both RGB and HSV.

Differential Revision: https://developer.blender.org/D14387

===

M   source/blender/editors/interface/interface_region_color_picker.cc

===

diff --git a/source/blender/editors/interface/interface_region_color_picker.cc 
b/source/blender/editors/interface/interface_region_color_picker.cc
index 0b2c538331a..8b28e9fece1 100644
--- a/source/blender/editors/interface/interface_region_color_picker.cc
+++ b/source/blender/editors/interface/interface_region_color_picker.cc
@@ -199,7 +199,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but,
* push, so disable it on RNA buttons in the color picker block */
   UI_but_flag_disable(bt, UI_BUT_UNDO);
 }
-else if (STREQ(bt->str, "Hex: ")) {
+else if (STREQ(bt->str, "Hex:")) {
   float rgb_hex[3];
   uchar rgb_hex_uchar[3];
   char col[16];
@@ -613,7 +613,7 @@ static void ui_block_colorpicker(uiBlock *block,
   bt = uiDefButR_prop(block,
   UI_BTYPE_NUM_SLIDER,
   0,
-  IFACE_("R:"),
+  IFACE_("Red:"),
   0,
   yco,
   butwidth,
@@ -623,7 +623,7 @@ static void ui_block_colorpicker(uiBlock *block,
   0,
   0.0,
   0.0,
-  0,
+  10,
   3,
   TIP_("Red"));
   UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
@@ -631,7 +631,7 @@ static void ui_block_colorpicker(uiBlock *block,
   bt = uiDefButR_prop(block,
   UI_BTYPE_NUM_SLIDER,
   0,
-  IFACE_("G:"),
+  IFACE_("Green:"),
   0,
   yco -= UI_UNIT_Y,
   butwidth,
@@ -641,7 +641,7 @@ static void ui_block_colorpicker(uiBlock *block,
   1,
   0.0,
   0.0,
-  0,
+  10,
   3,
   TIP_("Green"));
   UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
@@ -649,7 +649,7 @@ static void ui_block_colorpicker(uiBlock *block,
   bt = uiDefButR_prop(block,
   UI_BTYPE_NUM_SLIDER,
   0,
-  IFACE_("B:"),
+  IFACE_("Blue:"),
   0,
   yco -= UI_UNIT_Y,
   butwidth,
@@ -659,7 +659,7 @@ static void ui_block_colorpicker(uiBlock *block,
   2,
   0.0,
   0.0,
-  0,
+  10,
   3,
   TIP_("Blue"));
   UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
@@ -675,7 +675,7 @@ static void ui_block_colorpicker(uiBlock *block,
   bt = uiDefButF(block,
  UI_BTYPE_NUM_SLIDER,
  0,
- IFACE_("H:"),
+ IFACE_("Hue:"),
  0,
  yco,
  butwidth,
@@ -692,7 +692,7 @@ static void ui_block_colorpicker(uiBlock *block,
   bt = uiDefButF(block,
  UI_BTYPE_NUM_SLIDER,
  0,
- IFACE_("S:"),
+ IFACE_("Saturation:"),
  0,
  yco -= UI_UNIT_Y,
  butwidth,
@@ -710,7 +710,7 @@ static void ui_block_colorpicker(uiBlock *block,
 bt = uiDefButF(block,
UI_BTYPE_NUM_SLIDER,
0,
-   IFACE_("L:"),
+   IFACE_("Lightness:"),
0,
yco -= UI_UNIT_Y,
butwidth,
@@ -726,7 +726,7 @@ static void ui_block_colorpicker(uiBlock *block,
 bt = uiDefButF(block,
UI_BTYPE_NUM_SLIDER,
0,
-   IFACE_("V:"),
+   IFACE_("Value:"),
0,
yco -= UI_UNIT_Y,
butwidth,
@@ -750,

[Bf-blender-cvs] [82df48227bb] master: Nodes: Add general Combine/Separate Color nodes

2022-05-04 Thread Hallam Roberts
Commit: 82df48227bb7742466d429a5b465e0ada95d959d
Author: Hallam Roberts
Date:   Wed May 4 18:44:03 2022 +0200
Branches: master
https://developer.blender.org/rB82df48227bb7742466d429a5b465e0ada95d959d

Nodes: Add general Combine/Separate Color nodes

Inspired by D12936 and D12929, this patch adds general purpose
"Combine Color" and "Separate Color" nodes to Geometry, Compositor,
Shader and Texture nodes.
- Within Geometry Nodes, it replaces the existing "Combine RGB" and
  "Separate RGB" nodes.
- Within Compositor Nodes, it replaces the existing
  "Combine RGBA/HSVA/YCbCrA/YUVA" and "Separate RGBA/HSVA/YCbCrA/YUVA"
  nodes.
- Within Texture Nodes, it replaces the existing "Combine RGBA" and
  "Separate RGBA" nodes.
- Within Shader Nodes, it replaces the existing "Combine RGB/HSV" and
  "Separate RGB/HSV" nodes.

Python addons have not been updated to the new nodes yet.

**New shader code**
In node_color.h, color.h and gpu_shader_material_color_util.glsl,
missing methods hsl_to_rgb and rgb_to_hsl are added by directly
converting existing C code. They always produce the same result.

**Old code**
As requested by T96219, old nodes still exist but are not displayed in
the add menu. This means Python scripts can still create them as usual.
Otherwise, versioning replaces the old nodes with the new nodes when
opening .blend files.

Differential Revision: https://developer.blender.org/D14034

===

M   intern/cycles/blender/shader.cpp
M   intern/cycles/kernel/CMakeLists.txt
M   intern/cycles/kernel/osl/shaders/CMakeLists.txt
M   intern/cycles/kernel/osl/shaders/node_color.h
A   intern/cycles/kernel/osl/shaders/node_combine_color.osl
A   intern/cycles/kernel/osl/shaders/node_separate_color.osl
M   intern/cycles/kernel/svm/color_util.h
A   intern/cycles/kernel/svm/sepcomb_color.h
M   intern/cycles/kernel/svm/svm.h
M   intern/cycles/kernel/svm/types.h
M   intern/cycles/scene/shader_nodes.cpp
M   intern/cycles/scene/shader_nodes.h
M   intern/cycles/util/color.h
M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/blenlib/intern/math_color.c
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/compositor/CMakeLists.txt
M   source/blender/compositor/intern/COM_Converter.cc
M   source/blender/compositor/nodes/COM_CombineColorNode.cc
M   source/blender/compositor/nodes/COM_CombineColorNode.h
A   source/blender/compositor/nodes/COM_CombineColorNodeLegacy.cc
A   source/blender/compositor/nodes/COM_CombineColorNodeLegacy.h
M   source/blender/compositor/nodes/COM_SeparateColorNode.cc
M   source/blender/compositor/nodes/COM_SeparateColorNode.h
A   source/blender/compositor/nodes/COM_SeparateColorNodeLegacy.cc
A   source/blender/compositor/nodes/COM_SeparateColorNodeLegacy.h
M   source/blender/compositor/operations/COM_ConvertOperation.cc
M   source/blender/compositor/operations/COM_ConvertOperation.h
M   source/blender/editors/space_node/drawnode.cc
M   source/blender/gpu/CMakeLists.txt
M   source/blender/gpu/shaders/material/gpu_shader_material_color_util.glsl
A   
source/blender/gpu/shaders/material/gpu_shader_material_combine_color.glsl
A   
source/blender/gpu/shaders/material/gpu_shader_material_separate_color.glsl
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/NOD_composite.h
M   source/blender/nodes/NOD_function.h
M   source/blender/nodes/NOD_shader.h
M   source/blender/nodes/NOD_static_types.h
M   source/blender/nodes/NOD_texture.h
M   source/blender/nodes/composite/CMakeLists.txt
A   source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc
M   source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc
M   source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc
M   source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc
M   source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc
M   source/blender/nodes/function/CMakeLists.txt
A   source/blender/nodes/function/nodes/node_fn_combine_color.cc
A   source/blender/nodes/function/nodes/node_fn_separate_color.cc
M   source/blender/nodes/intern/node_util.c
M   source/blender/nodes/intern/node_util.h
M   source/blender/nodes/shader/CMakeLists.txt
A   source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc
M   source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc
M   source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc
M   source/blender/nodes/texture/CMakeLists.txt
A   source/blender/nodes/texture/nodes/node_text

[Bf-blender-cvs] [7dc4ac71e8d] master: Fix T97278: wrong hair particle shape with kink spiral

2022-04-13 Thread Hallam Roberts
Commit: 7dc4ac71e8dcbd801ca9d375cdd1bea88e6293ac
Author: Hallam Roberts
Date:   Wed Apr 13 16:23:38 2022 +0200
Branches: master
https://developer.blender.org/rB7dc4ac71e8dcbd801ca9d375cdd1bea88e6293ac

Fix T97278: wrong hair particle shape with kink spiral

Revert change from 3da84d8b that incorrectly used M_PI_4.

Differential Revision: https://developer.blender.org/D14636

===

M   source/blender/blenkernel/intern/particle_child.c

===

diff --git a/source/blender/blenkernel/intern/particle_child.c 
b/source/blender/blenkernel/intern/particle_child.c
index 5dba4d3f003..524ee31229b 100644
--- a/source/blender/blenkernel/intern/particle_child.c
+++ b/source/blender/blenkernel/intern/particle_child.c
@@ -85,7 +85,7 @@ static void do_kink_spiral_deform(ParticleKey *state,
  * and goes up to the Golden Spiral for 1.0
  * https://en.wikipedia.org/wiki/Golden_spiral
  */
-const float b = shape * (1.0f + sqrtf(5.0f)) / (float)M_PI_4;
+const float b = shape * (1.0f + sqrtf(5.0f)) / (float)M_PI * 0.25f;
 /* angle of the spiral against the curve (rotated opposite to make a 
smooth transition) */
 const float start_angle = ((b != 0.0f) ? atanf(1.0f / b) : (float)-M_PI_2) 
+
   (b > 0.0f ? -(float)M_PI_2 : (float)M_PI_2);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c7e25a25b06] master: Fix T96132: Cycles RGB/Vector/Float Curve shaders ignore extrapolation setting

2022-03-21 Thread Hallam Roberts
Commit: c7e25a25b06659ed41e9f4ee101a0980135cdb24
Author: Hallam Roberts
Date:   Mon Mar 21 17:33:24 2022 +0100
Branches: master
https://developer.blender.org/rBc7e25a25b06659ed41e9f4ee101a0980135cdb24

Fix T96132: Cycles RGB/Vector/Float Curve shaders ignore extrapolation setting

Differential Revision: https://developer.blender.org/D14393

===

M   intern/cycles/blender/shader.cpp
M   intern/cycles/kernel/osl/shaders/node_float_curve.osl
M   intern/cycles/kernel/osl/shaders/node_rgb_curves.osl
M   intern/cycles/kernel/osl/shaders/node_vector_curves.osl
M   intern/cycles/kernel/svm/ramp.h
M   intern/cycles/scene/shader_nodes.cpp
M   intern/cycles/scene/shader_nodes.h

===

diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp
index ec50ad9db9a..224cbea85f3 100644
--- a/intern/cycles/blender/shader.cpp
+++ b/intern/cycles/blender/shader.cpp
@@ -271,6 +271,7 @@ static ShaderNode *add_node(Scene *scene,
 curves->set_min_x(min_x);
 curves->set_max_x(max_x);
 curves->set_curves(curve_mapping_curves);
+curves->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
 node = curves;
   }
   if (b_node.is_a(_ShaderNodeVectorCurve)) {
@@ -284,6 +285,7 @@ static ShaderNode *add_node(Scene *scene,
 curves->set_min_x(min_x);
 curves->set_max_x(max_x);
 curves->set_curves(curve_mapping_curves);
+curves->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
 node = curves;
   }
   else if (b_node.is_a(_ShaderNodeFloatCurve)) {
@@ -297,6 +299,7 @@ static ShaderNode *add_node(Scene *scene,
 curve->set_min_x(min_x);
 curve->set_max_x(max_x);
 curve->set_curve(curve_mapping_curve);
+curve->set_extrapolate(mapping.extend() == mapping.extend_EXTRAPOLATED);
 node = curve;
   }
   else if (b_node.is_a(_ShaderNodeValToRGB)) {
diff --git a/intern/cycles/kernel/osl/shaders/node_float_curve.osl 
b/intern/cycles/kernel/osl/shaders/node_float_curve.osl
index 265a21bd4aa..70de1217877 100644
--- a/intern/cycles/kernel/osl/shaders/node_float_curve.osl
+++ b/intern/cycles/kernel/osl/shaders/node_float_curve.osl
@@ -7,13 +7,15 @@
 shader node_float_curve(float ramp[] = {0.0},
 float min_x = 0.0,
 float max_x = 1.0,
+int extrapolate = 1,
+
 float ValueIn = 0.0,
 float Factor = 0.0,
 output float ValueOut = 0.0)
 {
   float c = (ValueIn - min_x) / (max_x - min_x);
 
-  ValueOut = rgb_ramp_lookup(ramp, c, 1, 1);
+  ValueOut = rgb_ramp_lookup(ramp, c, 1, extrapolate);
 
   ValueOut = mix(ValueIn, ValueOut, Factor);
 }
diff --git a/intern/cycles/kernel/osl/shaders/node_rgb_curves.osl 
b/intern/cycles/kernel/osl/shaders/node_rgb_curves.osl
index b73c74801ee..388fdd05b70 100644
--- a/intern/cycles/kernel/osl/shaders/node_rgb_curves.osl
+++ b/intern/cycles/kernel/osl/shaders/node_rgb_curves.osl
@@ -7,6 +7,7 @@
 shader node_rgb_curves(color ramp[] = {0.0},
float min_x = 0.0,
float max_x = 1.0,
+   int extrapolate = 1,
 
color ColorIn = 0.0,
float Fac = 0.0,
@@ -14,9 +15,9 @@ shader node_rgb_curves(color ramp[] = {0.0},
 {
   color c = (ColorIn - color(min_x, min_x, min_x)) / (max_x - min_x);
 
-  color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
-  color g = rgb_ramp_lookup(ramp, c[1], 1, 1);
-  color b = rgb_ramp_lookup(ramp, c[2], 1, 1);
+  color r = rgb_ramp_lookup(ramp, c[0], 1, extrapolate);
+  color g = rgb_ramp_lookup(ramp, c[1], 1, extrapolate);
+  color b = rgb_ramp_lookup(ramp, c[2], 1, extrapolate);
 
   ColorOut[0] = r[0];
   ColorOut[1] = g[1];
diff --git a/intern/cycles/kernel/osl/shaders/node_vector_curves.osl 
b/intern/cycles/kernel/osl/shaders/node_vector_curves.osl
index a3bf1209e6e..3ef720ad6d6 100644
--- a/intern/cycles/kernel/osl/shaders/node_vector_curves.osl
+++ b/intern/cycles/kernel/osl/shaders/node_vector_curves.osl
@@ -7,6 +7,7 @@
 shader node_vector_curves(color ramp[] = {0.0},
   float min_x = 0.0,
   float max_x = 1.0,
+  int extrapolate = 1,
 
   vector VectorIn = vector(0.0, 0.0, 0.0),
   float Fac = 0.0,
@@ -14,9 +15,9 @@ shader node_vector_curves(color ramp[] = {0.0},
 {
   vector c = (VectorIn - vector(min_x, min_x, min_x)) / (max_x - min_x);
 
-  color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
-  color g = rgb_ramp_lookup(ramp, c[0], 1, 1);
-  color b = rgb_ramp_lookup(ramp, c[0], 1, 1);
+  color r = rgb_ramp_lookup(ramp, c[0], 1, extrapolate);
+  color g = rgb_ramp_lookup(ramp, c[0], 1, extrapolate);
+  color b = rgb_ramp_lookup(ramp, c[0], 1, e

[Bf-blender-cvs] [c5456819ee4] master: Fix T96655: Bloom crashes Eevee

2022-03-21 Thread Hallam Roberts
Commit: c5456819ee4904b6b1ec59b3f4ef705d29f170ac
Author: Hallam Roberts
Date:   Mon Mar 21 13:18:22 2022 +0100
Branches: master
https://developer.blender.org/rBc5456819ee4904b6b1ec59b3f4ef705d29f170ac

Fix T96655: Bloom crashes Eevee

This patch fixes T96655, bloom crashing Eevee.

The error occurs because rB472fc0c55848b2e2d428cfb4f7debb80a4e12081 added `vec3 
safe_color(vec3 c)` to `common_math_lib.glsl`.

However, `vec3 safe_color(vec3 c)` already exists in `effect_bloom_frag.glsl`.
This means `vec3 safe_color(vec3 c)` is duplicated within 
`common_math_lib.glsl` and `effect_bloom_frag.glsl`.

{F12938060 size=full}

The duplicate code in `effect_bloom_frag.glsl` can be removed since it's no 
longer needed.

(I checked the remaining methods, there shouldn't be any additional duplicate 
code)

Reviewed By: fclem

Maniphest Tasks: T96655

Differential Revision: https://developer.blender.org/D14396

===

M   release/scripts/addons
M   source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl

===

diff --git a/release/scripts/addons b/release/scripts/addons
index bb62f10715a..67f1fbca148 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit bb62f10715a871d7069d2b2c74b2efc97c3c350c
+Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl 
b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
index c6f61d1d443..9d9d7beb3cb 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
@@ -50,12 +50,6 @@ out vec4 FragColor;
 
 /* -- Utils - */
 
-vec3 safe_color(vec3 c)
-{
-  /* Clamp to avoid black square artifacts if a pixel goes NaN. */
-  return clamp(c, vec3(0.0), vec3(1e20)); /* 1e20 arbitrary. */
-}
-
 /* 3-tap median filter */
 vec3 median(vec3 a, vec3 b, vec3 c)
 {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3da84d8b086] master: Cleanup: use M_PI_2 and M_PI_4 where possible

2022-03-11 Thread Hallam Roberts
Commit: 3da84d8b086bd2d09beb5bdb89ba6beddf1e1dd6
Author: Hallam Roberts
Date:   Fri Mar 11 16:14:05 2022 +0100
Branches: master
https://developer.blender.org/rB3da84d8b086bd2d09beb5bdb89ba6beddf1e1dd6

Cleanup: use M_PI_2 and M_PI_4 where possible

The constant M_PI_4 is added to GLSL to ensure it works there too.

Differential Revision: https://developer.blender.org/D14288

===

M   intern/ghost/intern/GHOST_Wintab.cpp
M   intern/iksolver/intern/IK_QJacobian.cpp
M   source/blender/blenkernel/intern/armature_test.cc
M   source/blender/blenkernel/intern/mask.c
M   source/blender/blenkernel/intern/particle_child.c
M   source/blender/blenlib/intern/math_base_inline.c
M   source/blender/blenlib/intern/math_vector.c
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/bmesh/tools/bmesh_bevel.c
M   source/blender/draw/engines/eevee/eevee_lightprobes.c
M   source/blender/draw/engines/eevee/eevee_lookdev.c
M   source/blender/draw/engines/eevee/shaders/effect_dof_scatter_vert.glsl
M   source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
M   source/blender/draw/engines/gpencil/gpencil_draw_data.c
M   source/blender/draw/engines/workbench/workbench_effect_dof.c
M   source/blender/draw/intern/shaders/common_math_lib.glsl
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
M   source/blender/editors/space_view3d/view3d_navigate.c
M   source/blender/editors/uvedit/uvedit_parametrizer.c
M   source/blender/freestyle/intern/geometry/matrix_util.cpp
M   source/blender/freestyle/intern/winged_edge/Curvature.cpp
M   source/blender/freestyle/intern/winged_edge/WEdge.h
M   source/blender/gpu/intern/gpu_immediate_util.c
M   source/blender/io/collada/collada_internal.cpp
M   source/blender/io/usd/intern/usd_capi_import.cc
M   source/blender/makesdna/DNA_modifier_defaults.h
M   source/blender/makesrna/intern/rna_brush.c
M   source/blender/makesrna/intern/rna_camera.c
M   source/blender/makesrna/intern/rna_cloth.c

===

diff --git a/intern/ghost/intern/GHOST_Wintab.cpp 
b/intern/ghost/intern/GHOST_Wintab.cpp
index aaf9503b294..2547a38c0d1 100644
--- a/intern/ghost/intern/GHOST_Wintab.cpp
+++ b/intern/ghost/intern/GHOST_Wintab.cpp
@@ -326,7 +326,7 @@ void 
GHOST_Wintab::getInput(std::vector )
   ORIENTATION ort = pkt.pkOrientation;
 
   /* Convert raw fixed point data to radians. */
-  float altRad = (float)((fabs((float)ort.orAltitude) / 
(float)m_maxAltitude) * M_PI / 2.0);
+  float altRad = (float)((fabs((float)ort.orAltitude) / 
(float)m_maxAltitude) * M_PI_2);
   float azmRad = (float)(((float)ort.orAzimuth / (float)m_maxAzimuth) * 
M_PI * 2.0);
 
   /* Find length of the stylus' projected vector on the XY plane. */
@@ -334,7 +334,7 @@ void 
GHOST_Wintab::getInput(std::vector )
 
   /* From there calculate X and Y components based on azimuth. */
   out.tabletData.Xtilt = sin(azmRad) * vecLen;
-  out.tabletData.Ytilt = (float)(sin(M_PI / 2.0 - azmRad) * vecLen);
+  out.tabletData.Ytilt = (float)(sin(M_PI_2 - azmRad) * vecLen);
 }
 
 out.time = pkt.pkTime;
diff --git a/intern/iksolver/intern/IK_QJacobian.cpp 
b/intern/iksolver/intern/IK_QJacobian.cpp
index 39c0e6eb348..ea659414b73 100644
--- a/intern/iksolver/intern/IK_QJacobian.cpp
+++ b/intern/iksolver/intern/IK_QJacobian.cpp
@@ -193,7 +193,7 @@ void IK_QJacobian::InvertSDLS()
   // DLS. The SDLS damps individual singular values, instead of using a single
   // damping term.
 
-  double max_angle_change = M_PI / 4.0;
+  double max_angle_change = M_PI_4;
   double epsilon = 1e-10;
   int i, j;
 
diff --git a/source/blender/blenkernel/intern/armature_test.cc 
b/source/blender/blenkernel/intern/armature_test.cc
index 7475e6f36d4..4d266c8493a 100644
--- a/source/blender/blenkernel/intern/armature_test.cc
+++ b/source/blender/blenkernel/intern/armature_test.cc
@@ -285,7 +285,7 @@ TEST(vec_roll_to_mat3_normalized, Roll1)
   const float expected_roll_mat[3][3] = {{0.211324856f, 0.577350259f, 
-0.788675129f},
  {0.577350259f, 0.577350259f, 
0.577350259f},
  {0.788675129f, -0.577350259f, 
-0.211324856f}};
-  test_vec_roll_to_mat3_normalized(input, float(M_PI * 0.5), 
expected_roll_mat);
+  test_vec_roll_to_mat3_normalized(input, float(M_PI_2), expected_roll_mat);
 }
 
 /** Test that the matrix is orthogonal for an input close to -Y. */
diff --git a/source/blender/blenkernel/intern/mask.c 
b/source/blender/blenkernel/intern/mask.c
index da0f899001c..42e65a95404 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -609,7 +609,7 @@ float BKE_mask_spline_project_co(MaskSpline

[Bf-blender-cvs] [156e07232e7] master: Geometry Nodes: Tiny optimization to UV Sphere primitive

2022-03-08 Thread Hallam Roberts
Commit: 156e07232e79d53fa3f43d4bcfc4b0c4061331e5
Author: Hallam Roberts
Date:   Tue Mar 8 14:39:58 2022 -0600
Branches: master
https://developer.blender.org/rB156e07232e79d53fa3f43d4bcfc4b0c4061331e5

Geometry Nodes: Tiny optimization to UV Sphere primitive

Prevents a few unneeded calls to `std::sin`, with an observed
performance improvement of about 1 percent.

Differential Revision: https://developer.blender.org/D14279

===

M   source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc 
b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
index 4a09fd8d1d2..4e0e5c7c912 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
@@ -76,10 +76,10 @@ static void calculate_sphere_vertex_data(MutableSpan 
verts,
   int vert_index = 1;
   for (const int ring : IndexRange(1, rings - 1)) {
 const float theta = ring * delta_theta;
+const float sin_theta = std::sin(theta);
 const float z = std::cos(theta);
 for (const int segment : IndexRange(1, segments)) {
   const float phi = segment * delta_phi;
-  const float sin_theta = std::sin(theta);
   const float x = sin_theta * std::cos(phi);
   const float y = sin_theta * std::sin(phi);
   copy_v3_v3(verts[vert_index].co, float3(x, y, z) * radius);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [14f6afb0900] master: Geometry Nodes: Expand the Boolean Math node

2022-01-25 Thread Hallam Roberts
Commit: 14f6afb09003903a25872e6b05c67411db5e5267
Author: Hallam Roberts
Date:   Tue Jan 25 09:09:39 2022 -0600
Branches: master
https://developer.blender.org/rB14f6afb09003903a25872e6b05c67411db5e5267

Geometry Nodes: Expand the Boolean Math node

Currently the Boolean Math node only has 3 basic logic gates:
AND, OR, and NOT. This commit adds 6 additional logic gates
for convenience and ease of use.

- **Not And (NAND)** returns true when at least one input is false.
- **Nor (NOR)** returns true when both inputs are false.
- **Equal (XNOR)** returns true when both inputs are equal.
- **Not Equal (XOR)** returns true when both inputs are different.
- **Imply (IMPLY)** returns true unless the first input is true and
  the second is false.
- **Subtract (NIMPLY)** returns true when the first input is true and
  the second is false.

Differential Revision: https://developer.blender.org/D13774

===

M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/function/nodes/node_fn_boolean_math.cc

===

diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index 13f332f83fd..34252715545 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1931,6 +1931,14 @@ enum {
   NODE_BOOLEAN_MATH_AND = 0,
   NODE_BOOLEAN_MATH_OR = 1,
   NODE_BOOLEAN_MATH_NOT = 2,
+
+  NODE_BOOLEAN_MATH_NAND = 3,
+  NODE_BOOLEAN_MATH_NOR = 4,
+  NODE_BOOLEAN_MATH_XNOR = 5,
+  NODE_BOOLEAN_MATH_XOR = 6,
+
+  NODE_BOOLEAN_MATH_IMPLY = 7,
+  NODE_BOOLEAN_MATH_NIMPLY = 8,
 };
 
 /** Float compare node operations. */
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 117b9dbd983..536b2f7aa6e 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -300,9 +300,33 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = {
 };
 
 const EnumPropertyItem rna_enum_node_boolean_math_items[] = {
-{NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "Outputs true only when both 
inputs are true"},
-{NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "Outputs or when at least one of the 
inputs is true"},
-{NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Outputs the opposite of the 
input"},
+{NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "True when both inputs are true"},
+{NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "True when at least one input is 
true"},
+{NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Opposite of the input"},
+{0, "", ICON_NONE, NULL, NULL},
+{NODE_BOOLEAN_MATH_NAND, "NAND", 0, "Not And", "True when at least one 
input is false"},
+{NODE_BOOLEAN_MATH_NOR, "NOR", 0, "Nor", "True when both inputs are 
false"},
+{NODE_BOOLEAN_MATH_XNOR,
+ "XNOR",
+ 0,
+ "Equal",
+ "True when both inputs are equal (exclusive nor)"},
+{NODE_BOOLEAN_MATH_XOR,
+ "XOR",
+ 0,
+ "Not Equal",
+ "True when both inputs are different (exclusive or)"},
+{0, "", ICON_NONE, NULL, NULL},
+{NODE_BOOLEAN_MATH_IMPLY,
+ "IMPLY",
+ 0,
+ "Imply",
+ "True unless the first input is true and the second is false"},
+{NODE_BOOLEAN_MATH_NIMPLY,
+ "NIMPLY",
+ 0,
+ "Subtract",
+ "True when the first input is true and the second is false (not imply)"},
 {0, NULL, 0, NULL, NULL},
 };
 
diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc 
b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
index cd05f07d392..15b0bab22b7 100644
--- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
+++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc
@@ -43,8 +43,7 @@ static void node_boolean_math_update(bNodeTree *ntree, bNode 
*node)
 {
   bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(>inputs, 1);
 
-  nodeSetSocketAvailability(
-  ntree, sockB, ELEM(node->custom1, NODE_BOOLEAN_MATH_AND, 
NODE_BOOLEAN_MATH_OR));
+  nodeSetSocketAvailability(ntree, sockB, !ELEM(node->custom1, 
NODE_BOOLEAN_MATH_NOT));
 }
 
 static void node_boolean_math_label(const bNodeTree *UNUSED(ntree),
@@ -67,6 +66,18 @@ static const fn::MultiFunction *get_multi_function(bNode 
)
   static fn::CustomMF_SI_SI_SO or_fn{"Or",
[](bool a, bool b) { 
return a || b; }};
   static fn::Custo