I’m using the shader editor and I need to add some extra functionality to the Lighting.j3md.
So, I added the LightMappingNode and I’m not entirely sure what inputs it should be given. Here’s a screenshot of what I have right now:
I suppose the texCoord is the texture coordinate for the model? I get that from the CommonVert thingy.
And the color is fairly obvious I guess. But the lightMap?
it’s gonna be complicated, Lighting has not yet been translated to shader nodes. Also the editor is really buggy in 3.0 so you’d better modify the shader directly IMO
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