Shaders: rename Specular to Specular IOR Level in Principled BSDF
To clarify that this is no longer the primary control, but rather and adjustment on IOR. Ref #99447 Ref #112552
This commit is contained in:
@@ -692,10 +692,11 @@ static void version_principled_bsdf_emission(bNodeTree *ntree)
|
||||
}
|
||||
}
|
||||
|
||||
/* Rename Principled BSDF emission to emission color. */
|
||||
static void version_principled_bsdf_emission_color(bNodeTree *ntree)
|
||||
/* Rename various Principled BSDF sockets. */
|
||||
static void version_principled_bsdf_rename_sockets(bNodeTree *ntree)
|
||||
{
|
||||
version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Emission", "Emission Color");
|
||||
version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Specular", "Specular IOR Level");
|
||||
}
|
||||
|
||||
/* Replace old Principled Hair BSDF as a variant in the new Principled Hair BSDF. */
|
||||
@@ -1429,8 +1430,8 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
if (ntree->type == NTREE_SHADER) {
|
||||
/* Convert specular tint on the Principled BSDF. */
|
||||
version_principled_bsdf_specular_tint(ntree);
|
||||
/* Rename emission to emission color. */
|
||||
version_principled_bsdf_emission_color(ntree);
|
||||
/* Rename some sockets. */
|
||||
version_principled_bsdf_rename_sockets(ntree);
|
||||
}
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
|
||||
@@ -1138,7 +1138,7 @@ bNodeTree *EEVEE_shader_default_surface_nodetree(Material *ma)
|
||||
e_data.surface.roughness_socket = static_cast<bNodeSocketValueFloat *>(
|
||||
nodeFindSocket(bsdf, SOCK_IN, "Roughness")->default_value);
|
||||
e_data.surface.specular_socket = static_cast<bNodeSocketValueFloat *>(
|
||||
nodeFindSocket(bsdf, SOCK_IN, "Specular")->default_value);
|
||||
nodeFindSocket(bsdf, SOCK_IN, "Specular IOR Level")->default_value);
|
||||
e_data.surface.ntree = ntree;
|
||||
}
|
||||
/* Update */
|
||||
|
||||
@@ -41,7 +41,7 @@ DefaultSurfaceNodeTree::DefaultSurfaceNodeTree()
|
||||
roughness_socket_ =
|
||||
(bNodeSocketValueFloat *)nodeFindSocket(bsdf, SOCK_IN, "Roughness")->default_value;
|
||||
specular_socket_ =
|
||||
(bNodeSocketValueFloat *)nodeFindSocket(bsdf, SOCK_IN, "Specular")->default_value;
|
||||
(bNodeSocketValueFloat *)nodeFindSocket(bsdf, SOCK_IN, "Specular IOR Level")->default_value;
|
||||
ntree_ = ntree;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void node_bsdf_principled(vec4 base_color,
|
||||
float subsurface_scale,
|
||||
float subsurface_ior,
|
||||
float subsurface_anisotropy,
|
||||
float specular,
|
||||
float specular_ior_level,
|
||||
vec4 specular_tint,
|
||||
float anisotropic,
|
||||
float anisotropic_rotation,
|
||||
@@ -65,7 +65,7 @@ void node_bsdf_principled(vec4 base_color,
|
||||
ior = max(ior, 1e-5);
|
||||
transmission = clamp(transmission, 0.0, 1.0);
|
||||
subsurface = clamp(subsurface, 0.0, 1.0);
|
||||
specular = max(specular, 0.0);
|
||||
specular_ior_level = max(specular_ior_level, 0.0);
|
||||
specular_tint = max(specular_tint, vec4(0.0));
|
||||
/* Not used by EEVEE */
|
||||
/* anisotropic = clamp(anisotropic, 0.0, 1.0) */
|
||||
@@ -181,8 +181,8 @@ void node_bsdf_principled(vec4 base_color,
|
||||
if (true) {
|
||||
float eta = ior;
|
||||
float f0 = F0_from_ior(eta);
|
||||
if (specular != 0.5) {
|
||||
f0 *= 2.0 * specular;
|
||||
if (specular_ior_level != 0.5) {
|
||||
f0 *= 2.0 * specular_ior_level;
|
||||
eta = ior_from_F0(f0);
|
||||
if (ior < 1.0) {
|
||||
eta = 1.0 / eta;
|
||||
|
||||
@@ -388,13 +388,13 @@ void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
|
||||
has_specularity = false;
|
||||
}
|
||||
else {
|
||||
bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular");
|
||||
bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular IOR Level");
|
||||
set_color(node, col);
|
||||
/* TODO: Connect node */
|
||||
}
|
||||
}
|
||||
else if (cot.isTexture()) {
|
||||
add_texture_node(cot, -300, locy, "Specular");
|
||||
add_texture_node(cot, -300, locy, "Specular IOR Level");
|
||||
/* TODO: Connect node */
|
||||
}
|
||||
else {
|
||||
@@ -407,7 +407,7 @@ void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
|
||||
* TODO: This is a solution only for a corner case. We must find a better
|
||||
* way to handle specularity in general. Also note that currently we
|
||||
* do not export specularity values, see EffectExporter::operator() */
|
||||
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Specular");
|
||||
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Specular IOR Level");
|
||||
((bNodeSocketValueFloat *)socket->default_value)->value = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ void USDMaterialReader::set_principled_node_inputs(bNode *principled,
|
||||
}
|
||||
|
||||
if (pxr::UsdShadeInput specular_input = usd_shader.GetInput(usdtokens::specularColor)) {
|
||||
set_node_input(specular_input, principled, "Specular", ntree, column, &context);
|
||||
set_node_input(specular_input, principled, "Specular Tint", ntree, column, &context);
|
||||
}
|
||||
|
||||
if (pxr::UsdShadeInput metallic_input = usd_shader.GetInput(usdtokens::metallic)) {
|
||||
|
||||
@@ -296,7 +296,7 @@ static InputSpecMap &preview_surface_input_map()
|
||||
{"Color", {usdtokens::diffuse_color, pxr::SdfValueTypeNames->Float3, true}},
|
||||
{"Roughness", {usdtokens::roughness, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"Metallic", {usdtokens::metallic, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"Specular", {usdtokens::specular, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"Specular IOR Level", {usdtokens::specular, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"Alpha", {usdtokens::opacity, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"IOR", {usdtokens::ior, pxr::SdfValueTypeNames->Float, true}},
|
||||
/* Note that for the Normal input set_default_value is false. */
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace blender::io::obj {
|
||||
const char *tex_map_type_to_socket_id[] = {
|
||||
"Base Color",
|
||||
"Metallic",
|
||||
"Specular",
|
||||
"Specular IOR Level",
|
||||
"Roughness", /* Map specular exponent to roughness. */
|
||||
"Roughness",
|
||||
"Sheen",
|
||||
@@ -204,7 +204,7 @@ static void store_bsdf_properties(const bNode *bsdf_node,
|
||||
|
||||
float specular = material->spec;
|
||||
if (bsdf_node) {
|
||||
copy_property_from_node(SOCK_FLOAT, bsdf_node, "Specular", {&specular, 1});
|
||||
copy_property_from_node(SOCK_FLOAT, bsdf_node, "Specular IOR Level", {&specular, 1});
|
||||
}
|
||||
|
||||
float metallic = material->metallic;
|
||||
|
||||
@@ -307,7 +307,7 @@ static void set_bsdf_socket_values(bNode *bsdf, Material *mat, const MTLMaterial
|
||||
if (mtl_mat.tex_map_of_type(MTLTexMapType::Emission).is_valid()) {
|
||||
set_property_of_socket(SOCK_FLOAT, "Emission Strength", {1.0f}, bsdf);
|
||||
}
|
||||
set_property_of_socket(SOCK_FLOAT, "Specular", {specular}, bsdf);
|
||||
set_property_of_socket(SOCK_FLOAT, "Specular IOR Level", {specular}, bsdf);
|
||||
set_property_of_socket(SOCK_FLOAT, "Roughness", {roughness}, bsdf);
|
||||
mat->roughness = roughness;
|
||||
set_property_of_socket(SOCK_FLOAT, "Metallic", {metallic}, bsdf);
|
||||
|
||||
@@ -104,7 +104,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
.draw_buttons([](uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) {
|
||||
uiItemR(layout, ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
});
|
||||
spec.add_input<decl::Float>("Specular")
|
||||
spec.add_input<decl::Float>("Specular IOR Level")
|
||||
.default_value(0.5f)
|
||||
.min(0.0f)
|
||||
.max(1.0f)
|
||||
|
||||
Reference in New Issue
Block a user