Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/shaders/node_vertex_color.osl
| Show All 16 Lines | |||||
| #include "stdcycles.h" | #include "stdcycles.h" | ||||
| shader node_vertex_color(string bump_offset = "center", | shader node_vertex_color(string bump_offset = "center", | ||||
| string layer_name = "", | string layer_name = "", | ||||
| output color Color = 0.0, | output color Color = 0.0, | ||||
| output float Alpha = 0.0) | output float Alpha = 0.0) | ||||
| { | { | ||||
| float vertex_color[4]; | float vertex_color[4]; | ||||
| if (getattribute(layer_name, vertex_color)) { | string vertex_color_layer; | ||||
| if (layer_name == "") { | |||||
| vertex_color_layer = "geom:vertex_color"; | |||||
| } | |||||
| else { | |||||
| vertex_color_layer = layer_name; | |||||
| } | |||||
| if (getattribute(vertex_color_layer, vertex_color)) { | |||||
| Color = color(vertex_color[0], vertex_color[1], vertex_color[2]); | Color = color(vertex_color[0], vertex_color[1], vertex_color[2]); | ||||
| Alpha = vertex_color[3]; | Alpha = vertex_color[3]; | ||||
| if (bump_offset == "dx") { | if (bump_offset == "dx") { | ||||
| Color += Dx(Color); | Color += Dx(Color); | ||||
| Alpha += Dx(Alpha); | Alpha += Dx(Alpha); | ||||
| } | } | ||||
| else if (bump_offset == "dy") { | else if (bump_offset == "dy") { | ||||
| Color += Dy(Color); | Color += Dy(Color); | ||||
| Alpha += Dy(Alpha); | Alpha += Dy(Alpha); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| warning("%s", "Invalid attribute."); | warning("%s", "Invalid attribute."); | ||||
| } | } | ||||
| } | } | ||||