AttributeMap
Overview
AttributeMap reads data from a model for use in shading. The data can be implicit
in the model (i.e. position, geometric normal) or an explicit primitive attribute
added to models using the
UserData
object.
The following table shows what primitive attributes are expected and what values
are returned with the various map_type settings:
map_type | return value |
---|---|
primitive attribute | Explicit primitive attribute specified with primitive_attribute_name and primitive_attribute_type parameters |
position | Position in render space P (Vec3f) |
texture st | Texture coordinates specified with surface_st (Vec2f) for meshes or uv (Vec2f) for points or implicit coordinates depending on geometry type |
shading normal | Normal specified with N (Vec3f) or implicit geometric normal |
geometric normal | Implicit normal calculated from geometry (faceted for meshes) |
dpds | Partial derivative of P with respect to s texture st coordinate |
dpdt | Partial derivative of P with respect to t texture st coordinate |
dnds | Partial derivative of shading normal with respect to s texture st coordinate |
dndt | Partial derivative of shading normal with respect to t texture st coordinate |
map color | Color from color parameter or evaluated map bound to it |
hair surface P | Surface position of a curve specified with surface_P (Vec3f) |
hair surface N | Surface normal of a curve specified with surface_N (Vec3f) |
hair surface st | Surface texture st of a curve specified with surface_st (Vec2f) |
hair closest surface st | Closest surface texture st of a curve specified with closest_surface_st (Vec2f) |
id | Explicit id (int) primitive attribute |
velocity | Explicit velocity (Vec3f) primitive attribute |
acceleration | Explicit acceleration (Vec3f) primitive attribute |
motionvec | Explicit motionvec (Vec3f) primitive attribute |
Attribute Reference
Primitive Attribute attributes
primitive_attribute_name
String
default: Cd
the name of primitive attribute to display when attribute 'map type' is set to 'primitive attribute'
primitive_attribute_type
Int enum
0 = “float”
1 = “vec2f”
2 = “vec3f”
3 = “rgb” (default)
4 = “int”
the type of primitive attribute to display when attribute 'map type' is set to 'primitive attribute'
General attributes
color
Rgb bindable
default: [ 1, 1, 1 ]
input color - preferably a connected map
default_value
Rgb bindable
default: [ 1, 1, 1 ]
default value to display when the requested attribute is not available
map_type
Int enum
0 = “primitive attribute” (default)
1 = “position”
2 = “texture st”
3 = “shading normal”
4 = “geometric normal”
5 = “dpds”
6 = “dpdt”
7 = “dnds”
8 = “dndt”
9 = “map color”
12 = “hair surface P”
13 = “hair surface N”
14 = “hair surface st”
15 = “hair closest surface st”
16 = “id”
17 = “velocity”
18 = “acceleration”
19 = “motionvec”
20 = “observer direction”
No documentation available
warn_when_unavailable
Bool
default: False
Whether or not to issue a warning when the requested attribute is unavailable
Examples
-- vertex color, Cd
local attrMapPrimAttrCd = AttributeMap("attrMapPrimAttrCd") {
--[[
0 = prim attr
1 = position
2 = texture st
3 = shading normal
4 = geometric normal
5 = dpds
6 = dpdt
7 = dnds
8 = dndt
]]--
["map type"] = 0,
-- 0 = float
-- 1 = vec2
-- 2 = vec3
-- 3 = rgb
["primitive attribute type"] = 3,
["primitive attribute name"] = "Cd",
["default value"] = Rgb(0, 0, 1),
}
local attrMapPosition = AttributeMap("attrMapPosition") {
--[[
0 = prim attr
1 = position
2 = texture st
3 = shading normal
4 = geometric normal
5 = dpds
6 = dpdt
7 = dnds
8 = dndt
]]--
["map type"] = 1,
}