47 bNode *node_original = node->
runtime->original ? node->runtime->original :
node;
65 switch (
tex->extension) {
94 const char *gpu_node_name = use_cubic ?
"node_tex_tile_cubic" :
"node_tex_tile_linear";
96 GPU_image_tiled(mat, ima, iuser, sampler_state, &gpu_image, &gpu_image_tile_mapping);
98 GPU_stack_link(mat, node, gpu_node_name, in, out, gpu_image, gpu_image_tile_mapping);
101 const char *gpu_node_name = use_cubic ?
"node_tex_image_cubic" :
"node_tex_image_linear";
103 switch (
tex->projection) {
110 gpu_node_name = use_cubic ?
"tex_box_sample_cubic" :
"tex_box_sample_linear";
114 GPU_link(mat,
"world_normals_get", &vnor);
115 GPU_link(mat,
"normal_transform_world_to_object", vnor, &wnor);
116 GPU_link(mat, gpu_node_name, in[0].link, wnor, gpu_image, &col1, &col2, &col3);
117 GPU_link(mat,
"tex_box_blend", wnor, col1, col2, col3,
blend, &out[0].link, &out[1].link);
125 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
126 GPU_link(mat,
"point_map_to_sphere", *texco, texco);
135 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
136 GPU_link(mat,
"point_map_to_tube", *texco, texco);
143 if (out[0].hasoutput) {
148 GPU_link(mat,
"color_alpha_clear", out[0].link, &out[0].link);
156 if (out[1].hasoutput) {
157 GPU_link(mat,
"color_alpha_unpremultiply", out[0].link, &out[0].link);
160 GPU_link(mat,
"color_alpha_clear", out[0].link, &out[0].link);
164 if (out[1].hasoutput) {
165 GPU_link(mat,
"color_alpha_clear", out[0].link, &out[0].link);
168 GPU_link(mat,
"color_alpha_premultiply", out[0].link, &out[0].link);
181 std::string image_node_name = node_name(
false) +
"_Color";
183 NodeItem res = empty();
184 res.node = graph_->getNode(image_node_name);
186 res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
192 std::string image_path = image->id.name;
193 if (export_params_.image_fn) {
196 image_path = export_params_.image_fn(bmain, scene, image, &tex_image->
iuser);
199 NodeItem
vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
205 std::string filtertype;
208 filtertype =
"linear";
211 filtertype =
"closest";
215 filtertype =
"cubic";
220 std::string addressmode;
223 addressmode =
"periodic";
226 addressmode =
"clamp";
229 addressmode =
"constant";
232 addressmode =
"mirror";
238 NodeItem::Type node_type = NodeItem::Type::Color4;
239 const char *node_colorspace =
nullptr;
241 const char *image_colorspace = image->colorspace_settings.name;
243 node_type = NodeItem::Type::Vector4;
246 node_colorspace =
"lin_rec709";
249 node_colorspace =
"srgb_texture";
252 res = create_node(
"image",
255 {
"filtertype", val(filtertype)},
256 {
"uaddressmode", val(addressmode)},
257 {
"vaddressmode", val(addressmode)}});
258 res.set_input(
"file", image_path, NodeItem::Type::Filename);
259 res.node->setName(image_node_name);
260 if (node_colorspace) {
261 res.node->setAttribute(
"colorspace", node_colorspace);
266 if (
STREQ(socket_out_->name,
"Alpha")) {
283 ntype.
declare = file_ns::sh_node_tex_image_declare;
284 ntype.
initfunc = file_ns::node_shader_init_tex_image;
287 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_image;
void BKE_imageuser_default(ImageUser *iuser)
#define SH_NODE_TEX_IMAGE
#define NODE_CLASS_TEXTURE
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
#define BLI_assert_unreachable()
Main * DEG_get_bmain(const Depsgraph *graph)
Scene * DEG_get_input_scene(const Depsgraph *graph)
@ IMA_ALPHA_CHANNEL_PACKED
@ SHD_IMAGE_EXTENSION_MIRROR
@ SHD_IMAGE_EXTENSION_CLIP
@ SHD_IMAGE_EXTENSION_REPEAT
@ SHD_IMAGE_EXTENSION_EXTEND
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_image(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state)
void GPU_image_tiled(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state, GPUNodeLink **r_image_tiled_link, GPUNodeLink **r_image_tiled_mapping_link)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_uniform(const float *num)
@ GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_SAMPLER_FILTERING_MIPMAP
@ GPU_SAMPLER_FILTERING_ANISOTROPIC
@ GPU_SAMPLER_FILTERING_LINEAR
bool IMB_colormanagement_space_name_is_srgb(const char *name)
bool IMB_colormanagement_space_name_is_scene_linear(const char *name)
bool IMB_colormanagement_space_name_is_data(const char *name)
local_group_size(16, 16) .push_constant(Type b
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
void node_register_type(bNodeType *ntype)
static void node_shader_init_tex_image(bNodeTree *, bNode *node)
static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_tex_image_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_image()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
void node_shader_gpu_bump_tex_coord(GPUMaterial *mat, bNode *, GPUNodeLink **link)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_image_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
GPUSamplerExtendMode extend_yz
static constexpr GPUSamplerState default_sampler()
GPUSamplerFiltering filtering
void disable_filtering_flag(GPUSamplerFiltering filtering_flags)
GPUSamplerExtendMode extend_x
ColorManagedColorspaceSettings colorspace_settings
bNodeRuntimeHandle * runtime
NodeMaterialXFunction materialx_fn
void(* initfunc)(bNodeTree *ntree, bNode *node)
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeGPUExecFunction gpu_fn
NodeDeclareFunction declare