Fix #113777: Cycles IES texture not working for sphere lights
This was a regression after the sphere light changes, where the normal now is the normal along the geometry of the light and no longer suitable for the IES texture direction. This not only fixes point lights with non-zero radius, but makes the IES texture direction work consistently across light types and meshes, always rotated by the object transform.
This commit is contained in:
@@ -66,13 +66,14 @@ struct SocketType {
|
||||
LINK_TEXTURE_GENERATED = (1 << 4),
|
||||
LINK_TEXTURE_NORMAL = (1 << 5),
|
||||
LINK_TEXTURE_UV = (1 << 6),
|
||||
LINK_INCOMING = (1 << 7),
|
||||
LINK_NORMAL = (1 << 8),
|
||||
LINK_POSITION = (1 << 9),
|
||||
LINK_TANGENT = (1 << 10),
|
||||
LINK_OSL_INITIALIZER = (1 << 11),
|
||||
LINK_TEXTURE_INCOMING = (1 << 7),
|
||||
LINK_INCOMING = (1 << 8),
|
||||
LINK_NORMAL = (1 << 9),
|
||||
LINK_POSITION = (1 << 10),
|
||||
LINK_TANGENT = (1 << 11),
|
||||
LINK_OSL_INITIALIZER = (1 << 12),
|
||||
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) |
|
||||
(1 << 10) | (1 << 11)
|
||||
(1 << 10) | (1 << 11) | (1 << 12)
|
||||
};
|
||||
|
||||
ustring name;
|
||||
|
||||
@@ -847,8 +847,9 @@ void ShaderGraph::default_inputs(bool do_osl)
|
||||
/* nodes can specify default texture coordinates, for now we give
|
||||
* everything the position by default, except for the sky texture */
|
||||
|
||||
ShaderNode *geom = NULL;
|
||||
ShaderNode *texco = NULL;
|
||||
GeometryNode *geom = NULL;
|
||||
TextureCoordinateNode *texco = NULL;
|
||||
VectorTransformNode *normal_transform = NULL;
|
||||
|
||||
foreach (ShaderNode *node, nodes) {
|
||||
foreach (ShaderInput *input, node->inputs) {
|
||||
@@ -874,6 +875,20 @@ void ShaderGraph::default_inputs(bool do_osl)
|
||||
|
||||
connect(texco->output("UV"), input);
|
||||
}
|
||||
else if (input->flags() & SocketType::LINK_TEXTURE_INCOMING) {
|
||||
if (!geom) {
|
||||
geom = create_node<GeometryNode>();
|
||||
}
|
||||
if (!normal_transform) {
|
||||
normal_transform = create_node<VectorTransformNode>();
|
||||
normal_transform->set_transform_type(NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
|
||||
normal_transform->set_convert_from(NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD);
|
||||
normal_transform->set_convert_to(NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT);
|
||||
connect(geom->output("Incoming"), normal_transform->input("Vector"));
|
||||
}
|
||||
|
||||
connect(normal_transform->output("Vector"), input);
|
||||
}
|
||||
else if (input->flags() & SocketType::LINK_INCOMING) {
|
||||
if (!geom) {
|
||||
geom = create_node<GeometryNode>();
|
||||
@@ -912,6 +927,9 @@ void ShaderGraph::default_inputs(bool do_osl)
|
||||
if (texco) {
|
||||
add(texco);
|
||||
}
|
||||
if (normal_transform) {
|
||||
add(normal_transform);
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderGraph::refine_bump_nodes()
|
||||
|
||||
@@ -1336,7 +1336,7 @@ NODE_DEFINE(IESLightNode)
|
||||
SOCKET_STRING(filename, "File Name", ustring());
|
||||
|
||||
SOCKET_IN_FLOAT(strength, "Strength", 1.0f);
|
||||
SOCKET_IN_POINT(vector, "Vector", zero_float3(), SocketType::LINK_TEXTURE_NORMAL);
|
||||
SOCKET_IN_POINT(vector, "Vector", zero_float3(), SocketType::LINK_TEXTURE_INCOMING);
|
||||
|
||||
SOCKET_OUT_FLOAT(fac, "Fac");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user