Support vertex colors

This commit is contained in:
luboslenco
2020-02-28 16:14:19 +01:00
parent b9f228a141
commit 7469015f3e
8 changed files with 24 additions and 6 deletions
+1
View File
@@ -25,6 +25,7 @@ class MakePaint {
con_paint.data.color_writes_green = [true, true, true, true];
con_paint.data.color_writes_blue = [true, true, true, true];
con_paint.data.color_writes_alpha = [true, true, true, true];
con_paint.allow_vcols = Context.paintObject.data.geom.cols != null;
var vert = con_paint.make_vert();
var frag = con_paint.make_frag();
+11 -3
View File
@@ -211,6 +211,10 @@ class Material {
vert.add_out("vec4 wvpposition");
vert.write_end('wvpposition = gl_Position;');
}
if (con.is_elem('col')) {
vert.add_out('vec3 vcolor');
vert.write_attrib('vcolor = col.rgb;');
}
}
static function parse_output(node: TNode): TShaderOut {
@@ -378,9 +382,13 @@ class Material {
if (node.type == "ATTRIBUTE") {
if (socket == node.outputs[0]) { // Color
curshader.context.add_elem("col", "short4norm"); // Vcols only for now
// return "vcolor";
return "vec3(0.0, 0.0, 0.0)";
if (curshader.context.allow_vcols) {
curshader.context.add_elem("col", "short4norm"); // Vcols only for now
}
else {
curshader.write_attrib("vec3 vcolor = vec3(1.0, 1.0, 1.0);");
}
return "vcolor";
}
else { // Vector
curshader.context.add_elem("tex", "short2norm"); // UVMaps only for now
+1
View File
@@ -22,6 +22,7 @@ class MaterialShaderContext {
public var tesc:MaterialShader;
public var tese:MaterialShader;
public var data:TShaderContext;
public var allow_vcols = false;
var material:TMaterial;
var constants:Array<TShaderConstant>;
var tunits:Array<TTextureUnit>;