Cycles: Support texture coordinate from another object
This is the same as blender internal's texture mapping from another object, so this way it's possible to control texture space of one object by another. Quite straightforward change apart from the workaround for the stupidness of the dependency graph. Now shader has flag telling that it depends on object transform. This is the simplest way to know which shaders needs to be tagged for update when object changes. This might give some false-positive tags now but reducing them should not be priority for Cycles and rather be a priority to bring new dependency graph. Also GLSL preview does not support using other object for mapping. This is actually correct for BI shading as well and to be addressed as a part of general GLSL viewport improvements since it's not really clear how to support this in GLSL. Reviewers: brecht, juicyfruit Subscribers: eyecandy, venomgfx Differential Revision: https://developer.blender.org/D1021
This commit is contained in:
@@ -18,15 +18,33 @@ CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Texture Coordinate Node */
|
||||
|
||||
ccl_device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, int path_flag, float *stack, uint type, uint out_offset)
|
||||
ccl_device void svm_node_tex_coord(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
int path_flag,
|
||||
float *stack,
|
||||
uint4 node,
|
||||
int *offset)
|
||||
{
|
||||
float3 data;
|
||||
uint type = node.y;
|
||||
uint out_offset = node.z;
|
||||
|
||||
switch(type) {
|
||||
case NODE_TEXCO_OBJECT: {
|
||||
data = sd->P;
|
||||
if(sd->object != OBJECT_NONE)
|
||||
object_inverse_position_transform(kg, sd, &data);
|
||||
if(node.w == 0) {
|
||||
if(sd->object != OBJECT_NONE) {
|
||||
object_inverse_position_transform(kg, sd, &data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Transform tfm;
|
||||
tfm.x = read_node_float(kg, offset);
|
||||
tfm.y = read_node_float(kg, offset);
|
||||
tfm.z = read_node_float(kg, offset);
|
||||
tfm.w = read_node_float(kg, offset);
|
||||
data = transform_point(&tfm, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NODE_TEXCO_NORMAL: {
|
||||
|
Reference in New Issue
Block a user