Cycles: new Microfacet-based Hair BSDF with elliptical cross-section support #105600
@ -55,9 +55,9 @@ ccl_device_forceinline void film_write_denoising_features_surface(KernelGlobals
|
||||
}
|
||||
|
||||
/* All closures contribute to the normal feature, but only diffuse-like ones to the albedo. */
|
||||
if (sc->type != CLOSURE_BSDF_HAIR_MICROFACET_ID) {
|
||||
normal += sc->N * sc->sample_weight;
|
||||
}
|
||||
/* If far-field hair, use fiber tangent as feature instead of normal. */
|
||||
normal += (sc->type == CLOSURE_BSDF_HAIR_MICROFACET_ID ? safe_normalize(sd->dPdu) : sc->N) *
|
||||
sc->sample_weight;
|
||||
|
||||
sum_weight += sc->sample_weight;
|
||||
|
||||
if (sc->type == CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID) {
|
||||
@ -68,25 +68,16 @@ ccl_device_forceinline void film_write_denoising_features_surface(KernelGlobals
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (sc->type == CLOSURE_BSDF_HAIR_MICROFACET_ID) {
|
||||
/* If hair, use fiber tangent as feature instead of normal. */
|
||||
normal += safe_normalize(sd->dPdu);
|
||||
}
|
||||
|
||||
Spectrum closure_albedo = bsdf_albedo(sd, sc);
|
||||
if (sc->type == CLOSURE_BSDF_HAIR_MICROFACET_ID) {
|
||||
if (bsdf_get_specular_roughness_squared(sc) > sqr(0.075f) ||
|
||||
sc->type == CLOSURE_BSDF_HAIR_MICROFACET_ID) {
|
||||
/* Hair far field models "count" as diffuse. */
|
||||
diffuse_albedo += closure_albedo;
|
||||
sum_nonspecular_weight += sc->sample_weight;
|
||||
}
|
||||
else {
|
||||
if (bsdf_get_specular_roughness_squared(sc) > sqr(0.075f)) {
|
||||
diffuse_albedo += closure_albedo;
|
||||
sum_nonspecular_weight += sc->sample_weight;
|
||||
}
|
||||
else {
|
||||
specular_albedo += closure_albedo;
|
||||
}
|
||||
specular_albedo += closure_albedo;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1246,8 +1246,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
|
||||
#define SH_NODE_COMBINE_COLOR 711
|
||||
#define SH_NODE_SEPARATE_COLOR 712
|
||||
#define SH_NODE_MIX 713
|
||||
|
||||
#define SH_NODE_BSDF_HAIR_MICROFACET 800
|
||||
#define SH_NODE_BSDF_HAIR_MICROFACET 714
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@ -84,13 +84,21 @@ void node_bsdf_hair_microfacet(vec4 color,
|
||||
out Closure result)
|
||||
{
|
||||
/* Placeholder closure.
|
||||
* Some computation will have to happen here just like the Principled BSDF. */
|
||||
* TODO: Some computation will have to happen here just like the Principled BSDF. */
|
||||
#if 0
|
||||
ClosureHair hair_data;
|
||||
hair_data.weight = weight;
|
||||
hair_data.color = color.rgb;
|
||||
hair_data.offset = offset;
|
||||
hair_data.roughness = vec2(0.0);
|
||||
hair_data.T = g_data.curve_B;
|
||||
|
||||
#else
|
||||
ClosureDiffuse hair_data;
|
||||
hair_data.weight = weight;
|
||||
hair_data.color = color.rgb;
|
||||
hair_data.N = g_data.N;
|
||||
hair_data.sss_radius = vec3(0.0);
|
||||
hair_data.sss_id = 0u;
|
||||
#endif
|
||||
result = closure_eval(hair_data);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ static int node_shader_gpu_hair_microfacet(GPUMaterial *mat,
|
||||
|
||||
} // namespace blender::nodes::node_shader_bsdf_hair_microfacet_cc
|
||||
|
||||
/* node type definition */
|
||||
/* Node type definition. */
|
||||
void register_node_type_sh_bsdf_hair_microfacet()
|
||||
{
|
||||
namespace file_ns = blender::nodes::node_shader_bsdf_hair_microfacet_cc;
|
||||
|
Loading…
Reference in New Issue
Block a user
Is this conditional just due to compatibility?
If yes, and the tangent works better, I think we should just change it for the old model as well.
This piece of code is provided by @olivier.fx. I didn't came up with the logic myself, but for a far-field model the "normal" is always the incoming direction, not really a feature of the object itself, so tangent makes more sense here. For the previous near-field model the normal does influence the appearance and it makes sense to use normal as feature. Not sure if tangent works better, I'm not very knowledgeable about denoising.