97 const char *gpu_node_name = use_cubic ?
"node_tex_tile_cubic" :
"node_tex_tile_linear";
99 GPU_image_tiled(mat, ima, iuser, sampler_state, &gpu_image, &gpu_image_tile_mapping);
104 const char *gpu_node_name = use_cubic ?
"node_tex_image_cubic" :
"node_tex_image_linear";
113 gpu_node_name = use_cubic ?
"tex_box_sample_cubic" :
"tex_box_sample_linear";
117 GPU_link(mat,
"world_normals_get", &vnor);
118 GPU_link(mat,
"normal_transform_world_to_object", vnor, &wnor);
119 GPU_link(mat, gpu_node_name,
in[0].link, wnor, gpu_image, &col1, &col2, &col3);
128 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
129 GPU_link(mat,
"point_map_to_sphere", *texco, texco);
138 GPU_link(mat,
"point_texco_remap_square", *texco, texco);
139 GPU_link(mat,
"point_map_to_tube", *texco, texco);
146 if (
out[0].hasoutput) {
159 if (
out[1].hasoutput) {
160 GPU_link(mat,
"color_alpha_unpremultiply",
out[0].link, &
out[0].link);
167 if (
out[1].hasoutput) {
171 GPU_link(mat,
"color_alpha_premultiply",
out[0].link, &
out[0].link);
184 std::string image_node_name = node_name(
"Color");
186 NodeItem res = graph_.get_node(image_node_name);
188 res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
194 std::string image_path = image->id.name;
195 if (graph_.export_params.image_fn) {
198 image_path = graph_.export_params.image_fn(bmain, scene, image, &tex_image->
iuser);
201 NodeItem
vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
207 std::string filtertype;
210 filtertype =
"linear";
213 filtertype =
"closest";
217 filtertype =
"cubic";
222 std::string addressmode;
225 addressmode =
"periodic";
228 addressmode =
"clamp";
231 addressmode =
"constant";
234 addressmode =
"mirror";
240 NodeItem::Type node_type = NodeItem::Type::Color4;
241 const char *node_colorspace =
nullptr;
243 const char *image_colorspace = image->colorspace_settings.name;
245 node_type = NodeItem::Type::Vector4;
248 node_colorspace =
"lin_rec709";
251 node_colorspace =
"srgb_texture";
254 res = create_node(
"image",
257 {
"filtertype", val(filtertype)},
258 {
"uaddressmode", val(addressmode)},
259 {
"vaddressmode", val(addressmode)}});
260 res.set_input(
"file", image_path, NodeItem::Type::Filename);
261 res.node->setName(image_node_name);
262 if (node_colorspace) {
263 res.node->setAttribute(
"colorspace", node_colorspace);
268 if (
STREQ(socket_out_->identifier,
"Alpha")) {
285 ntype.
ui_name =
"Image Texture";
289 ntype.
declare = file_ns::sh_node_tex_image_declare;
290 ntype.
initfunc = file_ns::node_shader_init_tex_image;
293 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_image;
void BKE_imageuser_default(ImageUser *iuser)
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_IMAGE
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
@ NODE_DEFAULT_INPUT_POSITION_FIELD
@ 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)
void * MEM_callocN(size_t len, const char *str)
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))
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
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)
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_image()
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
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
ColorMapping color_mapping
bNodeRuntimeHandle * runtime
NodeMaterialXFunction materialx_fn
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeGPUExecFunction gpu_fn
const char * enum_name_legacy
NodeDeclareFunction declare
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)