Improve backscatter color of subsurface scattering in Principled BSDF
Differential Revision: https://developer.blender.org/D2685
This commit is contained in:
@@ -191,7 +191,7 @@ class PrincipledBSSRDFClosure : public CBSSRDFClosure {
|
|||||||
public:
|
public:
|
||||||
void setup(ShaderData *sd, int path_flag, float3 weight)
|
void setup(ShaderData *sd, int path_flag, float3 weight)
|
||||||
{
|
{
|
||||||
alloc(sd, path_flag, weight * albedo, CLOSURE_BSSRDF_PRINCIPLED_ID);
|
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -57,8 +57,8 @@ shader node_principled_bsdf(
|
|||||||
|
|
||||||
if (diffuse_weight > 1e-5) {
|
if (diffuse_weight > 1e-5) {
|
||||||
if (Subsurface > 1e-5) {
|
if (Subsurface > 1e-5) {
|
||||||
color Albedo = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
|
color mixed_ss_base_color = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
|
||||||
BSDF = bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, Albedo, Roughness);
|
BSDF = mixed_ss_base_color * bssrdf_principled(Normal, Subsurface * SubsurfaceRadius, 0.0, SubsurfaceColor, Roughness);
|
||||||
} else {
|
} else {
|
||||||
BSDF = BaseColor * principled_diffuse(Normal, Roughness);
|
BSDF = BaseColor * principled_diffuse(Normal, Roughness);
|
||||||
}
|
}
|
||||||
|
@@ -141,8 +141,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
float3 weight = sd->svm_closure_weight * mix_weight;
|
float3 weight = sd->svm_closure_weight * mix_weight;
|
||||||
|
|
||||||
#ifdef __SUBSURFACE__
|
#ifdef __SUBSURFACE__
|
||||||
float3 albedo = subsurface_color * subsurface + base_color * (1.0f - subsurface);
|
float3 mixed_ss_base_color = subsurface_color * subsurface + base_color * (1.0f - subsurface);
|
||||||
float3 subsurf_weight = weight * albedo * diffuse_weight;
|
float3 subsurf_weight = weight * mixed_ss_base_color * diffuse_weight;
|
||||||
float subsurf_sample_weight = fabsf(average(subsurf_weight));
|
float subsurf_sample_weight = fabsf(average(subsurf_weight));
|
||||||
|
|
||||||
/* disable in case of diffuse ancestor, can't see it well then and
|
/* disable in case of diffuse ancestor, can't see it well then and
|
||||||
@@ -154,7 +154,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
/* need to set the base color in this case such that the
|
/* need to set the base color in this case such that the
|
||||||
* rays get the correctly mixed color after transmitting
|
* rays get the correctly mixed color after transmitting
|
||||||
* the object */
|
* the object */
|
||||||
base_color = albedo;
|
base_color = mixed_ss_base_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* diffuse */
|
/* diffuse */
|
||||||
@@ -186,7 +186,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
bssrdf->sample_weight = subsurf_sample_weight;
|
bssrdf->sample_weight = subsurf_sample_weight;
|
||||||
bssrdf->radius = radius.x;
|
bssrdf->radius = radius.x;
|
||||||
bssrdf->texture_blur = texture_blur;
|
bssrdf->texture_blur = texture_blur;
|
||||||
bssrdf->albedo = albedo.x;
|
bssrdf->albedo = subsurface_color.x;
|
||||||
bssrdf->sharpness = sharpness;
|
bssrdf->sharpness = sharpness;
|
||||||
bssrdf->N = N;
|
bssrdf->N = N;
|
||||||
bssrdf->roughness = roughness;
|
bssrdf->roughness = roughness;
|
||||||
@@ -200,7 +200,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
bssrdf->sample_weight = subsurf_sample_weight;
|
bssrdf->sample_weight = subsurf_sample_weight;
|
||||||
bssrdf->radius = radius.y;
|
bssrdf->radius = radius.y;
|
||||||
bssrdf->texture_blur = texture_blur;
|
bssrdf->texture_blur = texture_blur;
|
||||||
bssrdf->albedo = albedo.y;
|
bssrdf->albedo = subsurface_color.y;
|
||||||
bssrdf->sharpness = sharpness;
|
bssrdf->sharpness = sharpness;
|
||||||
bssrdf->N = N;
|
bssrdf->N = N;
|
||||||
bssrdf->roughness = roughness;
|
bssrdf->roughness = roughness;
|
||||||
@@ -214,7 +214,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
|
|||||||
bssrdf->sample_weight = subsurf_sample_weight;
|
bssrdf->sample_weight = subsurf_sample_weight;
|
||||||
bssrdf->radius = radius.z;
|
bssrdf->radius = radius.z;
|
||||||
bssrdf->texture_blur = texture_blur;
|
bssrdf->texture_blur = texture_blur;
|
||||||
bssrdf->albedo = albedo.z;
|
bssrdf->albedo = subsurface_color.z;
|
||||||
bssrdf->sharpness = sharpness;
|
bssrdf->sharpness = sharpness;
|
||||||
bssrdf->N = N;
|
bssrdf->N = N;
|
||||||
bssrdf->roughness = roughness;
|
bssrdf->roughness = roughness;
|
||||||
|
Reference in New Issue
Block a user