diff options
Diffstat (limited to 'source')
5 files changed, 48 insertions, 20 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl index 80ed4e1ef69..1f5851c17d2 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl @@ -54,6 +54,7 @@ void node_bsdf_principled(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -134,7 +135,7 @@ void node_bsdf_principled(vec4 base_color, result.radiance += render_pass_glossy_mask(spec_col, out_spec); /* Coarse approx. */ result.radiance += render_pass_diffuse_mask(sheen_color, out_diff * out_sheen * sheen_color); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); @@ -161,6 +162,7 @@ void node_bsdf_principled_dielectric(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -193,7 +195,7 @@ void node_bsdf_principled_dielectric(vec4 base_color, result.radiance = render_pass_glossy_mask(vec3(1.0), out_spec); result.radiance += render_pass_diffuse_mask(sheen_color, out_diff * out_sheen * sheen_color); result.radiance += render_pass_diffuse_mask(diffuse, out_diff * diffuse); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); @@ -218,6 +220,7 @@ void node_bsdf_principled_metallic(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -238,7 +241,7 @@ void node_bsdf_principled_metallic(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = render_pass_glossy_mask(vec3(1.0), out_spec); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); @@ -263,6 +266,7 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -295,7 +299,7 @@ void node_bsdf_principled_clearcoat(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = render_pass_glossy_mask(vec3(spec_col), out_spec); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); @@ -321,6 +325,7 @@ void node_bsdf_principled_subsurface(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -365,7 +370,7 @@ void node_bsdf_principled_subsurface(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = render_pass_glossy_mask(vec3(1.0), out_spec); result.radiance += render_pass_diffuse_mask(sheen_color, out_diff * out_sheen * sheen_color); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); @@ -394,6 +399,7 @@ void node_bsdf_principled_glass(vec4 base_color, float transmission, float transmission_roughness, vec4 emission, + float emission_strength, float alpha, vec3 N, vec3 CN, @@ -436,7 +442,7 @@ void node_bsdf_principled_glass(vec4 base_color, result = CLOSURE_DEFAULT; result.radiance = render_pass_glossy_mask(refr_color, out_refr * refr_color); result.radiance += render_pass_glossy_mask(spec_col, out_spec * spec_col); - result.radiance += render_pass_emission_mask(emission.rgb); + result.radiance += render_pass_emission_mask(emission.rgb * emission_strength); result.radiance *= alpha; closure_load_ssr_data(ssr_spec * alpha, roughness, N, viewCameraVec, int(ssr_id), result); result.transmittance = vec3(1.0 - alpha); diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp index 06f54884668..16a9691d67e 100644 --- a/source/blender/io/collada/Materials.cpp +++ b/source/blender/io/collada/Materials.cpp @@ -323,6 +323,11 @@ void MaterialNode::set_emission(COLLADAFW::ColorOrTexture &cot) add_link(texture_node, 0, shader_node, 0); } } + + bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Emission Strength"); + if (socket) { + *(float *)socket->default_value = 1.0f; + } } void MaterialNode::set_opacity(COLLADAFW::ColorOrTexture &cot) diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 2493b3a386b..2719578753b 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -1326,13 +1326,29 @@ COLLADASW::ColorOrTexture bc_get_base_color(Material *ma) COLLADASW::ColorOrTexture bc_get_emission(Material *ma) { - Color default_color = {0, 0, 0, 1}; + Color default_color = {0, 0, 0, 1}; /* default black */ bNode *shader = bc_get_master_shader(ma); - if (ma->use_nodes && shader) { - return bc_get_cot_from_shader(shader, "Emission", default_color); + if (!(ma->use_nodes && shader)) { + return bc_get_cot(default_color); + } + + double emission_strength = 0.0; + bc_get_float_from_shader(shader, emission_strength, "Emission Strength"); + if (emission_strength == 0.0) { + return bc_get_cot(default_color); } - return bc_get_cot(default_color); /* default black */ + COLLADASW::ColorOrTexture cot = bc_get_cot_from_shader(shader, "Emission", default_color); + + /* Multiply in emission strength. If using texture, emission strength is not + * supported. */ + COLLADASW::Color col = cot.getColor(); + cot.getColor().set(emission_strength * col.getRed(), + emission_strength * col.getGreen(), + emission_strength * col.getBlue(), + col.getAlpha()); + + return cot; } COLLADASW::ColorOrTexture bc_get_ambient(Material *ma) @@ -1393,7 +1409,7 @@ double bc_get_reflectivity(Material *ma) return reflectivity; } -double bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid) +bool bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid) { bNodeSocket *socket = nodeFindSocket(shader, SOCK_IN, nodeid.c_str()); if (socket) { diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index 24ee1054e11..fa65d398954 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -384,7 +384,7 @@ double bc_get_alpha(Material *ma); double bc_get_ior(Material *ma); double bc_get_shininess(Material *ma); -double bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid); +bool bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid); COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader, std::string nodeid, Color &default_color, diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c index b9784e44053..ccc5198832a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c @@ -49,6 +49,7 @@ static bNodeSocketTemplate sh_node_bsdf_principled_in[] = { {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, @@ -89,26 +90,26 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, GPUNodeLink *sss_scale; /* Normals */ - if (!in[19].link) { - GPU_link(mat, "world_normals_get", &in[19].link); + if (!in[20].link) { + GPU_link(mat, "world_normals_get", &in[20].link); } /* Clearcoat Normals */ - if (!in[20].link) { - GPU_link(mat, "world_normals_get", &in[20].link); + if (!in[21].link) { + GPU_link(mat, "world_normals_get", &in[21].link); } #if 0 /* Not used at the moment. */ /* Tangents */ - if (!in[21].link) { + if (!in[22].link) { GPUNodeLink *orco = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "tangent_orco_z", orco, &in[21].link); + GPU_link(mat, "tangent_orco_z", orco, &in[22].link); GPU_link(mat, "node_tangent", GPU_builtin(GPU_WORLD_NORMAL), - in[21].link, + in[22].link, GPU_builtin(GPU_OBJECT_MATRIX), - &in[21].link); + &in[22].link); } #endif |