Fix Cycles OSL hair BSDF inconsistencies with SVM.

This commit is contained in:
Brecht Van Lommel
2016-07-29 02:22:01 +02:00
parent 52fb441c13
commit e0c7aaf5ad
2 changed files with 25 additions and 22 deletions

View File

@@ -24,34 +24,35 @@ shader node_hair_bsdf(
float Offset = 0.0, float Offset = 0.0,
float RoughnessU = 0.1, float RoughnessU = 0.1,
float RoughnessV = 1.0, float RoughnessV = 1.0,
normal Normal = Ng, normal Tangent = normal(0, 0, 0),
output closure color BSDF = 0) output closure color BSDF = 0)
{ {
float IsStrand;
float roughnessh = clamp(RoughnessU, 0.001, 1.0); float roughnessh = clamp(RoughnessU, 0.001, 1.0);
float roughnessv = clamp(RoughnessV, 0.001, 1.0); float roughnessv = clamp(RoughnessV, 0.001, 1.0);
getattribute("geom:is_curve", IsStrand); float offset = -Offset;
if (!IsStrand) { normal T;
if (backfacing()) { float IsCurve = 0;
BSDF = transparent(); getattribute("geom:is_curve", IsCurve);
}
else { if (isconnected(Tangent)) {
if (component == "reflection") T = Tangent;
BSDF = Color * hair_reflection(Normal, roughnessh, roughnessv, normalize(dPdv), 0.0); }
else else if(!IsCurve) {
BSDF = Color * hair_transmission(Normal, roughnessh, roughnessv, normalize(dPdv), 0.0); T = normalize(dPdv);
} offset = 0.0;
} }
else { else {
if (backfacing()) { T = normalize(dPdu);
BSDF = transparent(); }
}
else { if (backfacing() && IsCurve) {
if (component == "reflection") BSDF = transparent();
BSDF = Color * hair_reflection(Normal, roughnessh, roughnessv, dPdu, -Offset); }
else else {
BSDF = Color * hair_transmission(Normal, roughnessh, roughnessv, dPdu, -Offset); if (component == "reflection")
} BSDF = Color * hair_reflection(Ng, roughnessh, roughnessv, T, offset);
else
BSDF = Color * hair_transmission(Ng, roughnessh, roughnessv, T, offset);
} }
} }

View File

@@ -17,6 +17,8 @@ def render_file(filepath):
"--factory-startup", "--factory-startup",
filepath, filepath,
"-E", "CYCLES", "-E", "CYCLES",
# Run with OSL enabled
# "--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True",
"-o", TEMP_FILE_MASK, "-o", TEMP_FILE_MASK,
"-F", "PNG", "-F", "PNG",
"-f", "1", "-f", "1",