Cycles: make light UV available for Texture Coordinate node

The input socket of Image Texture node is connected with the UV output
of Texture Coordinate node by default, the later reads the geometry UV,
which is not available for lights because they have no real geometry.
The current implementation simply retrieves UV from shader data.

Pull Request: https://projects.blender.org/blender/blender/pulls/108691
This commit is contained in:
Weizhen Huang 2023-06-07 12:31:36 +02:00 committed by Weizhen Huang
parent 5399c7a79f
commit e3697710d0
2 changed files with 8 additions and 1 deletions

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

@ -71,6 +71,11 @@ ccl_device_noinline void svm_node_attr(KernelGlobals kg,
}
#endif
if (sd->type == PRIMITIVE_LAMP && node.y == ATTR_STD_UV) {
stack_store_float3(stack, out_offset, make_float3(1.0f - sd->u - sd->v, sd->u, 0.0f));
return;
}
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P;