Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_environment.c
- This file was moved from source/blender/nodes/shader/nodes/node_shader_tex_environment.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" | ||||
| /* **************** OUTPUT ******************** */ | /* **************** OUTPUT ******************** */ | ||||
| namespace blender::nodes::node_shader_tex_environment_cc { | |||||
| static bNodeSocketTemplate sh_node_tex_environment_in[] = { | static bNodeSocketTemplate sh_node_tex_environment_in[] = { | ||||
| {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static bNodeSocketTemplate sh_node_tex_environment_out[] = { | static bNodeSocketTemplate sh_node_tex_environment_out[] = { | ||||
| {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, | {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_NO_INTERNAL_LINK}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_init_tex_environment(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeTexEnvironment *tex = (NodeTexEnvironment *)MEM_callocN(sizeof(NodeTexEnvironment), | NodeTexEnvironment *tex = MEM_callocN(sizeof(NodeTexEnvironment), "NodeTexEnvironment"); | ||||
| "NodeTexEnvironment"); | |||||
| BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT); | ||||
| BKE_texture_colormapping_default(&tex->base.color_mapping); | BKE_texture_colormapping_default(&tex->base.color_mapping); | ||||
| tex->projection = SHD_PROJ_EQUIRECTANGULAR; | tex->projection = SHD_PROJ_EQUIRECTANGULAR; | ||||
| BKE_imageuser_default(&tex->iuser); | BKE_imageuser_default(&tex->iuser); | ||||
| node->storage = tex; | node->storage = tex; | ||||
| } | } | ||||
| static int node_shader_gpu_tex_environment(GPUMaterial *mat, | static int node_shader_gpu_tex_environment(GPUMaterial *mat, | ||||
| bNode *node, | bNode *node, | ||||
| bNodeExecData *UNUSED(execdata), | bNodeExecData *UNUSED(execdata), | ||||
| GPUNodeStack *in, | GPUNodeStack *in, | ||||
| GPUNodeStack *out) | GPUNodeStack *out) | ||||
| { | { | ||||
| Image *ima = (Image *)node->id; | Image *ima = (Image *)node->id; | ||||
| NodeTexEnvironment *tex = (NodeTexEnvironment *)node->storage; | NodeTexEnvironment *tex = node->storage; | ||||
| /* We get the image user from the original node, since GPU image keeps | /* We get the image user from the original node, since GPU image keeps | ||||
| * a pointer to it and the dependency refreshes the original. */ | * a pointer to it and the dependency refreshes the original. */ | ||||
| bNode *node_original = node->original ? node->original : node; | bNode *node_original = node->original ? node->original : node; | ||||
| NodeTexImage *tex_original = (NodeTexImage *)node_original->storage; | NodeTexImage *tex_original = node_original->storage; | ||||
| ImageUser *iuser = &tex_original->iuser; | ImageUser *iuser = &tex_original->iuser; | ||||
| eGPUSamplerState sampler = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER; | eGPUSamplerState sampler = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER; | ||||
| /* TODO(fclem): For now assume mipmap is always enabled. */ | /* TODO(fclem): For now assume mipmap is always enabled. */ | ||||
| if (true) { | if (true) { | ||||
| sampler |= GPU_SAMPLER_MIPMAP; | sampler |= GPU_SAMPLER_MIPMAP; | ||||
| } | } | ||||
| GPUNodeLink *outalpha; | GPUNodeLink *outalpha; | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | else { | ||||
| GPU_link(mat, "color_alpha_premultiply", out[0].link, &out[0].link); | GPU_link(mat, "color_alpha_premultiply", out[0].link, &out[0].link); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| } // namespace blender::nodes::node_shader_tex_environment_cc | |||||
| /* node type definition */ | /* node type definition */ | ||||
| void register_node_type_sh_tex_environment() | void register_node_type_sh_tex_environment(void) | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_shader_tex_environment_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE, 0); | sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE, 0); | ||||
| node_type_socket_templates( | node_type_socket_templates(&ntype, sh_node_tex_environment_in, sh_node_tex_environment_out); | ||||
| &ntype, file_ns::sh_node_tex_environment_in, file_ns::sh_node_tex_environment_out); | node_type_init(&ntype, node_shader_init_tex_environment); | ||||
| node_type_init(&ntype, file_ns::node_shader_init_tex_environment); | |||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_environment); | node_type_gpu(&ntype, node_shader_gpu_tex_environment); | ||||
| node_type_label(&ntype, node_image_label); | node_type_label(&ntype, node_image_label); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||