Jump to content

PartVariant Color Tinting


Electrocutor

Recommended Posts

Allow color tinting on all parts: stock or mod.

oPpUHlQ.jpg

 

Requires:
ModuleManager

 

Instructions:

  • Create a new text file under \GameData with extension .cfg (f.e. ColorTinting.cfg)
  • Copy and paste one of the following into the file and save it.

 

Natural Color System (NCS)

Spoiler

// Natural(NCS) Colors
@PART[*] {
	%MODULE[ModulePartVariants] {
		%name = ModulePartVariants

		VARIANT {
			name = NCS_Black
			displayName = Black

			primaryColor = #323232
			secondaryColor = #323232

			TEXTURE {
				_Color = #323232
			}
		}
		VARIANT {
			name = NCS_Red
			displayName = Red

			primaryColor = #c40233
			secondaryColor = #c40233

			TEXTURE {
				_Color = #c40233
			}
		}
		VARIANT {
			name = NCS_Green
			displayName = Green

			primaryColor = #009f6b
			secondaryColor = #009f6b

			TEXTURE {
				_Color = #009f6b
			}
		}
		VARIANT {
			name = NCS_Blue
			displayName = Blue

			primaryColor = #0087bd
			secondaryColor = #0087bd

			TEXTURE {
				_Color = #0087bd
			}
		}
		VARIANT {
			name = NCS_Yellow
			displayName = Yellow

			primaryColor = #ffd300
			secondaryColor = #ffd300

			TEXTURE {
				_Color = #ffd300
			}
		}
	}
}

 

 

Pigments (CMYK)

Spoiler

// Pigment(CMYK) Colors
@PART[*] {
	%MODULE[ModulePartVariants] {
		%name = ModulePartVariants

		VARIANT {
			name = CMYK_Black
			displayName = Black

			primaryColor = #323232
			secondaryColor = #323232

			TEXTURE {
				_Color = #323232
			}
		}
		VARIANT {
			name = CMYK_Red
			displayName = Red

			primaryColor = #ed1c24
			secondaryColor = #ed1c24

			TEXTURE {
				_Color = #ed1c24
			}
		}
		VARIANT {
			name = CMYK_Magenta
			displayName = Magenta

			primaryColor = #ff0090
			secondaryColor = #ff0090

			TEXTURE {
				_Color = #ff0090
			}
		}
		VARIANT {
			name = CMYK_Blue
			displayName = Blue

			primaryColor = #333399
			secondaryColor = #333399

			TEXTURE {
				_Color = #333399
			}
		}
		VARIANT {
			name = CMYK_Cyan
			displayName = Cyan

			primaryColor = #00b7eb
			secondaryColor = #00b7eb

			TEXTURE {
				_Color = #00b7eb
			}
		}
		VARIANT {
			name = CMYK_Green
			displayName = Green

			primaryColor = #00a550
			secondaryColor = #00a550

			TEXTURE {
				_Color = #00a550
			}
		}
		VARIANT {
			name = CMYK_Yellow
			displayName = Yellow

			primaryColor = #ffef00
			secondaryColor = #ffef00

			TEXTURE {
				_Color = #ffef00
			}
		}
	}
}

 

 

KSP Colors (this is the one most people would want)

Spoiler

