• Unity
  • Greyscale Colour Mapping

  • Изменено
Related Discussions
...

Hi Herald,

Have you encountered grey scale colour mapping technique?

In other words I'm looking into technique where we are going to export all our artwork in greyscale and colour map it in Unity with colour gradient texture. Similar to what SVG is doing. Is there any source where I can look into?

Thank you, Marek.

Hi Marek,

That's an interesting topic. Unfortunately it's a bit too specialized to provide custom Spine shaders, but I'm sure you can easily modify one of the existing shaders with ease.

Basically it just like using a normal color lookup texture, as e.g. used in LUT-based tonemapping, just much simpler (1D instead of 3D).

So you could modify Spine-Skeleton.shader like this:

_ColorLUT ("Color LUT", 2D) = "black" {}
..
sampler2D _ColorLUT;
..

float4 frag (VertexOutput i) : SV_Target {
    fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy); // texcol.rgb containss grayscale color

// this is the only new line in the shader:
texcol.rgb = tex2D(_ColorLUT, float2(texcol.g, 0)); // use green channel of grayscale texture as lookup position

// lines below stay unchanged.
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
SHADOW_CASTER_FRAGMENT(i)
}