Conversion shaders

The following shaders allow for conversions between data types: 

Float to Int

Convert float to an integer value.

Float to Matrix

Construct a 4x4 matrix from float values for each element. The input_xy parameters set the value in column x and row y.

Float to RGB

Create RGB color from individual R, G, B float values.

'Float To RGB' used to convert 'Noise' float output to RGB

Float to RGBA

Create RGBA color from R, G, B, A float values.

RGB to Float

Convert RGB color to float value.

RGB to Vector

Convert RGB color to vector.

RGBA to Float

Convert RGB color and alpha value to float.

Vector to RGB

Convert vector to RGB color.

 

Arnold Data Type Conversions

The following table shows how data types are converted within Arnold itself.

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