// KSP Colors
@PART[*]:HAS[!MODULE[ModulePartVariants]] {
	MODULE {
		name = ModulePartVariants

		VARIANT {
			name = KSP_Black
			displayName = Black

			primaryColor = #2d2e2d
			secondaryColor = #2d2e2d

			TEXTURE {
				_Color = #2d2e2d
			}
		}
		VARIANT {
			name = KSP_MetalGrey
			displayName = Metal Grey

			primaryColor = #7b7d7b
			secondaryColor = #7b7d7b

			TEXTURE {
				_Color = #7b7d7b
			}
		}
		VARIANT {
			name = KSP_DarkGrey
			displayName = Dark Grey

			primaryColor = #4c4f47
			secondaryColor = #4c4f47

			TEXTURE {
				_Color = #4c4f47
			}
		}
		VARIANT {
			name = KSP_Orange
			displayName = Orange

			primaryColor = #f49841
			secondaryColor = #f49841

			TEXTURE {
				_Color = #f49841
			}
		}
		VARIANT {
			name = KSP_Green
			displayName = Green

			primaryColor = #737a5a
			secondaryColor = #737a5a

			TEXTURE {
				_Color = #737a5a
			}
		}
		VARIANT {
			name = KSP_Yellow
			displayName = Yellow

			primaryColor = #e3b85f
			secondaryColor = #e3b85f

			TEXTURE {
				_Color = #e3b85f
			}
		}
		VARIANT {
			name = KSP_Red
			displayName = Red

			primaryColor = #a52a29
			secondaryColor = #a52a29

			TEXTURE {
				_Color = #a52a29
			}
		}
		VARIANT {
			name = KSP_Blue
			displayName = Blue

			primaryColor = #394563
			secondaryColor = #394563

			TEXTURE {
				_Color = #394563
			}
		}
		VARIANT {
			name = KSP_Cyan
			displayName = Cyan

			primaryColor = #567988
			secondaryColor = #567988

			TEXTURE {
				_Color = #567988
			}
		}
	}
}

@PART[*]:HAS[@MODULE[ModulePartVariants]:HAS[@VARIANT:HAS[!GAMEOBJECTS]]] {
	@MODULE[ModulePartVariants] {
		VARIANT {
			name = KSP_Black
			displayName = Black

			primaryColor = #2d2e2d
			secondaryColor = #2d2e2d

			TEXTURE {
				_Color = #2d2e2d
			}
		}
		VARIANT {
			name = KSP_MetalGrey
			displayName = Metal Grey

			primaryColor = #7b7d7b
			secondaryColor = #7b7d7b

			TEXTURE {
				_Color = #7b7d7b
			}
		}
		VARIANT {
			name = KSP_DarkGrey
			displayName = Dark Grey

			primaryColor = #4c4f47
			secondaryColor = #4c4f47

			TEXTURE {
				_Color = #4c4f47
			}
		}
		VARIANT {
			name = KSP_Orange
			displayName = Orange

			primaryColor = #f49841
			secondaryColor = #f49841

			TEXTURE {
				_Color = #f49841
			}
		}
		VARIANT {
			name = KSP_Green
			displayName = Green

			primaryColor = #737a5a
			secondaryColor = #737a5a

			TEXTURE {
				_Color = #737a5a
			}
		}
		VARIANT {
			name = KSP_Yellow
			displayName = Yellow

			primaryColor = #e3b85f
			secondaryColor = #e3b85f

			TEXTURE {
				_Color = #e3b85f
			}
		}
		VARIANT {
			name = KSP_Red
			displayName = Red

			primaryColor = #a52a29
			secondaryColor = #a52a29

			TEXTURE {
				_Color = #a52a29
			}
		}
		VARIANT {
			name = KSP_Blue
			displayName = Blue

			primaryColor = #394563
			secondaryColor = #394563

			TEXTURE {
				_Color = #394563
			}
		}
		VARIANT {
			name = KSP_Cyan
			displayName = Cyan

			primaryColor = #567988
			secondaryColor = #567988

			TEXTURE {
				_Color = #567988
			}
		}
	}
}

// if has variants and has a variant that sets gameobjects, then do this; otherwise, just add normally

