Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_image.c
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | ||||
| NodeTexImage *tex = node->storage; | NodeTexImage *tex = node->storage; | ||||
| GPUNodeLink *norm; | GPUNodeLink *norm; | ||||
| int isdata = tex->color_space == SHD_COLORSPACE_NONE; | int isdata = tex->color_space == SHD_COLORSPACE_NONE; | ||||
| float blend = tex->projection_blend; | float blend = tex->projection_blend; | ||||
| if (!ima) | if (!ima) | ||||
| return GPU_stack_link(mat, "node_tex_image_empty", in, out); | return GPU_stack_link(mat, node, "node_tex_image_empty", in, out); | ||||
| if (!in[0].link) | if (!in[0].link) | ||||
| in[0].link = GPU_attribute(CD_MTFACE, ""); | in[0].link = GPU_attribute(CD_MTFACE, ""); | ||||
| node_shader_gpu_tex_mapping(mat, node, in, out); | node_shader_gpu_tex_mapping(mat, node, in, out); | ||||
| switch (tex->projection) { | switch (tex->projection) { | ||||
| case SHD_PROJ_FLAT: | case SHD_PROJ_FLAT: | ||||
| GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | ||||
| break; | break; | ||||
| case SHD_PROJ_BOX: | case SHD_PROJ_BOX: | ||||
| GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL), | GPU_link(mat, "direction_transform_m4v3", GPU_builtin(GPU_VIEW_NORMAL), | ||||
| GPU_builtin(GPU_INVERSE_VIEW_MATRIX), | GPU_builtin(GPU_INVERSE_VIEW_MATRIX), | ||||
| &norm); | &norm); | ||||
| GPU_link(mat, "direction_transform_m4v3", norm, | GPU_link(mat, "direction_transform_m4v3", norm, | ||||
| GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), | GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), | ||||
| &norm); | &norm); | ||||
| GPU_link(mat, "node_tex_image_box", in[0].link, | GPU_link(mat, "node_tex_image_box", in[0].link, | ||||
| norm, | norm, | ||||
| GPU_image(ima, iuser, isdata), | GPU_image(ima, iuser, isdata), | ||||
| GPU_uniform(&blend), | GPU_uniform(&blend), | ||||
| &out[0].link, | &out[0].link, | ||||
| &out[1].link); | &out[1].link); | ||||
| break; | break; | ||||
| case SHD_PROJ_SPHERE: | case SHD_PROJ_SPHERE: | ||||
| GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); | GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); | ||||
| GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link); | GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link); | ||||
| GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | ||||
| break; | break; | ||||
| case SHD_PROJ_TUBE: | case SHD_PROJ_TUBE: | ||||
| GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); | GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link); | ||||
| GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link); | GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link); | ||||
| GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | GPU_stack_link(mat, node, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); | ||||
| break; | break; | ||||
| } | } | ||||
| ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); | ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); | ||||
| if ((tex->color_space == SHD_COLORSPACE_COLOR) && | if ((tex->color_space == SHD_COLORSPACE_COLOR) && | ||||
| ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && | ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && | ||||
| GPU_material_do_color_management(mat)) | GPU_material_do_color_management(mat)) | ||||
| { | { | ||||
| Show All 21 Lines | |||||