Fix T90815: wrong Cycles OSL normal map render after recent optimization
This commit is contained in:
@@ -110,6 +110,7 @@ ustring OSLRenderServices::u_curve_thickness("geom:curve_thickness");
|
|||||||
ustring OSLRenderServices::u_curve_length("geom:curve_length");
|
ustring OSLRenderServices::u_curve_length("geom:curve_length");
|
||||||
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
|
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
|
||||||
ustring OSLRenderServices::u_curve_random("geom:curve_random");
|
ustring OSLRenderServices::u_curve_random("geom:curve_random");
|
||||||
|
ustring OSLRenderServices::u_normal_map_normal("geom:normal_map_normal");
|
||||||
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
|
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
|
||||||
ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
|
ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
|
||||||
ustring OSLRenderServices::u_path_diffuse_depth("path:diffuse_depth");
|
ustring OSLRenderServices::u_path_diffuse_depth("path:diffuse_depth");
|
||||||
@@ -985,8 +986,18 @@ bool OSLRenderServices::get_object_standard_attribute(const KernelGlobals *kg,
|
|||||||
float3 f = curve_tangent_normal(kg, sd);
|
float3 f = curve_tangent_normal(kg, sd);
|
||||||
return set_attribute_float3(f, type, derivatives, val);
|
return set_attribute_float3(f, type, derivatives, val);
|
||||||
}
|
}
|
||||||
else
|
else if (name == u_normal_map_normal) {
|
||||||
|
if (sd->type & PRIMITIVE_ALL_TRIANGLE) {
|
||||||
|
float3 f = triangle_smooth_normal_unnormalized(kg, sd, sd->Ng, sd->prim, sd->u, sd->v);
|
||||||
|
return set_attribute_float3(f, type, derivatives, val);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSLRenderServices::get_background_attribute(const KernelGlobals *kg,
|
bool OSLRenderServices::get_background_attribute(const KernelGlobals *kg,
|
||||||
|
@@ -297,6 +297,7 @@ class OSLRenderServices : public OSL::RendererServices {
|
|||||||
static ustring u_curve_length;
|
static ustring u_curve_length;
|
||||||
static ustring u_curve_tangent_normal;
|
static ustring u_curve_tangent_normal;
|
||||||
static ustring u_curve_random;
|
static ustring u_curve_random;
|
||||||
|
static ustring u_normal_map_normal;
|
||||||
static ustring u_path_ray_length;
|
static ustring u_path_ray_length;
|
||||||
static ustring u_path_ray_depth;
|
static ustring u_path_ray_depth;
|
||||||
static ustring u_path_diffuse_depth;
|
static ustring u_path_diffuse_depth;
|
||||||
|
@@ -45,7 +45,7 @@ shader node_normal_map(normal NormalIn = N,
|
|||||||
|
|
||||||
// get _unnormalized_ interpolated normal and tangent
|
// get _unnormalized_ interpolated normal and tangent
|
||||||
if (getattribute(attr_name, tangent) && getattribute(attr_sign_name, tangent_sign) &&
|
if (getattribute(attr_name, tangent) && getattribute(attr_sign_name, tangent_sign) &&
|
||||||
(!is_smooth || getattribute("geom:N", ninterp))) {
|
(!is_smooth || getattribute("geom:normal_map_normal", ninterp))) {
|
||||||
// apply normal map
|
// apply normal map
|
||||||
vector B = tangent_sign * cross(ninterp, tangent);
|
vector B = tangent_sign * cross(ninterp, tangent);
|
||||||
Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * ninterp);
|
Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * ninterp);
|
||||||
|
Reference in New Issue
Block a user