28 b.add_output<
decl::Color>(
"Color"_ustr).no_muted_links();
29 b.add_output<
decl::Float>(
"Alpha"_ustr).no_muted_links();
97 sampler_state.
filtering = GPU_SAMPLER_FILTERING_ANISOTROPIC_ENABLE |
106 const char *gpu_node_name = use_cubic ?
"node_tex_tile_cubic" :
"node_tex_tile_linear";
108 GPU_image_tiled(mat, ima, iuser, sampler_state, &gpu_image, &gpu_image_tile_mapping);
113 const char *gpu_node_name = use_cubic ?
"node_tex_image_cubic" :
"node_tex_image_linear";
122 gpu_node_name = use_cubic ?
"tex_box_sample_cubic" :
"tex_box_sample_linear";
128 "normal_transform_world_to_object",
142 GPU_link(mat,
"tex_box_blend", wnor, col1, col2, col3, blend, &
out[0].link, &
out[1].link);
150 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
151 GPU_link(mat,
"point_map_to_sphere", *texco, texco);
160 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
161 GPU_link(mat,
"point_map_to_tube", *texco, texco);
168 if (
out[0].hasoutput &&
out[0].link) {
181 if (
out[1].hasoutput) {
182 GPU_link(mat,
"color_alpha_unpremultiply",
out[0].link, &
out[0].link);
189 if (
out[1].hasoutput) {
193 GPU_link(mat,
"color_alpha_premultiply",
out[0].link, &
out[0].link);
206 std::string image_node_name = node_name(
"Color");
208 NodeItem res = graph_.get_node(image_node_name);
210 res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
216 std::string image_path =
image->id.name;
217 if (graph_.export_params.image_fn) {
220 image_path = graph_.export_params.image_fn(bmain, scene,
image, &tex_image->
iuser);
223 NodeItem vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
225 vector = texcoord_node();
229 std::string filtertype;
232 filtertype =
"linear";
235 filtertype =
"closest";
239 filtertype =
"cubic";
244 std::string addressmode;
247 addressmode =
"periodic";
250 addressmode =
"clamp";
253 addressmode =
"constant";
256 addressmode =
"mirror";
262 NodeItem::Type node_type = NodeItem::Type::Color4;
263 const char *node_colorspace =
nullptr;
265 const char *image_colorspace =
image->colorspace_settings.name;
267 node_type = NodeItem::Type::Vector4;
270 node_colorspace =
"lin_rec709";
273 node_colorspace =
"srgb_texture";
276 res = create_node(
"image",
279 {
"filtertype", val(filtertype)},
280 {
"uaddressmode", val(addressmode)},
281 {
"vaddressmode", val(addressmode)}});
282 res.set_input(
"file", image_path, NodeItem::Type::Filename);
283 res.node->setName(image_node_name);
284 if (node_colorspace) {
285 res.node->setAttribute(
"colorspace", node_colorspace);
290 if (
STREQ(socket_out_->identifier,
"Alpha")) {
307 ntype.
ui_name =
"Image Texture";
311 ntype.
declare = file_ns::sh_node_tex_image_declare;
312 ntype.
initfunc = file_ns::node_shader_init_tex_image;
315 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_image;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_IMAGE
#define BLI_assert_unreachable()
#define image(slot, qualifiers, format)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
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)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ IMA_ALPHA_CHANNEL_PACKED
void register_node_type_sh_tex_image()
@ SHD_IMAGE_EXTENSION_EXTEND
@ SHD_IMAGE_EXTENSION_CLIP
@ SHD_IMAGE_EXTENSION_MIRROR
@ SHD_IMAGE_EXTENSION_REPEAT
GPUNodeLink * GPU_image(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state)
@ GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_SAMPLER_FILTERING_LINEAR
@ GPU_SAMPLER_FILTERING_MIPMAP
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_uniform(const float *num)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
Main * DEG_get_bmain(const Depsgraph *graph)
void GPU_image_tiled(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state, GPUNodeLink **r_image_tiled_link, GPUNodeLink **r_image_tiled_mapping_link)
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void node_shader_gpu_bump_tex_coord(GPUMaterial *mat, bNode *, GPUNodeLink **link)
GPUNodeLink * GPU_shading_data()
Scene * DEG_get_input_scene(const Depsgraph *graph)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
GPUNodeLink * GPU_attribute(GPUMaterial *mat, eCustomDataType type, const char *name)
GPUNodeLink * GPU_kernel_globals()
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
bool IMB_colormanagement_space_name_is_data(const char *name)
void node_image_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
void BKE_imageuser_default(ImageUser *iuser)
bool IMB_colormanagement_space_name_is_scene_linear(const char *name)
bool IMB_colormanagement_space_name_is_srgb(const char *name)
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void disable_filtering_flag(GPUSamplerFiltering filtering_flags)
GPUSamplerExtendMode extend_yz
GPUSamplerFiltering filtering
GPUSamplerExtendMode extend_x
static constexpr GPUSamplerState default_sampler()
ColorMapping color_mapping
static constexpr int _240
NodeMaterialXFunction materialx_fn
std::string ui_description
void(*) labelfunc(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeGPUExecFunction gpu_fn
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare