Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2005 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 #include "node_shader_util.h" 00034 00035 /* **************** OUTPUT ******************** */ 00036 static bNodeSocketTemplate sh_node_output_in[]= { 00037 { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f}, 00038 { SOCK_FLOAT, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, 00039 { -1, 0, "" } 00040 }; 00041 00042 static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) 00043 { 00044 if(data) { 00045 ShadeInput *shi= ((ShaderCallData *)data)->shi; 00046 float col[4]; 00047 00048 /* stack order input sockets: col, alpha, normal */ 00049 nodestack_get_vec(col, SOCK_VECTOR, in[0]); 00050 nodestack_get_vec(col+3, SOCK_FLOAT, in[1]); 00051 00052 if(shi->do_preview) { 00053 nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage); 00054 node->lasty= shi->ys; 00055 } 00056 00057 if(node->flag & NODE_DO_OUTPUT) { 00058 ShadeResult *shr= ((ShaderCallData *)data)->shr; 00059 00060 copy_v4_v4(shr->combined, col); 00061 shr->alpha= col[3]; 00062 00063 // copy_v3_v3(shr->nor, in[3]->vec); 00064 } 00065 } 00066 } 00067 00068 static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) 00069 { 00070 GPUNodeLink *outlink; 00071 00072 /*if(in[1].hasinput) 00073 GPU_material_enable_alpha(mat);*/ 00074 00075 GPU_stack_link(mat, "output_node", in, out, &outlink); 00076 GPU_material_output_link(mat, outlink); 00077 00078 return 1; 00079 } 00080 00081 void register_node_type_sh_output(bNodeTreeType *ttype) 00082 { 00083 static bNodeType ntype; 00084 00085 node_type_base(ttype, &ntype, SH_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW); 00086 node_type_compatibility(&ntype, NODE_OLD_SHADING); 00087 node_type_socket_templates(&ntype, sh_node_output_in, NULL); 00088 node_type_size(&ntype, 80, 60, 200); 00089 node_type_exec(&ntype, node_shader_exec_output); 00090 node_type_gpu(&ntype, gpu_shader_output); 00091 00092 /* Do not allow muting output node. */ 00093 node_type_mute(&ntype, NULL, NULL); 00094 node_type_gpu_mute(&ntype, NULL); 00095 00096 nodeRegisterType(ttype, &ntype); 00097 }