@PART[*]:HAS[@MODULE[ModulePartVariants]:HAS[@VARIANT:HAS[@GAMEOBJECTS]]] {
	@MODULE[ModulePartVariants] {
		+VARIANT,0 {
			@name = KSP_Black
			@displayName = Black

			@primaryColor = #2d2e2d
			@secondaryColor = #2d2e2d

			%TEXTURE {
				%_Color = #2d2e2d
			}
		}
		+VARIANT,0 {
			@name = KSP_MetalGrey
			@displayName = Metal Grey

			@primaryColor = #7b7d7b
			@secondaryColor = #7b7d7b

			%TEXTURE {
				%_Color = #7b7d7b
			}
		}
		+VARIANT,0 {
			@name = KSP_DarkGrey
			@displayName = Dark Grey

			@primaryColor = #4c4f47
			@secondaryColor = #4c4f47

			%TEXTURE {
				%_Color = #4c4f47
			}
		}
		+VARIANT,0 {
			@name = KSP_Orange
			@displayName = Orange

			@primaryColor = #f49841
			@secondaryColor = #f49841

			%TEXTURE {
				%_Color = #f49841
			}
		}
		+VARIANT,0 {
			@name = KSP_Green
			@displayName = Green

			@primaryColor = #737a5a
			@secondaryColor = #737a5a

			%TEXTURE {
				%_Color = #737a5a
			}
		}
		+VARIANT,0 {
			@name = KSP_Yellow
			@displayName = Yellow

			@primaryColor = #e3b85f
			@secondaryColor = #e3b85f

			%TEXTURE {
				%_Color = #e3b85f
			}
		}
		+VARIANT,0 {
			@name = KSP_Red
			@displayName = Red

			@primaryColor = #a52a29
			@secondaryColor = #a52a29

			%TEXTURE {
				%_Color = #a52a29
			}
		}
		+VARIANT,0 {
			@name = KSP_Blue
			@displayName = Blue

			@primaryColor = #394563
			@secondaryColor = #394563

			%TEXTURE {
				%_Color = #394563
			}
		}
		+VARIANT,0 {
			@name = KSP_Cyan
			@displayName = Cyan

			@primaryColor = #567988
			@secondaryColor = #567988

			%TEXTURE {
				%_Color = #567988
			}
		}
	}
}

 

 

Edited by Electrocutor
Link to comment
Share on other sites

Strange, I see that this interferes with the part's flag. Steps to reproduce:

 

1.  Take out part with flag on it.  Mk1 Lander Can is a great example to use.

2.  Set a mission flag, take your pick.

3. Change the part color via the variants provided by this MM config.

4. Observe the flag is interfered with.

5.  Re-choose mission flag.

6. Observe flag returns to proper display.

7.  Go to step 3 and repeat.

Link to comment
Share on other sites

16 minutes ago, klesh said:

Strange, I see that this interferes with the part's flag. Steps to reproduce:

 

1.  Take out part with flag on it.  Mk1 Lander Can is a great example to use.

2.  Set a mission flag, take your pick.

3. Change the part color via the variants provided by this MM config.

4. Observe the flag is interfered with.

5.  Re-choose mission flag.

6. Observe flag returns to proper display.

7.  Go to step 3 and repeat.

It's not this; it's a bug with KSP itself.

Link to comment
Share on other sites

I figured as much.  Its a very cool use of the Variant system!  Well done.

Might I suggest versions of the orange and "dark grey" that the MH parts come with (on the russian parts)?  Perhaps the gold and "white" and "dark" from the structural panels as well? 

Essentially a Making History companion .cfg.

Edited by klesh
Link to comment
Share on other sites

1 hour ago, klesh said:

I figured as much.  Its a very cool use of the Variant system!  Well done.

Might I suggest versions of the orange and "dark grey" that the MH parts come with (on the russian parts)?  Perhaps the gold and "white" and "dark" from the structural panels as well? 

Essentially a Making History companion .cfg.

Okay... updated with KSP colors. That said, since the "white" parts have varying shades, they'll not all match perfectly.

Edited by Electrocutor
Link to comment
Share on other sites

oNJnVcm.jpg

