Shaders: rename Principled BSDF Emission to Emission Color
Ref #99447 Ref #112848
This commit is contained in:
parent
def9b76207
commit
ca5f1c0f00
|
@ -29,7 +29,7 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
|
|||
color CoatTint = color(1.0, 1.0, 1.0),
|
||||
float IOR = 1.45,
|
||||
float Transmission = 0.0,
|
||||
color Emission = 1.0,
|
||||
color EmissionColor = 1.0,
|
||||
float EmissionStrength = 0.0,
|
||||
float Alpha = 1.0,
|
||||
normal Normal = N,
|
||||
|
@ -100,8 +100,8 @@ shader node_principled_bsdf(string distribution = "multi_ggx",
|
|||
BSDF = mix(BSDF, MetallicBSDF, clamp(Metallic, 0.0, 1.0));
|
||||
}
|
||||
|
||||
if (EmissionStrength > 0.0 && Emission != color(0.0)) {
|
||||
BSDF += EmissionStrength * Emission * emission();
|
||||
if (EmissionStrength > 0.0 && EmissionColor != color(0.0)) {
|
||||
BSDF += EmissionStrength * EmissionColor * emission();
|
||||
}
|
||||
|
||||
if (Coat > 1e-5) {
|
||||
|
|
|
@ -138,7 +138,7 @@ static float3 output_estimate_emission(ShaderOutput *output, bool &is_constant)
|
|||
{
|
||||
const bool is_principled = (node->type == PrincipledBsdfNode::get_node_type());
|
||||
/* Emission and Background node. */
|
||||
ShaderInput *color_in = node->input(is_principled ? "Emission" : "Color");
|
||||
ShaderInput *color_in = node->input(is_principled ? "Emission Color" : "Color");
|
||||
ShaderInput *strength_in = node->input(is_principled ? "Emission Strength" : "Strength");
|
||||
|
||||
if (is_principled) {
|
||||
|
|
|
@ -2720,7 +2720,7 @@ NODE_DEFINE(PrincipledBsdfNode)
|
|||
SOCKET_IN_FLOAT(ior, "IOR", 0.0f);
|
||||
SOCKET_IN_FLOAT(transmission, "Transmission", 0.0f);
|
||||
SOCKET_IN_FLOAT(anisotropic_rotation, "Anisotropic Rotation", 0.0f);
|
||||
SOCKET_IN_COLOR(emission, "Emission", one_float3());
|
||||
SOCKET_IN_COLOR(emission_color, "Emission Color", one_float3());
|
||||
SOCKET_IN_FLOAT(emission_strength, "Emission Strength", 0.0f);
|
||||
SOCKET_IN_FLOAT(alpha, "Alpha", 1.0f);
|
||||
SOCKET_IN_NORMAL(normal, "Normal", zero_float3(), SocketType::LINK_NORMAL);
|
||||
|
@ -2743,7 +2743,7 @@ void PrincipledBsdfNode::simplify_settings(Scene * /* scene */)
|
|||
{
|
||||
if (!has_surface_emission()) {
|
||||
/* Emission will be zero, so optimize away any connected emission input. */
|
||||
ShaderInput *emission_in = input("Emission");
|
||||
ShaderInput *emission_in = input("Emission Color");
|
||||
ShaderInput *strength_in = input("Emission Strength");
|
||||
if (emission_in->link) {
|
||||
emission_in->disconnect();
|
||||
|
@ -2762,9 +2762,9 @@ bool PrincipledBsdfNode::has_surface_transparent()
|
|||
|
||||
bool PrincipledBsdfNode::has_surface_emission()
|
||||
{
|
||||
ShaderInput *emission_in = input("Emission");
|
||||
ShaderInput *emission_color_in = input("Emission Color");
|
||||
ShaderInput *emission_strength_in = input("Emission Strength");
|
||||
return (emission_in->link != NULL || reduce_max(emission) > CLOSURE_WEIGHT_CUTOFF) &&
|
||||
return (emission_color_in->link != NULL || reduce_max(emission_color) > CLOSURE_WEIGHT_CUTOFF) &&
|
||||
(emission_strength_in->link != NULL || emission_strength > CLOSURE_WEIGHT_CUTOFF);
|
||||
}
|
||||
|
||||
|
@ -2825,7 +2825,7 @@ void PrincipledBsdfNode::compile(SVMCompiler &compiler)
|
|||
int subsurface_anisotropy_offset = compiler.stack_assign(input("Subsurface Anisotropy"));
|
||||
int alpha_offset = compiler.stack_assign_if_linked(alpha_in);
|
||||
int emission_strength_offset = compiler.stack_assign_if_linked(emission_strength_in);
|
||||
int emission_offset = compiler.stack_assign(input("Emission"));
|
||||
int emission_color_offset = compiler.stack_assign(input("Emission Color"));
|
||||
|
||||
compiler.add_node(NODE_CLOSURE_BSDF,
|
||||
compiler.encode_uchar4(closure,
|
||||
|
@ -2866,7 +2866,7 @@ void PrincipledBsdfNode::compile(SVMCompiler &compiler)
|
|||
|
||||
compiler.add_node(
|
||||
compiler.encode_uchar4(
|
||||
alpha_offset, emission_strength_offset, emission_offset, SVM_STACK_INVALID),
|
||||
alpha_offset, emission_strength_offset, emission_color_offset, SVM_STACK_INVALID),
|
||||
__float_as_int(get_float(alpha_in->socket_type)),
|
||||
__float_as_int(get_float(emission_strength_in->socket_type)),
|
||||
SVM_STACK_INVALID);
|
||||
|
|
|
@ -546,7 +546,7 @@ class PrincipledBsdfNode : public BsdfBaseNode {
|
|||
NODE_SOCKET_API(float, surface_mix_weight)
|
||||
NODE_SOCKET_API(ClosureType, distribution)
|
||||
NODE_SOCKET_API(ClosureType, subsurface_method)
|
||||
NODE_SOCKET_API(float3, emission)
|
||||
NODE_SOCKET_API(float3, emission_color)
|
||||
NODE_SOCKET_API(float, emission_strength)
|
||||
NODE_SOCKET_API(float, alpha)
|
||||
|
||||
|
|
|
@ -468,14 +468,14 @@ class PrincipledBSDFWrapper(ShaderWrapper):
|
|||
def emission_color_get(self):
|
||||
if not self.use_nodes or self.node_principled_bsdf is None:
|
||||
return Color((0.0, 0.0, 0.0))
|
||||
return rgba_to_rgb(self.node_principled_bsdf.inputs["Emission"].default_value)
|
||||
return rgba_to_rgb(self.node_principled_bsdf.inputs["Emission Color"].default_value)
|
||||
|
||||
@_set_check
|
||||
def emission_color_set(self, color):
|
||||
if self.use_nodes and self.node_principled_bsdf is not None:
|
||||
color = values_clamp(color, 0.0, 1000000.0)
|
||||
color = rgb_to_rgba(color)
|
||||
self.node_principled_bsdf.inputs["Emission"].default_value = color
|
||||
self.node_principled_bsdf.inputs["Emission Color"].default_value = color
|
||||
|
||||
emission_color = property(emission_color_get, emission_color_set)
|
||||
|
||||
|
@ -484,7 +484,7 @@ class PrincipledBSDFWrapper(ShaderWrapper):
|
|||
return None
|
||||
return ShaderImageTextureWrapper(
|
||||
self, self.node_principled_bsdf,
|
||||
self.node_principled_bsdf.inputs["Emission"],
|
||||
self.node_principled_bsdf.inputs["Emission Color"],
|
||||
grid_row_diff=1,
|
||||
)
|
||||
|
||||
|
|
|
@ -692,6 +692,12 @@ static void version_principled_bsdf_emission(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
|
||||
/* Rename Principled BSDF emission to emission color. */
|
||||
static void version_principled_bsdf_emission_color(bNodeTree *ntree)
|
||||
{
|
||||
version_node_input_socket_name(ntree, SH_NODE_BSDF_PRINCIPLED, "Emission", "Emission Color");
|
||||
}
|
||||
|
||||
/* Replace old Principled Hair BSDF as a variant in the new Principled Hair BSDF. */
|
||||
static void version_replace_principled_hair_model(bNodeTree *ntree)
|
||||
{
|
||||
|
@ -1423,6 +1429,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);
|
||||
}
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
|
|
|
@ -609,7 +609,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
|||
if (node->type == SH_NODE_BSDF_PRINCIPLED) {
|
||||
bNodeSocket *roughness_socket = nodeFindSocket(node, SOCK_IN, "Roughness");
|
||||
*version_cycles_node_socket_float_value(roughness_socket) = 0.5f;
|
||||
bNodeSocket *emission = nodeFindSocket(node, SOCK_IN, "Emission");
|
||||
bNodeSocket *emission = nodeFindSocket(node, SOCK_IN, "Emission Color");
|
||||
copy_v4_fl(version_cycles_node_socket_rgba_value(emission), 1.0f);
|
||||
bNodeSocket *emission_strength = nodeFindSocket(node, SOCK_IN, "Emission Strength");
|
||||
*version_cycles_node_socket_float_value(emission_strength) = 0.0f;
|
||||
|
|
|
@ -330,7 +330,7 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot)
|
|||
int locy = -300 * (node_map.size() - 2);
|
||||
if (cot.isColor()) {
|
||||
COLLADAFW::Color col = cot.getColor();
|
||||
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Emission");
|
||||
bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Emission Color");
|
||||
float *fcol = (float *)socket->default_value;
|
||||
|
||||
fcol[0] = col.getRed();
|
||||
|
@ -340,9 +340,9 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot)
|
|||
}
|
||||
// texture
|
||||
else if (cot.isTexture()) {
|
||||
bNode *texture_node = add_texture_node(cot, -300, locy, "Emission");
|
||||
bNode *texture_node = add_texture_node(cot, -300, locy, "Emission Color");
|
||||
if (texture_node != nullptr) {
|
||||
add_link(texture_node, "Color", shader_node, "Emission");
|
||||
add_link(texture_node, "Color", shader_node, "Emission Color");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1188,7 +1188,7 @@ COLLADASW::ColorOrTexture bc_get_emission(Material *ma)
|
|||
return bc_get_cot(default_color);
|
||||
}
|
||||
|
||||
COLLADASW::ColorOrTexture cot = bc_get_cot_from_shader(shader, "Emission", default_color);
|
||||
COLLADASW::ColorOrTexture cot = bc_get_cot_from_shader(shader, "Emission Color", default_color);
|
||||
|
||||
/* If using texture, emission strength is not supported. */
|
||||
COLLADASW::Color col = cot.getColor();
|
||||
|
|
|
@ -465,7 +465,7 @@ void USDMaterialReader::set_principled_node_inputs(bNode *principled,
|
|||
}
|
||||
|
||||
if (pxr::UsdShadeInput emissive_input = usd_shader.GetInput(usdtokens::emissiveColor)) {
|
||||
set_node_input(emissive_input, principled, "Emission", ntree, column, &context);
|
||||
set_node_input(emissive_input, principled, "Emission Color", ntree, column, &context);
|
||||
}
|
||||
|
||||
if (pxr::UsdShadeInput specular_input = usd_shader.GetInput(usdtokens::specularColor)) {
|
||||
|
|
|
@ -292,7 +292,7 @@ static InputSpecMap &preview_surface_input_map()
|
|||
{
|
||||
static InputSpecMap input_map = {
|
||||
{"Base Color", {usdtokens::diffuse_color, pxr::SdfValueTypeNames->Float3, true}},
|
||||
{"Emission", {usdtokens::emissive_color, pxr::SdfValueTypeNames->Float3, true}},
|
||||
{"Emission Color", {usdtokens::emissive_color, pxr::SdfValueTypeNames->Float3, true}},
|
||||
{"Color", {usdtokens::diffuse_color, pxr::SdfValueTypeNames->Float3, true}},
|
||||
{"Roughness", {usdtokens::roughness, pxr::SdfValueTypeNames->Float, true}},
|
||||
{"Metallic", {usdtokens::metallic, pxr::SdfValueTypeNames->Float, true}},
|
||||
|
|
|
@ -32,7 +32,7 @@ const char *tex_map_type_to_socket_id[] = {
|
|||
"Roughness",
|
||||
"Sheen",
|
||||
"Metallic", /* Map reflection to metallic. */
|
||||
"Emission",
|
||||
"Emission Color",
|
||||
"Alpha",
|
||||
"Normal",
|
||||
};
|
||||
|
@ -232,7 +232,7 @@ static void store_bsdf_properties(const bNode *bsdf_node,
|
|||
float emission_strength = 0.0f;
|
||||
if (bsdf_node) {
|
||||
copy_property_from_node(SOCK_FLOAT, bsdf_node, "Emission Strength", {&emission_strength, 1});
|
||||
copy_property_from_node(SOCK_RGBA, bsdf_node, "Emission", {emission_col, 3});
|
||||
copy_property_from_node(SOCK_RGBA, bsdf_node, "Emission Color", {emission_col, 3});
|
||||
}
|
||||
mul_v3_fl(emission_col, emission_strength);
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ static void set_bsdf_socket_values(bNode *bsdf, Material *mat, const MTLMaterial
|
|||
|
||||
float3 emission_color = mtl_mat.emission_color;
|
||||
if (emission_color.x >= 0 && emission_color.y >= 0 && emission_color.z >= 0) {
|
||||
set_property_of_socket(SOCK_RGBA, "Emission", {emission_color, 3}, bsdf);
|
||||
set_property_of_socket(SOCK_RGBA, "Emission Color", {emission_color, 3}, bsdf);
|
||||
}
|
||||
if (mtl_mat.tex_map_of_type(MTLTexMapType::Emission).is_valid()) {
|
||||
set_property_of_socket(SOCK_FLOAT, "Emission Strength", {1.0f}, bsdf);
|
||||
|
|
|
@ -184,7 +184,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
|
||||
/* Panel for Emission settings. */
|
||||
PanelDeclarationBuilder &emis = b.add_panel("Emission").default_closed(true);
|
||||
emis.add_input<decl::Color>("Emission").default_value({1.0f, 1.0f, 1.0f, 1.0f});
|
||||
emis.add_input<decl::Color>("Emission Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
|
||||
#define SOCK_EMISSION_ID 27
|
||||
emis.add_input<decl::Float>("Emission Strength").default_value(0.0).min(0.0f).max(1000000.0f);
|
||||
#define SOCK_EMISSION_STRENGTH_ID 28
|
||||
|
|
Loading…
Reference in New Issue