How does tint work? (SOLVED)

I have never been sure how the colour values work in defold, either with text or tint. I understand there are four values to a tint. Are they R G B and transparency? What are the maximum and minimum values for the vmath.vector4?

(nb. i have checked documentation and couldn’t find anything related to the actual colours etc)

1 Like

According to the shader code:

lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm;

It modifies the original rgba value of the texture. Usually it’s meant to be from 0 to 1, but I don’t see any checks on that, so you can supply values higher than 1 to make some bizarre look. Negative values won’t make sense.

Hi.

If I understand you correctly, this is my answer:

There are 4 Values in this order: Red, Green, Blue, Opaque (transparency).

Every value has to be between 0 and 1 (0, 0.1, 0.2, 0.456 … 1), while 1 is 100%.

So if you like to have a red tint/color you need 1, 0, 0, 1, so vector4(1, 0, 0, 1).

Mixing them will get the color you need. There are different tools in the web helps you to geht the right values using a RGB-Selector. You choose the color and you will get a RGB-Value.

Transparency is also between 0 and 1, 1 means 100% visible (=no transparency)

Here are some examples:

COLOR_ORANGE = vmath.vector4(1, 0.5, 0, 1)
COLOR_LIGHTBLUE = vmath.vector4(0.5, 1, 1, 1)
COLOR_RED = vmath.vector4(1, 0, 0, 1)
COLOR_GREEN = vmath.vector4(0, 1, 0, 1)
COLOR_BLUE = vmath.vector4(0, 0, 1, 1)
COLOR_YELLOW = vmath.vector4(1, 1, 0, 1)
COLOR_GREY = vmath.vector4(.7, .7, .7, 1)
COLOR_WHITE = vmath.vector4(1, 1, 1, 1)

If it helps, I could write you a very small tool (just a view lines) where you can select a colorbox and get the values back.

2 Likes

If you want a colorpicker tool you can try http://colorpicker.angelqm.com/ Set it to “PROG: JAVA RGBA” so it shows you 0-1 rgba values.

1 Like

Thanks to ross and stephen for their help.

1 Like