Fix #124642: OSL generates UVs for objects that don't have any #124673

Merged
Sergey Sharybin merged 10 commits from Alaska/blender:add_is_light into main 2024-07-24 12:17:02 +02:00
4 changed files with 15 additions and 1 deletions

View File

@ -75,6 +75,7 @@ ustring OSLRenderServices::u_object_location("object:location");
ustring OSLRenderServices::u_object_color("object:color");
ustring OSLRenderServices::u_object_alpha("object:alpha");
ustring OSLRenderServices::u_object_index("object:index");
ustring OSLRenderServices::u_object_is_light("object:is_light");
weizhen marked this conversation as resolved Outdated

The variable name should be matching the name of the attribute.

The variable name should be matching the name of the attribute.
ustring OSLRenderServices::u_geom_dupli_generated("geom:dupli_generated");
ustring OSLRenderServices::u_geom_dupli_uv("geom:dupli_uv");
ustring OSLRenderServices::u_material_index("material:index");
@ -870,6 +871,10 @@ bool OSLRenderServices::get_object_standard_attribute(const KernelGlobalsCPU *kg
float f = object_pass_id(kg, sd->object);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_object_is_light) {
float f = (sd->type & PRIMITIVE_LAMP) != 0;
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_geom_dupli_generated) {
float3 f = object_dupli_generated(kg, sd->object);
return set_attribute_float3(f, type, derivatives, val);

View File

@ -306,6 +306,7 @@ class OSLRenderServices : public OSL::RendererServices {
static ustring u_object_color;
static ustring u_object_alpha;
static ustring u_object_index;
static ustring u_object_is_light;
static ustring u_geom_dupli_generated;
static ustring u_geom_dupli_uv;
static ustring u_material_index;

View File

@ -48,6 +48,8 @@ ccl_device_constant DeviceString u_object_color = 12695623857059169556ull;
ccl_device_constant DeviceString u_object_alpha = 11165053919428293151ull;
/* "object:index" */
ccl_device_constant DeviceString u_object_index = 6588325838217472556ull;
/* "object:is_light" */
ccl_device_constant DeviceString u_object_is_light = 13979755312845091842ull;
/* "geom:dupli_generated" */
ccl_device_constant DeviceString u_geom_dupli_generated = 6715607178003388908ull;
/* "geom:dupli_uv" */
@ -1117,6 +1119,10 @@ ccl_device_inline bool get_object_standard_attribute(KernelGlobals kg,
float f = object_pass_id(kg, sd->object);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == DeviceStrings::u_object_is_light) {
float f = ((sd->type & PRIMITIVE_LAMP) != 0);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == DeviceStrings::u_geom_dupli_generated) {
float3 f = object_dupli_generated(kg, sd->object);
return set_attribute_float3(f, type, derivatives, val);

View File

@ -48,7 +48,9 @@ shader node_texture_coordinate(
if (!getattribute("geom:generated", Generated)) {
Generated = transform("object", P);
}
if (!getattribute("geom:uv", UV)) {
float is_light;
getattribute("object:is_light", is_light);
if (!getattribute("geom:uv", UV) && is_light) {
UV = point(1.0 - u - v, u, 0.0);
}
}