Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_tex_environment.c
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | ||||
| { | { | ||||
| Image *ima = (Image *)node->id; | Image *ima = (Image *)node->id; | ||||
| ImageUser *iuser = NULL; | ImageUser *iuser = NULL; | ||||
| NodeTexImage *tex = node->storage; | NodeTexImage *tex = node->storage; | ||||
| int isdata = tex->color_space == SHD_COLORSPACE_NONE; | int isdata = tex->color_space == SHD_COLORSPACE_NONE; | ||||
| if (!ima) | if (!ima) | ||||
| return GPU_stack_link(mat, "node_tex_environment_empty", in, out); | return GPU_stack_link(mat, node, "node_tex_environment_empty", in, out); | ||||
| if (!in[0].link) { | if (!in[0].link) { | ||||
| GPUMatType type = GPU_Material_get_type(mat); | GPUMatType type = GPU_Material_get_type(mat); | ||||
| if (type == GPU_MATERIAL_TYPE_MESH) | if (type == GPU_MATERIAL_TYPE_MESH) | ||||
| in[0].link = GPU_builtin(GPU_VIEW_POSITION); | in[0].link = GPU_builtin(GPU_VIEW_POSITION); | ||||
| else | else | ||||
| GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link); | GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link); | ||||
| } | } | ||||
| node_shader_gpu_tex_mapping(mat, node, in, out); | node_shader_gpu_tex_mapping(mat, node, in, out); | ||||
| if (tex->projection == SHD_PROJ_EQUIRECTANGULAR) | if (tex->projection == SHD_PROJ_EQUIRECTANGULAR) | ||||
| GPU_stack_link(mat, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata)); | GPU_stack_link(mat, node, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata)); | ||||
| else | else | ||||
| GPU_stack_link(mat, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata)); | GPU_stack_link(mat, node, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata)); | ||||
| ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); | ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); | ||||
| if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && | if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && | ||||
| GPU_material_do_color_management(mat)) | GPU_material_do_color_management(mat)) | ||||
| { | { | ||||
| GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); | GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); | ||||
| } | } | ||||
| BKE_image_release_ibuf(ima, ibuf, NULL); | BKE_image_release_ibuf(ima, ibuf, NULL); | ||||
| Show All 18 Lines | |||||