Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_coord.c
- This file was moved from source/blender/nodes/shader/nodes/node_shader_tex_coord.cc.
| Show All 11 Lines | |||||
| * You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2005 Blender Foundation. | * The Original Code is Copyright (C) 2005 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| #include "node_shader_util.hh" | #include "../node_shader_util.h" | ||||
| #include "DNA_customdata_types.h" | #include "DNA_customdata_types.h" | ||||
| /* **************** OUTPUT ******************** */ | /* **************** OUTPUT ******************** */ | ||||
| namespace blender::nodes::node_shader_tex_coord_cc { | |||||
| static bNodeSocketTemplate sh_node_tex_coord_out[] = { | static bNodeSocketTemplate sh_node_tex_coord_out[] = { | ||||
| {SOCK_VECTOR, N_("Generated"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Generated"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("Object"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Object"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("Camera"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Camera"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("Window"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Window"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {SOCK_VECTOR, N_("Reflection"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | {SOCK_VECTOR, N_("Reflection"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static int node_shader_gpu_tex_coord(GPUMaterial *mat, | static int node_shader_gpu_tex_coord(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| Object *ob = (Object *)node->id; | Object *ob = (Object *)node->id; | ||||
| GPUNodeLink *inv_obmat = (ob != nullptr) ? GPU_uniform(&ob->imat[0][0]) : | GPUNodeLink *inv_obmat = (ob != NULL) ? GPU_uniform(&ob->imat[0][0]) : | ||||
| GPU_builtin(GPU_INVERSE_OBJECT_MATRIX); | GPU_builtin(GPU_INVERSE_OBJECT_MATRIX); | ||||
| /* Opti: don't request orco if not needed. */ | /* Opti: don't request orco if not needed. */ | ||||
| const float default_coords[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | GPUNodeLink *orco = (!out[0].hasoutput) ? GPU_constant((float[4]){0.0f, 0.0f, 0.0f, 0.0f}) : | ||||
| GPUNodeLink *orco = (!out[0].hasoutput) ? GPU_constant(default_coords) : | |||||
| GPU_attribute(mat, CD_ORCO, ""); | GPU_attribute(mat, CD_ORCO, ""); | ||||
| GPUNodeLink *mtface = GPU_attribute(mat, CD_MTFACE, ""); | GPUNodeLink *mtface = GPU_attribute(mat, CD_MTFACE, ""); | ||||
| GPUNodeLink *viewpos = GPU_builtin(GPU_VIEW_POSITION); | GPUNodeLink *viewpos = GPU_builtin(GPU_VIEW_POSITION); | ||||
| GPUNodeLink *worldnor = GPU_builtin(GPU_WORLD_NORMAL); | GPUNodeLink *worldnor = GPU_builtin(GPU_WORLD_NORMAL); | ||||
| GPUNodeLink *texcofacs = GPU_builtin(GPU_CAMERA_TEXCO_FACTORS); | GPUNodeLink *texcofacs = GPU_builtin(GPU_CAMERA_TEXCO_FACTORS); | ||||
| if (out[0].hasoutput) { | if (out[0].hasoutput) { | ||||
| GPU_link(mat, "generated_from_orco", orco, &orco); | GPU_link(mat, "generated_from_orco", orco, &orco); | ||||
| Show All 12 Lines | for (int i = 0; sh_node_tex_coord_out[i].type != -1; i++) { | ||||
| if (node->branch_tag != 0 && ELEM(i, 1, 6)) { | if (node->branch_tag != 0 && ELEM(i, 1, 6)) { | ||||
| GPU_link(mat, | GPU_link(mat, | ||||
| "vector_math_normalize", | "vector_math_normalize", | ||||
| out[i].link, | out[i].link, | ||||
| out[i].link, | out[i].link, | ||||
| out[i].link, | out[i].link, | ||||
| out[i].link, | out[i].link, | ||||
| &out[i].link, | &out[i].link, | ||||
| nullptr); | NULL); | ||||
| } | } | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_coord_cc | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tex_coord() | void register_node_type_sh_tex_coord(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_coord_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT, 0); | sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT, 0); | ||||
| node_type_socket_templates(&ntype, nullptr, file_ns::sh_node_tex_coord_out); | node_type_socket_templates(&ntype, NULL, sh_node_tex_coord_out); | ||||
| node_type_init(&ntype, nullptr); | node_type_init(&ntype, NULL); | ||||
| node_type_storage(&ntype, "", nullptr, nullptr); | node_type_storage(&ntype, "", NULL, NULL); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_coord); | node_type_gpu(&ntype, node_shader_gpu_tex_coord); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||