diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-29 19:54:42 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2016-10-29 20:24:08 +0300 |
commit | 1272ee455e7aeed3f6acb0b8a8366af5ad6aec99 (patch) | |
tree | 1ea02f9f80aea75403d78e898a6d2449d6331036 /intern/cycles/render/light.cpp | |
parent | d3b0977a354d91c363d7128f3e0ef2c5eea977e7 (diff) |
Cycles: Implement texture coordinates for Point, Spot and Area Lamps
When using the Normal output of the Texture Coordinate node on Point and Spot lamps, the coordinates now depend on the rotation of the lamp.
On Area lamps, the Parametric output of the Geometry node now returns UV coordinates on the area lamp.
Credit for the Area lamp part goes to Stefan Werner (from D1995).
Diffstat (limited to 'intern/cycles/render/light.cpp')
-rw-r--r-- | intern/cycles/render/light.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 93f6d7902f0..777f3229ce6 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -126,6 +126,8 @@ NODE_DEFINE(Light) SOCKET_FLOAT(spot_angle, "Spot Angle", M_PI_4_F); SOCKET_FLOAT(spot_smooth, "Spot Smooth", 0.0f); + SOCKET_TRANSFORM(tfm, "Transform", transform_identity()); + SOCKET_BOOLEAN(cast_shadow, "Cast Shadow", true); SOCKET_BOOLEAN(use_mis, "Use Mis", false); SOCKET_BOOLEAN(use_diffuse, "Use Diffuse", true); @@ -762,6 +764,11 @@ void LightManager::device_update_points(Device *device, light_data[light_index*LIGHT_SIZE + 4] = make_float4(max_bounces, 0.0f, 0.0f, 0.0f); + Transform tfm = light->tfm; + Transform itfm = transform_inverse(tfm); + memcpy(&light_data[light_index*LIGHT_SIZE + 5], &tfm, sizeof(float4)*3); + memcpy(&light_data[light_index*LIGHT_SIZE + 8], &itfm, sizeof(float4)*3); + light_index++; } @@ -788,6 +795,11 @@ void LightManager::device_update_points(Device *device, light_data[light_index*LIGHT_SIZE + 3] = make_float4(-1, dir.x, dir.y, dir.z); light_data[light_index*LIGHT_SIZE + 4] = make_float4(-1, 0.0f, 0.0f, 0.0f); + Transform tfm = light->tfm; + Transform itfm = transform_inverse(tfm); + memcpy(&light_data[light_index*LIGHT_SIZE + 5], &tfm, sizeof(float4)*3); + memcpy(&light_data[light_index*LIGHT_SIZE + 8], &itfm, sizeof(float4)*3); + light_index++; } |