Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
| Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | #endif | ||||
| if (in[2].link) { | if (in[2].link) { | ||||
| sss_scale = in[2].link; | sss_scale = in[2].link; | ||||
| } | } | ||||
| else { | else { | ||||
| GPU_link(mat, "set_rgb_one", &sss_scale); | GPU_link(mat, "set_rgb_one", &sss_scale); | ||||
| } | } | ||||
| /* Due to the manual effort done per config, we only optimize the most common permutations. */ | uint flag = GPU_MATFLAG_GLOSSY; | ||||
| char *node_name; | if (use_diffuse) { | ||||
| uint flag = 0; | flag |= GPU_MATFLAG_DIFFUSE; | ||||
| if (!use_subsurf && use_diffuse && !use_refract && !use_clear) { | |||||
| static char name[] = "node_bsdf_principled_dielectric"; | |||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY; | |||||
| } | |||||
| else if (!use_subsurf && !use_diffuse && !use_refract && !use_clear) { | |||||
| static char name[] = "node_bsdf_principled_metallic"; | |||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_GLOSSY; | |||||
| } | |||||
| else if (!use_subsurf && !use_diffuse && !use_refract && use_clear) { | |||||
| static char name[] = "node_bsdf_principled_clearcoat"; | |||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_GLOSSY; | |||||
| } | |||||
| else if (use_subsurf && use_diffuse && !use_refract && !use_clear) { | |||||
| static char name[] = "node_bsdf_principled_subsurface"; | |||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY; | |||||
| } | |||||
| else if (!use_subsurf && !use_diffuse && use_refract && !use_clear && !socket_not_zero(4)) { | |||||
| static char name[] = "node_bsdf_principled_glass"; | |||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT; | |||||
| } | } | ||||
| else { | if (use_refract) { | ||||
| static char name[] = "node_bsdf_principled"; | flag |= GPU_MATFLAG_REFRACT; | ||||
| node_name = name; | |||||
| flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT; | |||||
| } | } | ||||
| if (use_subsurf) { | if (use_subsurf) { | ||||
| flag |= GPU_MATFLAG_SSS; | flag |= GPU_MATFLAG_SSS; | ||||
| } | } | ||||
| float f_use_diffuse = use_diffuse ? 1.0f : 0.0f; | |||||
| float f_use_clearcoat = use_clear ? 1.0f : 0.0f; | |||||
| float f_use_refraction = use_refract ? 1.0f : 0.0f; | |||||
| float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; | float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f; | ||||
| GPU_material_flag_set(mat, flag); | GPU_material_flag_set(mat, flag); | ||||
| return GPU_stack_link(mat, | return GPU_stack_link(mat, | ||||
| node, | node, | ||||
| node_name, | "node_bsdf_principled", | ||||
| in, | in, | ||||
| out, | out, | ||||
| GPU_builtin(GPU_VIEW_POSITION), | GPU_constant(&f_use_diffuse), | ||||
| GPU_constant(&f_use_clearcoat), | |||||
| GPU_constant(&f_use_refraction), | |||||
| GPU_constant(&use_multi_scatter), | GPU_constant(&use_multi_scatter), | ||||
| GPU_constant(&node->ssr_id), | GPU_constant(&node->ssr_id), | ||||
| GPU_constant(&node->sss_id), | GPU_constant(&node->sss_id), | ||||
| sss_scale); | sss_scale); | ||||
| } | } | ||||
| static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| Show All 30 Lines | |||||