Almost there... it seems I will have to do the ones with existing variants with a little different syntax because those parts have a whole bunch of extra meshes inside them that have to be explicitly hidden. I don't think I'll bother with it for now though unless there a number of people who want it fixed up.

Link to comment
Share on other sites

Really nice job man! looking like this will be a really cool feature. I see this is working on parts with variant switching?  I was under the impression from squad and what I have seen so far myself you could not load 2 modules at once? This appears to be working fine with multiple modules?  I tried to implement the stock colour switch with my Porkjet tanks and had to get rid of the stock resource switching code because I could only get one module at a time to load? I install my Porkjet parts as model replacements under the squad folder so that they will work Importing and exporting stock craft files. It appears the one module limit is a Squad game engine limitation and module manager can bypass it ? How do you see this working with other mods? I know that there is https://spacedock.info/mod/1748/Mauws' Custom Paint Jobs [Alpha Pack] That I have not tried yet. Even if stuff continues to play nice together How long do you think we can go before we blow up the UI "with to many choices" ?  Nice job that Stock Orange looks sweet on solar panels.                           VAUjebu.pngNow if I can get working Linux shaders again. Oh the pretty reflections.           

Edited by Delbrutis
Link to comment
Share on other sites

15 hours ago, Electrocutor said:

It's not this; it's a bug with KSP itself.

Well if it's a Squad bug then that's why they don't have a texture switch on any part with a flag . With this installed any part with a flag gets "overridden" essentially looses the flag on load. Loading to the pad' loading a new craft' loading a save vessel out in the world. Even if you have not applied a new texture.or have switched back to the original it still overrides the flag. This may actually be part of a Squad feature. I don't know how many people  noticed but we now have persistent flags in the game. Your craft now will keep the flag chosen in the VAB when it was built and saved. Even if you have a different flag selected when you load the craft it will have the flag it was saved with. Now you can have multiple craft together with different flags on them in the game. Good news is it looks like your colour changes get saved and remembered exactly the same. But I think that's what is messing with the flag? You don't have to actually change the colour.Just having the module loaded on the part seems to interfere. It would be a shame to loose this ability on command parts and cockpits. But maybe there is a way to exclude the flag transform layer? The other parts look cool and worst case scenario is to just write in a exclusion for command part's. Or maybe ModuleManager could look for any part that has the flag transform listed in it's configuration. I'M not super good at writing MM file's but I might have a go at removing anything with a flag While I'M waiting for the new TRR to come out. The new Ven wheels just got fixed. And most mods  seem to be almost caught up .1.4.2 looks like it fixed some of the biggest Linux bugs "FINGERS CROSSED".  I know there are a lot of people that think the other switchers Firespitter' BAC9' Interstellar' "I think that's most of them ?" Work better or have nicer features. And I think their probably right. But I just think any time you can do something with a simple configuration file under stock It's just a way better option. So many mod's with different dependences to keep track of. Would be nice to cut down on some of those dll files we always have to keep updated.        

 

OK I just checked this out and it's worse than I thought . It turns out in my first post when I was surprised this worked with two modules loaded I was right " I wish I wasn’t"  the flag transform was just another module. Unity cant seem to keep more than one. When I tried to get it working with the same configuration file the game simply loaded the first and ignored any other modules. ModuleManager Technically lets you bypass this and load more than one. They appear to be working at first But when the game tries to access or use a module's info again like reloading a craft or a scene change it cant. moduleManager can handle loading more than one and maybe they would work fine together ? But the native game loader obviously cant.  Example take a structural tube and make it it's full length attach something to the bottom node. colour it and watch the node disappear with the attached part inside of it . You can start over just like applying a new flag and it works in the VAB Temporarily until you change the texture again or leave to launch the craft load a new scene or whatever . It wont work outside of the VAB . Sorry but it looks like having this stuff universally applied is a "BAD IDEA"  OH well guess it's back to one of the Dll files.               

