Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c195
1 files changed, 0 insertions, 195 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
deleted file mode 100644
index 5fbf66d5a68..00000000000
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
- * All rights reserved.
- */
-
-#include "../node_shader_util.h"
-
-/* **************** OUTPUT ******************** */
-
-static bNodeSocketTemplate sh_node_bsdf_principled_in[] = {
- {SOCK_RGBA, N_("Base Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- {SOCK_FLOAT, N_("Subsurface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_VECTOR,
- N_("Subsurface Radius"),
- 1.0f,
- 0.2f,
- 0.1f,
- 0.0f,
- 0.0f,
- 100.0f,
- PROP_NONE,
- SOCK_COMPACT},
- {SOCK_RGBA, N_("Subsurface Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- {SOCK_FLOAT, N_("Subsurface IOR"), 1.4f, 0.0f, 0.0f, 0.0f, 1.01f, 3.8f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Subsurface Anisotropy"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Metallic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Specular"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Specular Tint"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Roughness"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Anisotropic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Anisotropic Rotation"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Sheen"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Sheen Tint"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Clearcoat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Clearcoat Roughness"), 0.03f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
- {SOCK_FLOAT, N_("Transmission"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_FLOAT, N_("Transmission Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_RGBA, N_("Emission"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- {SOCK_FLOAT, N_("Emission Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f},
- {SOCK_FLOAT, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- {SOCK_VECTOR, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- {SOCK_VECTOR,
- N_("Clearcoat Normal"),
- 0.0f,
- 0.0f,
- 0.0f,
- 1.0f,
- -1.0f,
- 1.0f,
- PROP_NONE,
- SOCK_HIDE_VALUE},
- {SOCK_VECTOR, N_("Tangent"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
- {SOCK_FLOAT, N_("Weight"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE, SOCK_UNAVAIL},
- {-1, ""},
-};
-
-static bNodeSocketTemplate sh_node_bsdf_principled_out[] = {
- {SOCK_SHADER, N_("BSDF")},
- {-1, ""},
-};
-
-static void node_shader_init_principled(bNodeTree *UNUSED(ntree), bNode *node)
-{
- node->custom1 = SHD_GLOSSY_GGX;
- node->custom2 = SHD_SUBSURFACE_RANDOM_WALK;
-}
-
-#define socket_not_zero(sock) (in[sock].link || (clamp_f(in[sock].vec[0], 0.0f, 1.0f) > 1e-5f))
-#define socket_not_one(sock) \
- (in[sock].link || (clamp_f(in[sock].vec[0], 0.0f, 1.0f) < 1.0f - 1e-5f))
-
-static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- /* Normals */
- if (!in[22].link) {
- GPU_link(mat, "world_normals_get", &in[22].link);
- }
-
- /* Clearcoat Normals */
- if (!in[23].link) {
- GPU_link(mat, "world_normals_get", &in[23].link);
- }
-
-#if 0 /* Not used at the moment. */
- /* Tangents */
- if (!in[24].link) {
- GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
- GPU_link(mat, "tangent_orco_z", orco, &in[24].link);
- GPU_link(mat, "node_tangent", in[24].link, &in[24].link);
- }
-#endif
-
- bool use_diffuse = socket_not_one(6) && socket_not_one(17);
- bool use_subsurf = socket_not_zero(1) && use_diffuse;
- bool use_refract = socket_not_one(6) && socket_not_zero(17);
- bool use_transparency = socket_not_one(21);
- // bool use_clear = socket_not_zero(14);
-
- uint flag = GPU_MATFLAG_GLOSSY;
- if (use_diffuse) {
- flag |= GPU_MATFLAG_DIFFUSE;
- }
- if (use_refract) {
- flag |= GPU_MATFLAG_REFRACT;
- }
- if (use_subsurf) {
- flag |= GPU_MATFLAG_SUBSURFACE;
- }
- if (use_transparency) {
- flag |= GPU_MATFLAG_TRANSPARENT;
- }
-
- float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
-
- GPU_material_flag_set(mat, flag);
-
- GPUNodeLink *diffuse_weight, *specular_weight, *glass_reflection_weight,
- *glass_transmission_weight, *clearcoat_weight;
-
- GPU_stack_link(mat,
- node,
- "node_bsdf_principled",
- in,
- out,
- GPU_constant(&use_multi_scatter),
- &diffuse_weight,
- &specular_weight,
- &glass_reflection_weight,
- &glass_transmission_weight,
- &clearcoat_weight);
-
- return GPU_stack_eval_link(mat,
- node,
- "node_bsdf_principled_eval",
- in,
- out,
- GPU_constant(&use_multi_scatter),
- diffuse_weight,
- specular_weight,
- glass_reflection_weight,
- glass_transmission_weight,
- clearcoat_weight);
-}
-
-static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node)
-{
- bNodeSocket *sock;
- int distribution = node->custom1;
-
- for (sock = node->inputs.first; sock; sock = sock->next) {
- if (STREQ(sock->name, "Transmission Roughness")) {
- if (distribution == SHD_GLOSSY_GGX) {
- sock->flag &= ~SOCK_UNAVAIL;
- }
- else {
- sock->flag |= SOCK_UNAVAIL;
- }
- }
- }
-}
-
-/* node type definition */
-void register_node_type_sh_bsdf_principled(void)
-{
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_BSDF_PRINCIPLED, "Principled BSDF", NODE_CLASS_SHADER, 0);
- node_type_socket_templates(&ntype, sh_node_bsdf_principled_in, sh_node_bsdf_principled_out);
- node_type_size_preset(&ntype, NODE_SIZE_LARGE);
- node_type_init(&ntype, node_shader_init_principled);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_gpu(&ntype, node_shader_gpu_bsdf_principled);
- node_type_update(&ntype, node_shader_update_principled);
-
- nodeRegisterType(&ntype);
-}