[Bf-blender-cvs] [16afe3a17fa] temp-geometry-nodes-delete-geometry-image-texture: Geometry Nodes: Add Image texture node (WIP)
Charlie Jolly
noreply at git.blender.org
Thu Oct 7 09:12:27 CEST 2021
Commit: 16afe3a17fa6c65eea94ba99ee44882da25b2ba6
Author: Charlie Jolly
Date: Thu Oct 7 09:11:39 2021 +0200
Branches: temp-geometry-nodes-delete-geometry-image-texture
https://developer.blender.org/rB16afe3a17fa6c65eea94ba99ee44882da25b2ba6
Geometry Nodes: Add Image texture node (WIP)
Port shader image texture node
**Core devs: Please take over if you want to.**
{F10797876}
Differential Revision: https://developer.blender.org/D12734
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenlib/BLI_float2.hh
M source/blender/blenlib/BLI_float3.hh
M source/blender/blenlib/BLI_float4.hh
M source/blender/modifiers/intern/MOD_nodes_evaluator.cc
M source/blender/nodes/CMakeLists.txt
D source/blender/nodes/shader/nodes/node_shader_tex_image.c
A source/blender/nodes/shader/nodes/node_shader_tex_image.cc
M source/tools
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 4833954c0ac..3d01b77226f 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 4833954c0ac85cc407e1d5a153aa11b1d1823ec0
+Subproject commit 3d01b77226fcd99024ffaa0c12a6c14f22914d9f
diff --git a/release/scripts/addons b/release/scripts/addons
index f86f25e6221..1f38515d87f 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit f86f25e62217264495d05f116ccb09d575fe9841
+Subproject commit 1f38515d87fb78443f2ead17b4e95411f43dc1b2
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 5a82baad9f9..42da56aa737 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 5a82baad9f986722104280e8354a4427d8e9eab1
+Subproject commit 42da56aa73726710107031787af5eea186797984
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index a9321a788f6..908a00ad9be 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -635,6 +635,7 @@ geometry_node_categories = [
]),
GeometryNodeCategory("GEO_TEXTURE", "Texture", items=[
NodeItem("ShaderNodeTexNoise"),
+ NodeItem("ShaderNodeTexImage"),
]),
GeometryNodeCategory("GEO_VECTOR", "Vector", items=[
NodeItem("ShaderNodeVectorCurve"),
diff --git a/source/blender/blenlib/BLI_float2.hh b/source/blender/blenlib/BLI_float2.hh
index cf6e00ba938..bdac28d7937 100644
--- a/source/blender/blenlib/BLI_float2.hh
+++ b/source/blender/blenlib/BLI_float2.hh
@@ -84,6 +84,13 @@ struct float2 {
return *this;
}
+ float2 &operator*=(const float2 &other)
+ {
+ x *= other.x;
+ y *= other.y;
+ return *this;
+ }
+
float2 &operator*=(float factor)
{
x *= factor;
@@ -91,6 +98,13 @@ struct float2 {
return *this;
}
+ float2 &operator-=(float factor)
+ {
+ x -= factor;
+ y -= factor;
+ return *this;
+ }
+
float2 &operator/=(float divisor)
{
x /= divisor;
@@ -110,16 +124,42 @@ struct float2 {
return {a.x + b.x, a.y + b.y};
}
+ friend float2 operator+(const float2 &a, const float &b)
+ {
+ return {a.x + b, a.y + b};
+ }
+
friend float2 operator-(const float2 &a, const float2 &b)
{
return {a.x - b.x, a.y - b.y};
}
+ friend float2 operator-(const float2 &a, const float &b)
+ {
+ return {a.x - b, a.y - b};
+ }
+
+ friend float2 operator-(const float2 &a)
+ {
+ return {-a.x, -a.y};
+ }
+
+ friend float2 operator*(const float2 &a, const float2 &b)
+ {
+ return {a.x * b.x, a.y * b.y};
+ }
+
friend float2 operator*(const float2 &a, float b)
{
return {a.x * b, a.y * b};
}
+ friend float2 operator/(const float2 &a, const float2 &b)
+ {
+ BLI_assert(b.x != 0.0f && b.y != 0.0f);
+ return {a.x / b.x, a.y / b.y};
+ }
+
friend float2 operator/(const float2 &a, float b)
{
BLI_assert(b != 0.0f);
@@ -152,6 +192,11 @@ struct float2 {
return float2(fabsf(a.x), fabsf(a.y));
}
+ static float2 floor(const float2 &a)
+ {
+ return float2(floorf(a.x), floorf(a.y));
+ }
+
static float distance(const float2 &a, const float2 &b)
{
return (a - b).length();
@@ -163,6 +208,14 @@ struct float2 {
return float2::dot(diff, diff);
}
+ static float2 safe_divide(const float2 &a, const float2 &b)
+ {
+ float2 result;
+ result.x = (b.x == 0.0f) ? 0.0f : a.x / b.x;
+ result.y = (b.y == 0.0f) ? 0.0f : a.y / b.y;
+ return result;
+ }
+
struct isect_result {
enum {
LINE_LINE_COLINEAR = -1,
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh
index 04aae375889..efde8a43f4e 100644
--- a/source/blender/blenlib/BLI_float3.hh
+++ b/source/blender/blenlib/BLI_float3.hh
@@ -62,6 +62,11 @@ struct float3 {
return {a.x + b.x, a.y + b.y, a.z + b.z};
}
+ friend float3 operator+(const float3 &a, const float &b)
+ {
+ return {a.x + b, a.y + b, a.z + b};
+ }
+
float3 &operator+=(const float3 &b)
{
this->x += b.x;
@@ -75,6 +80,11 @@ struct float3 {
return {a.x - b.x, a.y - b.y, a.z - b.z};
}
+ friend float3 operator-(const float3 &a, const float &b)
+ {
+ return {a.x - b, a.y - b, a.z - b};
+ }
+
friend float3 operator-(const float3 &a)
{
return {-a.x, -a.y, -a.z};
diff --git a/source/blender/blenlib/BLI_float4.hh b/source/blender/blenlib/BLI_float4.hh
index b1feee3121b..c49fc86ca63 100644
--- a/source/blender/blenlib/BLI_float4.hh
+++ b/source/blender/blenlib/BLI_float4.hh
@@ -63,6 +63,11 @@ struct float4 {
return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w};
}
+ friend float4 operator-(const float4 &a, const float &b)
+ {
+ return {a.x - b, a.y - b, a.z - b, a.w - b};
+ }
+
float4 &operator*=(float factor)
{
x *= factor;
@@ -72,6 +77,11 @@ struct float4 {
return *this;
}
+ friend float4 operator*(const float4 &a, const float4 &b)
+ {
+ return {a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w};
+ }
+
friend float4 operator*(const float4 &a, float b)
{
return {a.x * b, a.y * b, a.z * b, a.w * b};
@@ -81,6 +91,14 @@ struct float4 {
{
return b * a;
}
+
+ static float4 clamp(const float4 &a, const float mn, const float mx)
+ {
+ return float4(std::min(std::max(a.x, mn), mx),
+ std::min(std::max(a.y, mn), mx),
+ std::min(std::max(a.z, mn), mx),
+ std::min(std::max(a.w, mn), mx));
+ }
};
} // namespace blender
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index c5213dc304b..c69096759ab 100644
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@ -331,6 +331,7 @@ static void get_socket_value(const SocketRef &socket, void *r_value)
if (bsocket.type == SOCK_VECTOR) {
if (ELEM(bnode.type,
GEO_NODE_SET_POSITION,
+ SH_NODE_TEX_IMAGE,
SH_NODE_TEX_NOISE,
GEO_NODE_MESH_TO_POINTS,
GEO_NODE_PROXIMITY)) {
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 88ae7bcfaf8..0a5804cfc96 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -326,7 +326,7 @@ set(SRC
shader/nodes/node_shader_tex_coord.c
shader/nodes/node_shader_tex_environment.c
shader/nodes/node_shader_tex_gradient.cc
- shader/nodes/node_shader_tex_image.c
+ shader/nodes/node_shader_tex_image.cc
shader/nodes/node_shader_tex_magic.c
shader/nodes/node_shader_tex_musgrave.cc
shader/nodes/node_shader_tex_noise.cc
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
deleted file mode 100644
index 09d06c35a5f..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
- * All rights reserved.
- */
-
-#include "../node_shader_util.h"
-
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_tex_image_in[] = {
- {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_tex_image_out[] = {
- {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- {SOCK_FLOAT,
- N_("Alpha"),
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- 1.0f,
- PROP_NONE,
- SOCK_NO_INTERNAL_LINK},
- {-1, ""},
-};
-
-static void node_shader_init_tex_image(bNodeTree *UNUSED(ntree), bNode *node)
-{
- NodeTexImage *tex = MEM_callocN(sizeof(NodeTexImage), "NodeTexImage");
- BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT);
- BKE_texture_colormapping_default(&tex->base.color_mapping);
- BKE_imageuser_default(&tex->iuser);
-
- node->storage = tex;
-}
-
-static int node_shader_gpu_tex_image(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- Image *ima = (Image *)node->id;
- NodeTexImage *tex = node->storage;
-
- /* We get the image user from the original node, since GPU image keeps
- * a pointer to it and the dependency refreshes the original. */
- bNode *node_original = node->original ? node->original : node;
- NodeTexImage *tex_original = node_original->storage;
- ImageUser *iuser = &tex_original->iuser;
-
- if (!ima) {
- return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
- }
-
- GPUNodeLink **texco = &in[0].link;
- if (!*texco) {
- *texco = GPU_attribute(mat, CD_MTFACE, "");
- node_shader_gpu_bump_tex_coord(mat, node, texco);
- }
-
- node_shader_gpu_tex_mapping(mat, node, in, out);
-
- eGPUSamplerState sampler_state = 0;
-
- switch (tex->extension) {
- case SHD_IMAGE_EXTENSION_REPEAT:
- sampler_state |= GPU_SAMPLER_REPEAT;
- break;
- case SHD_IMAGE_EXTENSION_CLIP:
- sampler_state |= GPU_SAMPLER_CLAMP_BORDER;
- break;
- default:
- break;
- }
-
- if (t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list