Edited by Delbrutis
Add Update Info
Link to comment
Share on other sites

If enough people want this, I will fix the issue with existing variants not properly using the tinting. It just requires a bit of MM finesse so that each iteration of the existing variant also has a tinted version of that variant.

That said... using an actual recolor texture like what Textures Unlimited has allowed @Manwith Noname to do is a much better approach because it allows actual recoloring instead of just a universal tint. It is, however, also a great deal of work to make those recolor mask textures.

Edited by Electrocutor
Link to comment
Share on other sites

I've updated the KSP Colors script to compensate for existing model-changing variants. The current implementation uses the first variant as a base and then applies tint to it. I had originally made a copy of every variant for tinting, but that became rather unruly very quickly.

Edited by Electrocutor
Link to comment
Share on other sites

38 minutes ago, [INDO]dimas_1502 said:

so this is basically kerbpaint but stock?

No, Kerbpaint requires a new shader and new textures with masks to allow specific repainting; like what Textures Unlimited allows. This is not even a mod, it's just a config that uses the stuff already in KSP to tint what is already there. It is very generic.

Link to comment
Share on other sites

1 hour ago, Electrocutor said:

No, Kerbpaint requires a new shader and new textures with masks to allow specific repainting; like what Textures Unlimited allows. This is not even a mod, it's just a config that uses the stuff already in KSP to tint what is already there. It is very generic.

no i mean the tinting ability
also ">stock"

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

Hello, sorry for being dense, i feel like i can use the information in the op to get at what i want, but i cannot wrap my head around it.

I am writing a patch that clones the existing fuel cells to create monoprop fuel cells. I am simply writing a module manager patch that uses +PART to clone the fuel cell and then modifying the INPUT_RESOURCE nodes to use monoprop instead of lfo.

Can I use the _COLOR variable to tint the existing texture so that my cloned part has a slightly different coloration?

I feel like I can, but I am not sure if the syntax would be as simple as that. Would it work if i just added the following?

TEXTURE
{
    _COLOR = #FFD700
}

Nope! Just tried it, didn't work.

Edit2: Hm I have made a tiny bit of progress, but it does not seem to work still. I am thinking, judging by the screenshots on this thead, that the tinting works by tinting the white parts of the existing texture. The texture for the fuel cells have very little or no white in it, so the variant coloring just does not show up. Nope, that's not it. Looking closely, it does have some white parts and pieces, but they are not getting any tinting.

Edited by canisin
Link to comment
Share on other sites

This might be of interest to some of you 

Also @canisin, you can change the texture in the part config in the MODEL section 

MODEL
{
model = BDArmory/Parts/agm-86Cruise/model
texture = texture, OrX/Parts/TMTSNBN/texture2
scale = 1.0, 1.0, 1.0
}
 
if you have questions feel free to pm me 
Link to comment
Share on other sites

3 hours ago, DoctorDavinci said:

This might be of interest to some of you 

Also @canisin, you can change the texture in the part config in the MODEL section 

MODEL
{
model = BDArmory/Parts/agm-86Cruise/model
texture = texture, OrX/Parts/TMTSNBN/texture2
scale = 1.0, 1.0, 1.0
}
 
if you have questions feel free to pm me 

Yea, i could change the texture, but that would mean that i need a new texture, right? I was hoping that i would be able to get away with merely tinting the existing texture.

Link to comment
Share on other sites

1 hour ago, canisin said:

Yea, i could change the texture, but that would mean that i need a new texture, right? I was hoping that i would be able to get away with merely tinting the existing texture.

Yes, you would need to add a texture but that is super simple to do and deosn't really add much in the means of space taken in memory

Link to comment
Share on other sites

13 minutes ago, canisin said:

That's not the problem, the problem is i can't/don't want to create a new texture. I am not good at painting :)

Textures can be a pain ... DCK covers like 18 mods including stock and I had to do a number of custom textures for all the parts

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...