When shader parameters of are connected together, some allowance is made for parameters to be connected when they have different types. Here are the rules for automatic parameter conversions.

Key:

(empty)conversion is disallowed/ignored
copycopy (no need to convert)
expandall components set to the same source value
shallow copyfor pointer types (pointer, node, array, matrix), copy the pointer, not the actual value
boolean castzero means false, non-zero means true, and vice-versa
upcastsmaller integer type just gets stuffed into a larger integer type
downcastlarger integer type gets truncated into a smaller integer type
averagethe average of the components are taken
      TARGET     
SOURCEenumbooleanbyteintuintfloatRGBRGBAvectorpointpoint2
enumcopy          
boolean copyboolean
cast
boolean
cast
boolean
cast
      
byte 

boolean
cast

copyupcastupcast      
int boolean
cast
downcastcopycopy      
uint boolean
cast
downcastcopycopy      
float     copy

r = flt
g = flt
b = flt

r = flt
g = flt
b = flt
a = 1

x = flt
y = flt
z = flt

x = flt
y = flt
z = flt

x = flt
y = flt

RGB     average(rgb)copy

r = r
g = g

b = b
a = 1

x = r
y = g
z = b

x = r
y = g
z = b

x = r
y = g

RGBA     average(rgb)

r = r
g = g

b = b

copy

x = r
y = g
z = b

x = r
y = g
z = b

x = r
y = g

vector     vector.x

r = x
g = y
b = z

r = x
g = y
b = z
a = 1

copy

x = x
y = y
z = z

 
point     pnt.x

r = x
g = y
b = z

r = x
g = y
b = z
a = 1

x = x
y = y
z = z
copy 
point2     pnt2.x

r = x
g = y
b = 0

r = x
g = y
b = 0
a = 1

x = x
y = y
z = 0

x = x
y = y
z = 0

copy
string           
node           
pointer           
array           
matrix           

 

 

    TARGET 
SOURCEstringnodepointerarraymatrix
enum     
boolean     
byte     
int     
uint     
float     
RGB     
RGBA     
vector     
point     
point2     
stringcopy    
node  shallow copy  
pointer  shallow copy  
array   shallow copy 
matrix    shallow copy

 

 


A few notes:

  • The node type (AI_TYPE_NODE) is currently resolved at scene creation time, and node-to-node shader connections are not formally allowed since they internally are turned into a connection based on the output type of the shader node. However, whenever one wants to pass a node along, they can pass it as a generic pointer type instead of using other mechanisms such as shader message passing. The vast majority of the time, if you are using pointer passing inside of your shaders, however, you should re-think your design.
  • No automatic conversions exist between integer types and floating-point types.
  • No automatic conversions exist between enumerations and any other type.


 

  • No labels