Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-11 18:01:17 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-06-11 18:06:28 +0300
commit84692844a3d6493ce0649c5021ec92e684b59a86 (patch)
treeb6dca64f71b53d55e9e55483bf9e76e2a116d7f4 /source/blender/nodes
parent27b673402228aeede8369d99bf64f3da21541058 (diff)
Fix merge error in 908b696, removed files were accidentally added back.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geom.c163
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_material.c374
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c97
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_texture.c166
4 files changed, 0 insertions, 800 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c
deleted file mode 100644
index 0a51ee8dc68..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_geom.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_geom.c
- * \ingroup shdnodes
- */
-
-
-#include "node_shader_util.h"
-
-#include "DNA_customdata_types.h"
-
-/* **************** GEOMETRY ******************** */
-
-/* output socket type definition */
-static bNodeSocketTemplate sh_node_geom_out[] = {
- { SOCK_VECTOR, 0, N_("Global")},
- { SOCK_VECTOR, 0, N_("Local")},
- { SOCK_VECTOR, 0, N_("View")},
- { SOCK_VECTOR, 0, N_("Orco")},
- { SOCK_VECTOR, 0, N_("UV")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { SOCK_RGBA, 0, N_("Vertex Color")},
- { SOCK_FLOAT, 0, N_("Vertex Alpha")},
- { SOCK_FLOAT, 0, N_("Front/Back")},
- { -1, 0, "" }
-};
-
-/* node execute callback */
-static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **UNUSED(in), bNodeStack **out)
-{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- NodeGeometry *ngeo = (NodeGeometry *)node->storage;
- ShadeInputUV *suv = &shi->uv[shi->actuv];
- static float defaultvcol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- int i;
-
- if (ngeo->uvname[0]) {
- /* find uv map by name */
- for (i = 0; i < shi->totuv; i++) {
- if (STREQ(shi->uv[i].name, ngeo->uvname)) {
- suv = &shi->uv[i];
- break;
- }
- }
- }
-
- /* out: global, local, view, orco, uv, normal, vertex color */
- copy_v3_v3(out[GEOM_OUT_GLOB]->vec, shi->gl);
- copy_v3_v3(out[GEOM_OUT_LOCAL]->vec, shi->co);
- copy_v3_v3(out[GEOM_OUT_VIEW]->vec, shi->view);
- copy_v3_v3(out[GEOM_OUT_ORCO]->vec, shi->lo);
- copy_v3_v3(out[GEOM_OUT_UV]->vec, suv->uv);
- copy_v3_v3(out[GEOM_OUT_NORMAL]->vec, shi->vno);
-
- if (shi->use_world_space_shading) {
- negate_v3(out[GEOM_OUT_NORMAL]->vec);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[GEOM_OUT_NORMAL]->vec);
- }
- if (shi->totcol) {
- /* find vertex color layer by name */
- ShadeInputCol *scol = &shi->col[0];
-
- if (ngeo->colname[0]) {
- for (i = 0; i < shi->totcol; i++) {
- if (STREQ(shi->col[i].name, ngeo->colname)) {
- scol = &shi->col[i];
- break;
- }
- }
- }
-
- srgb_to_linearrgb_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col);
- out[GEOM_OUT_VCOL]->vec[3] = scol->col[3];
- out[GEOM_OUT_VCOL_ALPHA]->vec[0] = scol->col[3];
- }
- else {
- memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
- out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f;
- }
-
- if (shi->osatex) {
- out[GEOM_OUT_GLOB]->data = shi->dxgl;
- out[GEOM_OUT_GLOB]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_LOCAL]->data = shi->dxco;
- out[GEOM_OUT_LOCAL]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_VIEW]->data = &shi->dxview;
- out[GEOM_OUT_VIEW]->datatype = NS_OSA_VALUES;
- out[GEOM_OUT_ORCO]->data = shi->dxlo;
- out[GEOM_OUT_ORCO]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_UV]->data = suv->dxuv;
- out[GEOM_OUT_UV]->datatype = NS_OSA_VECTORS;
- out[GEOM_OUT_NORMAL]->data = shi->dxno;
- out[GEOM_OUT_NORMAL]->datatype = NS_OSA_VECTORS;
- }
-
- /* front/back, normal flipping was stored */
- out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor) ? 0.0f : 1.0f;
- }
-}
-
-static void node_shader_init_geometry(bNodeTree *UNUSED(ntree), bNode *node)
-{
- node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
-}
-
-static int gpu_shader_geom(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- NodeGeometry *ngeo = (NodeGeometry *)node->storage;
- GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
- GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, ngeo->uvname);
- GPUNodeLink *mcol = GPU_attribute(CD_MCOL, ngeo->colname);
-
- bool ret = GPU_stack_link(mat, "geom", in, out,
- GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
- GPU_builtin(GPU_INVERSE_VIEW_MATRIX), orco, mtface, mcol);
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", out[5].link, &out[5].link);
- ret &= GPU_link(mat, "direction_transform_m4v3", out[5].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[5].link);
- }
- return ret;
-}
-
-/* node type definition */
-void register_node_type_sh_geom(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_GEOMETRY, "Geometry", NODE_CLASS_INPUT, 0);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, NULL, sh_node_geom_out);
- node_type_init(&ntype, node_shader_init_geometry);
- node_type_storage(&ntype, "NodeGeometry", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_geom);
- node_type_gpu(&ntype, gpu_shader_geom);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c
deleted file mode 100644
index 8a73ddc1194..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_material.c
- * \ingroup shdnodes
- */
-
-#include "node_shader_util.h"
-
-/* **************** MATERIAL ******************** */
-
-static bNodeSocketTemplate sh_node_material_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("DiffuseIntensity"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION},
- { -1, 0, "" }
-};
-
-static bNodeSocketTemplate sh_node_material_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { SOCK_FLOAT, 0, N_("Alpha")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { -1, 0, "" }
-};
-
-/* **************** EXTENDED MATERIAL ******************** */
-
-static bNodeSocketTemplate sh_node_material_ext_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("DiffuseIntensity"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION},
- { SOCK_RGBA, 1, N_("Mirror"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Ambient"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Emit"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
- { SOCK_FLOAT, 1, N_("SpecTra"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Reflectivity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Alpha"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
- { SOCK_FLOAT, 1, N_("Translucency"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
- { -1, 0, "" }
-};
-
-static bNodeSocketTemplate sh_node_material_ext_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { SOCK_FLOAT, 0, N_("Alpha")},
- { SOCK_VECTOR, 0, N_("Normal")},
- { SOCK_RGBA, 0, N_("Diffuse")},
- { SOCK_RGBA, 0, N_("Spec")},
- { SOCK_RGBA, 0, N_("AO")},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- if (data && node->id) {
- ShadeResult shrnode;
- ShadeInput *shi;
- ShaderCallData *shcd = data;
- float col[4];
- bNodeSocket *sock;
- char hasinput[NUM_MAT_IN] = {'\0'};
- int i, mode;
-
- /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
- * the constant input stack values (e.g. in case material node is inside a group).
- * we just want to know if a node input uses external data or the material setting.
- * this is an ugly hack, but so is this node as a whole.
- */
- for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i)
- hasinput[i] = (sock->link != NULL);
-
- shi = shcd->shi;
- shi->mat = (Material *)node->id;
-
- /* copy all relevant material vars, note, keep this synced with render_types.h */
- memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float));
- shi->har = shi->mat->har;
-
- /* write values */
- if (hasinput[MAT_IN_COLOR])
- nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]);
-
- if (hasinput[MAT_IN_SPEC])
- nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]);
-
- if (hasinput[MAT_IN_REFL])
- nodestack_get_vec(&shi->refl, SOCK_FLOAT, in[MAT_IN_REFL]);
-
- /* retrieve normal */
- if (hasinput[MAT_IN_NORMAL]) {
- nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]);
- if (shi->use_world_space_shading) {
- negate_v3(shi->vn);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), shi->vn);
- }
- normalize_v3(shi->vn);
- }
- else
- copy_v3_v3(shi->vn, shi->vno);
-
- /* custom option to flip normal */
- if (node->custom1 & SH_NODE_MAT_NEG) {
- negate_v3(shi->vn);
- }
-
- if (node->type == SH_NODE_MATERIAL_EXT) {
- if (hasinput[MAT_IN_MIR])
- nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]);
- if (hasinput[MAT_IN_AMB])
- nodestack_get_vec(&shi->amb, SOCK_FLOAT, in[MAT_IN_AMB]);
- if (hasinput[MAT_IN_EMIT])
- nodestack_get_vec(&shi->emit, SOCK_FLOAT, in[MAT_IN_EMIT]);
- if (hasinput[MAT_IN_SPECTRA])
- nodestack_get_vec(&shi->spectra, SOCK_FLOAT, in[MAT_IN_SPECTRA]);
- if (hasinput[MAT_IN_RAY_MIRROR])
- nodestack_get_vec(&shi->ray_mirror, SOCK_FLOAT, in[MAT_IN_RAY_MIRROR]);
- if (hasinput[MAT_IN_ALPHA])
- nodestack_get_vec(&shi->alpha, SOCK_FLOAT, in[MAT_IN_ALPHA]);
- if (hasinput[MAT_IN_TRANSLUCENCY])
- nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]);
- }
-
- /* make alpha output give results even if transparency is only enabled on
- * the material linked in this not and not on the parent material */
- mode = shi->mode;
- if (shi->mat->mode & MA_TRANSP)
- shi->mode |= MA_TRANSP;
-
- shi->nodes = 1; /* temp hack to prevent trashadow recursion */
- node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
- shi->nodes = 0;
-
- shi->mode = mode;
-
- /* write to outputs */
- if (node->custom1 & SH_NODE_MAT_DIFF) {
- copy_v3_v3(col, shrnode.combined);
- if (!(node->custom1 & SH_NODE_MAT_SPEC)) {
- sub_v3_v3(col, shrnode.spec);
- }
- }
- else if (node->custom1 & SH_NODE_MAT_SPEC) {
- copy_v3_v3(col, shrnode.spec);
- }
- else
- col[0] = col[1] = col[2] = 0.0f;
-
- col[3] = shrnode.alpha;
-
- if (shi->do_preview)
- BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
-
- copy_v3_v3(out[MAT_OUT_COLOR]->vec, col);
- out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha;
-
- if (node->custom1 & SH_NODE_MAT_NEG) {
- shi->vn[0] = -shi->vn[0];
- shi->vn[1] = -shi->vn[1];
- shi->vn[2] = -shi->vn[2];
- }
-
- copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn);
-
- if (shi->use_world_space_shading) {
- negate_v3(out[MAT_OUT_NORMAL]->vec);
- mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[MAT_OUT_NORMAL]->vec);
- }
- /* Extended material options */
- if (node->type == SH_NODE_MATERIAL_EXT) {
- /* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside
- * a node tree :( */
- copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diffshad);
- copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec);
- copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao);
- }
-
- /* copy passes, now just active node */
- if (node->flag & NODE_ACTIVE_ID) {
- float combined[4], alpha;
-
- copy_v4_v4(combined, shcd->shr->combined);
- alpha = shcd->shr->alpha;
-
- *(shcd->shr) = shrnode;
-
- copy_v4_v4(shcd->shr->combined, combined);
- shcd->shr->alpha = alpha;
- }
- }
-}
-
-
-static void node_shader_init_material(bNodeTree *UNUSED(ntree), bNode *node)
-{
- node->custom1 = SH_NODE_MAT_DIFF | SH_NODE_MAT_SPEC;
-}
-
-/* XXX this is also done as a local static function in gpu_codegen.c,
- * but we need this to hack around the crappy material node.
- */
-static GPUNodeLink *gpu_get_input_link(GPUMaterial *mat, GPUNodeStack *in)
-{
- if (in->link) {
- return in->link;
- }
- else {
- GPUNodeLink *result = NULL;
-
- /* note GPU_uniform() is only intended to be used as a parameter to
- * GPU_link(), returning it directly results in leaks or double frees */
- if (in->type == GPU_FLOAT)
- GPU_link(mat, "set_value", GPU_uniform(in->vec), &result);
- else if (in->type == GPU_VEC3)
- GPU_link(mat, "set_rgb", GPU_uniform(in->vec), &result);
- else if (in->type == GPU_VEC4)
- GPU_link(mat, "set_rgba", GPU_uniform(in->vec), &result);
- else
- BLI_assert(0);
-
- return result;
- }
-}
-
-static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- if (node->id) {
- GPUShadeInput shi;
- GPUShadeResult shr;
- bNodeSocket *sock;
- char hasinput[NUM_MAT_IN] = {'\0'};
- int i;
-
- /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
- * the constant input stack values (e.g. in case material node is inside a group).
- * we just want to know if a node input uses external data or the material setting.
- */
- for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i)
- hasinput[i] = (sock->link != NULL);
-
- GPU_shadeinput_set(mat, (Material *)node->id, &shi);
-
- /* write values */
- if (hasinput[MAT_IN_COLOR])
- shi.rgb = gpu_get_input_link(mat, &in[MAT_IN_COLOR]);
-
- if (hasinput[MAT_IN_SPEC])
- shi.specrgb = gpu_get_input_link(mat, &in[MAT_IN_SPEC]);
-
- if (hasinput[MAT_IN_REFL])
- shi.refl = gpu_get_input_link(mat, &in[MAT_IN_REFL]);
-
- /* retrieve normal */
- if (hasinput[MAT_IN_NORMAL]) {
- GPUNodeLink *tmp;
- shi.vn = gpu_get_input_link(mat, &in[MAT_IN_NORMAL]);
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
- GPU_link(mat, "direction_transform_m4v3", shi.vn, GPU_builtin(GPU_VIEW_MATRIX), &shi.vn);
- }
- GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp);
- }
-
- /* custom option to flip normal */
- if (node->custom1 & SH_NODE_MAT_NEG)
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
-
- if (node->type == SH_NODE_MATERIAL_EXT) {
- if (hasinput[MAT_IN_MIR])
- shi.mir = gpu_get_input_link(mat, &in[MAT_IN_MIR]);
- if (hasinput[MAT_IN_AMB])
- shi.amb = gpu_get_input_link(mat, &in[MAT_IN_AMB]);
- if (hasinput[MAT_IN_EMIT])
- shi.emit = gpu_get_input_link(mat, &in[MAT_IN_EMIT]);
- if (hasinput[MAT_IN_SPECTRA])
- shi.spectra = gpu_get_input_link(mat, &in[MAT_IN_SPECTRA]);
- if (hasinput[MAT_IN_ALPHA])
- shi.alpha = gpu_get_input_link(mat, &in[MAT_IN_ALPHA]);
- }
-
- GPU_shaderesult_set(&shi, &shr); /* clears shr */
-
- /* write to outputs */
- if (node->custom1 & SH_NODE_MAT_DIFF) {
- out[MAT_OUT_COLOR].link = shr.combined;
-
- if (!(node->custom1 & SH_NODE_MAT_SPEC)) {
- GPUNodeLink *link;
- GPU_link(mat, "vec_math_sub", shr.combined, shr.spec, &out[MAT_OUT_COLOR].link, &link);
- }
- }
- else if (node->custom1 & SH_NODE_MAT_SPEC) {
- out[MAT_OUT_COLOR].link = shr.spec;
- }
- else
- GPU_link(mat, "set_rgb_zero", &out[MAT_OUT_COLOR].link);
-
- GPU_link(mat, "mtex_alpha_to_col", out[MAT_OUT_COLOR].link, shr.alpha, &out[MAT_OUT_COLOR].link);
-
- out[MAT_OUT_ALPHA].link = shr.alpha; //
-
- if (node->custom1 & SH_NODE_MAT_NEG)
- GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
- out[MAT_OUT_NORMAL].link = shi.vn;
- if (GPU_material_use_world_space_shading(mat)) {
- GPU_link(mat, "vec_math_negate", out[MAT_OUT_NORMAL].link, &out[MAT_OUT_NORMAL].link);
- GPU_link(mat, "direction_transform_m4v3", out[MAT_OUT_NORMAL].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[MAT_OUT_NORMAL].link);
- }
-
- if (node->type == SH_NODE_MATERIAL_EXT) {
- out[MAT_OUT_DIFFUSE].link = shr.diff;
- out[MAT_OUT_SPEC].link = shr.spec;
- GPU_link(mat, "set_rgb_one", &out[MAT_OUT_AO].link);
- }
-
- return 1;
- }
-
- return 0;
-}
-
-void register_node_type_sh_material(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_MATERIAL, "Material", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_material_in, sh_node_material_out);
- node_type_init(&ntype, node_shader_init_material);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_material);
- node_type_gpu(&ntype, gpu_shader_material);
-
- nodeRegisterType(&ntype);
-}
-
-
-void register_node_type_sh_material_ext(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_MATERIAL_EXT, "Extended Material", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_material_ext_in, sh_node_material_ext_out);
- node_type_init(&ntype, node_shader_init_material);
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_material);
- node_type_gpu(&ntype, gpu_shader_material);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
deleted file mode 100644
index 5b1a68b4bf9..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_output.c
- * \ingroup shdnodes
- */
-
-
-#include "node_shader_util.h"
-
-/* **************** OUTPUT ******************** */
-static bNodeSocketTemplate sh_node_output_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_output(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out))
-{
- if (data) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- float col[4];
-
- /* stack order input sockets: col, alpha, normal */
- nodestack_get_vec(col, SOCK_VECTOR, in[0]);
- nodestack_get_vec(col + 3, SOCK_FLOAT, in[1]);
-
- if (shi->do_preview) {
- BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
- node->lasty = shi->ys;
- }
-
- if (node->flag & NODE_DO_OUTPUT) {
- ShadeResult *shr = ((ShaderCallData *)data)->shr;
-
- copy_v4_v4(shr->combined, col);
- shr->alpha = col[3];
-
- // copy_v3_v3(shr->nor, in[3]->vec);
- }
- }
-}
-
-static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- GPUNodeLink *outlink;
-
-#if 0
- if (in[1].hasinput)
- GPU_material_enable_alpha(mat);
-#endif
-
- GPU_stack_link(mat, "output_node", in, out, &outlink);
- GPU_material_output_link(mat, outlink);
-
- return 1;
-}
-
-void register_node_type_sh_output(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_output_in, NULL);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_output);
- node_type_gpu(&ntype, gpu_shader_output);
-
- /* Do not allow muting output node. */
- node_type_internal_links(&ntype, NULL);
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c
deleted file mode 100644
index 737ec7d1c4b..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_texture.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/nodes/shader/nodes/node_shader_texture.c
- * \ingroup shdnodes
- */
-
-#include "DNA_texture_types.h"
-
-#include "node_shader_util.h"
-
-#include "GPU_material.h"
-
-/* **************** TEXTURE ******************** */
-static bNodeSocketTemplate sh_node_texture_in[] = {
- { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, /* no limit */
- { -1, 0, "" }
-};
-static bNodeSocketTemplate sh_node_texture_out[] = {
- { SOCK_FLOAT, 0, N_("Value"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { SOCK_RGBA, 0, N_("Color"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { SOCK_VECTOR, 0, N_("Normal"), 0, 0, 0, 0, 0, 0, PROP_NONE, SOCK_NO_INTERNAL_LINK},
- { -1, 0, "" }
-};
-
-static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
- if (data && node->id) {
- ShadeInput *shi = ((ShaderCallData *)data)->shi;
- TexResult texres;
- bNodeSocket *sock_vector = node->inputs.first;
- float vec[3], nor[3] = {0.0f, 0.0f, 0.0f};
- int retval;
- short which_output = node->custom1;
-
- short thread = shi->thread;
-
- /* out: value, color, normal */
-
- /* we should find out if a normal as output is needed, for now we do all */
- texres.nor = nor;
- texres.tr = texres.tg = texres.tb = 0.0f;
-
- /* don't use in[0]->hasinput, see material node for explanation */
- if (sock_vector->link) {
- nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
-
- if (in[0]->datatype == NS_OSA_VECTORS) {
- float *fp = in[0]->data;
- retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else if (in[0]->datatype == NS_OSA_VALUES) {
- const float *fp = in[0]->data;
- float dxt[3], dyt[3];
-
- dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
- dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f;
- retval = multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else
- retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL);
- }
- else {
- copy_v3_v3(vec, shi->lo);
- retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL);
- }
-
- /* stupid exception */
- if ( ((Tex *)node->id)->type == TEX_STUCCI) {
- texres.tin = 0.5f + 0.7f * texres.nor[0];
- CLAMP(texres.tin, 0.0f, 1.0f);
- }
-
- /* intensity and color need some handling */
- if (texres.talpha)
- out[0]->vec[0] = texres.ta;
- else
- out[0]->vec[0] = texres.tin;
-
- if ((retval & TEX_RGB) == 0) {
- copy_v3_fl(out[1]->vec, out[0]->vec[0]);
- out[1]->vec[3] = 1.0f;
- }
- else {
- copy_v3_v3(out[1]->vec, &texres.tr);
- out[1]->vec[3] = 1.0f;
- }
-
- copy_v3_v3(out[2]->vec, nor);
-
- if (shi->do_preview) {
- BKE_node_preview_set_pixel(execdata->preview, out[1]->vec, shi->xs, shi->ys, shi->do_manage);
- }
-
- }
-}
-
-static int gpu_shader_texture(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
-{
- Tex *tex = (Tex *)node->id;
-
- if (tex && tex->ima && (tex->type == TEX_IMAGE || tex->type == TEX_ENVMAP)) {
- if (tex->type == TEX_IMAGE) {
- GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, false);
- GPU_stack_link(mat, "texture_image", in, out, texlink);
- }
- else { /* TEX_ENVMAP */
- if (!in[0].link)
- in[0].link = GPU_uniform(in[0].vec);
- if (!GPU_material_use_world_space_shading(mat))
- GPU_link(mat, "direction_transform_m4v3", in[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &in[0].link);
- GPU_link(mat, "mtex_cube_map_refl_from_refldir",
- GPU_cube_map(tex->ima, &tex->iuser, false), in[0].link, &out[0].link, &out[1].link);
- GPU_link(mat, "color_to_normal", out[1].link, &out[2].link);
- }
-
- ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);
- if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
- GPU_material_do_color_management(mat))
- {
- GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link);
- }
- BKE_image_release_ibuf(tex->ima, ibuf, NULL);
-
- return true;
- }
-
- return false;
-}
-
-void register_node_type_sh_texture(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_compatibility(&ntype, NODE_OLD_SHADING);
- node_type_socket_templates(&ntype, sh_node_texture_in, sh_node_texture_out);
- node_type_exec(&ntype, NULL, NULL, node_shader_exec_texture);
- node_type_gpu(&ntype, gpu_shader_texture);
-
- nodeRegisterType(&ntype);
-}