Shader Nodes, Inputs for LightMapping node? (Solved)

Success!

If anyone else would like to add team-colors or tintable textures with lighting, here’s what I did:

I coped the Lighting.j3md, as well as the accompanying Lighting.frag and Lighting.vert files (to assets/MatDefs dir) and added two parameters:

//the texture within which the alpha component determines the amount of tint on that area.
Texture2D TintMap

//what color to use as the tint color
Color TintColor

I also added them to the Defines section, and then I do this in the fragment shader, on line 174:

#ifdef DIFFUSEMAP
  vec4 diffuseColor = texture2D(m_DiffuseMap, newTexCoord);

  //are we using a TINTMAP alpha value to tint this with a TintColor?
  #ifdef TINTMAP
    vec4 tintColor = texture2D(m_TintMap, newTexCoord);

    //invert the tintColor alpha
    float tintAmount = 1.0 - tintColor.a;

    //get tint amount
    vec4 tint = m_TintColor;
    tint.r *= tintAmount;
    tint.g *= tintAmount;
    tint.b *= tintAmount;

    diffuseColor.r = mix(diffuseColor.r, tint.r, tintAmount);
    diffuseColor.g = mix(diffuseColor.g, tint.g, tintAmount);
    diffuseColor.b = mix(diffuseColor.b, tint.b, tintAmount);
  #endif
#else
  vec4 diffuseColor = vec4(1.0);
#endif
2 Likes