Jump to content

Adding lights to a Command Pod/Cockpit?


Recommended Posts

So somebody give it to me straight here, how much work would be involved in adding lights to a command pod?

Specifically the old Mk1 pod/cockpit, which I just love; and I always add back in to my games. Via a small mod I made a while back.

xgPTNzJ.png

The lack of a toggle light does bug me a bit though, and I I have dabbled in modding and config file changes a bit before but I'm no expert. I'm guessing I'd have to add the animation module in, and then make an emissive to match the Mk1 cockpit's window shape?

Any help or suggestions are most appreciated. Also if you want to tell me it's way more trouble than it's worth and I'm in over my head; that would also be welcome. Lol.

Edited by Rocket In My Pocket
Link to comment
Share on other sites

13 hours ago, Mecripp said:

Did you take the light out of it ?

Add what ksp did that come from .90 ?

Afaik it was replaced with the new Mk1 cockpit before it was ever given a light? (Ie. Crew lights in cockpits/command pods weren't a thing back then.)

I took the model itself and the config file for it directly from the game files of the last version that ever used it. (I've also checked the model and config from the Kerbin Historical Institute mod download, it also doesn't have a crew light.)

Is there a version of it available somewhere with a crew light? (To clarify what I mean by "crew light" I mean when you push the lights button and the actual window glows from the outside.)

Edited by Rocket In My Pocket
Link to comment
Share on other sites

37 minutes ago, Rocket In My Pocket said:

Afaik it was replaced with the new Mk1 cockpit before it was ever given a light? (Ie. Crew lights in cockpits/command pods weren't a thing back then.)

I took the model itself and the config file for it directly from the game files of the last version that ever used it. (I've also checked the model and config from the Kerbin Historical Institute mod download, it also doesn't have a crew light.)

Is there a version of it available somewhere with a crew light? (To clarify what I mean by "crew light" I mean when you push the lights button and the actual window glows from the outside.)

Are you any good at textures ?

Link to comment
Share on other sites

25 minutes ago, Mecripp said:

Are you any good at textures ?

I'm not the worst lol.

I'm fairly confident I could make a passable emissive texture, if someone explained the steps involved and/or what programs are needed. (Or pointed me to a guide that explains these things.)

Edited by Rocket In My Pocket
Link to comment
Share on other sites

1 hour ago, Rocket In My Pocket said:

I'm not the worst lol.

I'm fairly confident I could make a passable emissive texture, if someone explained the steps involved and/or what programs are needed. (Or pointed me to a guide that explains these things.)

Its not going to be possible as they rely on an 'Animation' component that has to be compiled into the model in the Unity Editor.

So you can't add it to existing parts using the standard ModuleAnimateGeneric setup like other stock parts.

 

There -might- be a stock module that can do it using config-defined float-curves, but as I don't use stock modules... I'm not really the right person to provide info on them.

If mods are an option, some of them might have a config-based system to do it.  I know that SSTU does -- I wrote it so that it actually takes the data from the config files and compiles a new animation at runtime (specifically to solve the case of models that did not have animations on them originally).

 

Link to comment
Share on other sites

3 minutes ago, Shadowmage said:

Its not going to be possible as they rely on an 'Animation' component that has to be compiled into the model in the Unity Editor.

So you can't add it to existing parts using the standard ModuleAnimateGeneric setup like other stock parts.

 

There -might- be a stock module that can do it using config-defined float-curves, but as I don't use stock modules... I'm not really the right person to provide info on them.

If mods are an option, some of them might have a config-based system to do it.  I know that SSTU does -- I wrote it so that it actually takes the data from the config files and compiles a new animation at runtime (specifically to solve the case of models that did not have animations on them originally).

 

I appreciate the response!

Yes, modding is definitely an option, I had to mod it back into the game in the first place; so I see no harm in going further down the rabbit hole. Lol.

To get back to my original question though; is the result going to be worth the effort? The lack of a light bothers me but it's a minor thing...I'm not lazy, and I'd be willing to learn some new systems and do some texture work to make it happen, but...I draw the line at 3D modelling since I have no experience with it. I'm also not looking to spend days and days of my time on it, so in your opinion; how large of a task would I be taking on here?

Link to comment
Share on other sites

8 minutes ago, Rocket In My Pocket said:

I'm also not looking to spend days and days of my time on it, so in your opinion; how large of a task would I be taking on here?

For someone familiar with the process, probably 15 minutes, and I would say that it is on the 'brain dead simple' end of the modding spectrum (compared to doing modeling, real texturing, extensive config work, and esp. plugin work). 

You need to create the emissive texture (maybe 5 mins for a very simple one for just the windows with a solid color), and then create the patch/edit the config file to add the module (maybe another 5 minutes as you can copypasta out of an existing part config).  As this is a stock part, and it is probably compiled using the wrong shader, you'll have to also find some way to set/specify the proper shader (you need one with emissive support).  Add another 5 minutes to copy/paste/edit a shader-assignment config (using TexturesUnlimited, or your favorite shader-replacing mod whatever that might be).

If all of that made sense to you -- great, you are probably not going to have any problems, and it probably won't take you much more than 15-20 minutes.  If any of that left you with questions -- you are probably in a for at least a few hours of work learning the various systems and how they all need to work together before you could make confident progress (shaders, textures, animations).  I would still say it is 'worth it', but I also have some strange tortured mind that actually enjoys learning new things.

 

Sadly, it is sounding like it will require at least two mods to accomplish what you are looking for -- TexturesUnlimited to allow for replacing of the shader and adding the new texture to the existing model, and SSTU for its config-based emissive animation module.  There might be other mods' with similar features that could be used, but being the author of them, those are the ones that I am familiar with.

(please let me know if you are wanting to go down this route as I can point you towards some example configs/etc that should simplify much of the process)

Link to comment
Share on other sites

Thanks again for the quick response.

Yeah, I have some experience with writing module manager patches (I wrote a small patch for myself that adds liquid fuel storage to all the stock wings for instance); so I get the gist of what you are saying, and copy pasting someone else's hard work sounds right up my alley. (Lol...) I am a little fuzzy on the details though. If I could trouble you with a few more questions I'd surely appreciate it.

-What is an "emissive" texture and how does it differ from a regular one? The stock ones just look like a black background with the "glow" drawn onto the windows. Is it really that simple?

-What's a good program for .dds files? I have paint.net and GIMP but I don't think either of them will allow me to edit them.

It sounds like your two mods are going to be the easiest and most direct solution, and I have no issues with adding them to my game; or having them be a dependency for the cockpit mod, so yea; please do point me towards some example configs! I've come this far, and I'm not going to give up with out at least giving it my best shot. Thank you again for your help so far!

Edited by Rocket In My Pocket
Link to comment
Share on other sites

38 minutes ago, Rocket In My Pocket said:

What is an "emissive" texture and how does it differ from a regular one? The stock ones just look like a black background with the "glow" drawn onto the windows. Is it really that simple?

Yep, thats it.  Black everywhere except for the spots that should glow.  The glowy spots will be brighter the closer to white the color is in the texture, and you can even include tinted colors -- I generally go for a beige/tan/yellow'ish color for window emissives (plain white looks a bit garish), but you could easily make them glow green/red/blue/purple/whatever color you want.

 

38 minutes ago, Rocket In My Pocket said:

-What's a good program for .dds files? I have paint.net and GIMP but I don't think either of them will allow me to edit them.

You don't author .dds files directly.  You create a regular .png and then convert them to DDS.  (DDS is a lossy format, and not for storage -- only use it for the 'finished' product) (Photoshop -might- let you export directly to DDS with an addon/plugin, but its just doing the export-convert process behind the scenes)

I use a self-written png-to-dds conversion tool for my own needs, but it is based on the conversion code from DDS4KSP with the GUI removed ( https://github.com/Telanor/DDS4KSP ), which still works very well.  This tool has given me the best results on DDS conversion for use in KSP, and is fairly lightweight and easy to use.

I would not recommend using the GIMP .dds plugin, as it does not export them in the right format for some reason.

 

40 minutes ago, Rocket In My Pocket said:

It sounds like your two mods are going to be the easiest and most direct solution, and I have no issues with adding them to my game; or having them be a dependency for the cockpit mod, so yea; please do point me towards some example configs!

The example for adding the emissive module is a whopping 9 lines...

https://github.com/shadowmage45/SSTULabs/blob/master/GameData/SSTU/Parts/ShipCore/Series-B/SC-B-CM.cfg#L231-L239

The patch/config for setting up the shader swap and adding the emissive texture is a bit more complex, but still not too crazy:

https://github.com/shadowmage45/SSTULabs/blob/master/GameData/SSTU/Shaders/DefaultShaderAssignments-SolarPanels.cfg#L50-L69

You'll need to know the path to the model file and to the texture files.  You'll need to know what shader you will be using (probably 'KSP/Emissive/BumpedSpecular' , but I'm not certain on that).


If you need any further pointers, please let me know.

 

Link to comment
Share on other sites

2 hours ago, Shadowmage said:

Its not going to be possible as they rely on an 'Animation' component that has to be compiled into the model in the Unity Editor.

So you can't add it to existing parts using the standard ModuleAnimateGeneric setup like other stock parts.

 

There -might- be a stock module that can do it using config-defined float-curves, but as I don't use stock modules... I'm not really the right person to provide info on them.

If mods are an option, some of them might have a config-based system to do it.  I know that SSTU does -- I wrote it so that it actually takes the data from the config files and compiles a new animation at runtime (specifically to solve the case of models that did not have animations on them originally).

 

A quick look I see squad does it 2 ways 

MODULE
	{
		name = ModuleColorChanger
		shaderProperty = _EmissiveColor
		animRate = 0.8
		animState = false
		useRate = true
		toggleInEditor = true
		toggleInFlight = true
		toggleInFlight = true
		unfocusedRange = 5
		toggleName = #autoLOC_502011 //#autoLOC_502011 = Toggle Lights
		eventOnName = #autoLOC_502012 //#autoLOC_502012 = Lights On
		eventOffName = #autoLOC_502013 //#autoLOC_502013 = Lights Off
		toggleAction = True
		defaultActionGroup = Light
		redCurve
		{
			key = 0 0 0 3
			key = 1 1 0 0
		}
		greenCurve
		{
			key = 0 0 0 1
			key = 1 1 1 0
		}
		blueCurve
		{
			key = 0 0 0 0
			key = 1 0.7 1.5 0
		}
		alphaCurve
		{
			key = 0 1
		}
	}
	MODULE
	{
		name = ModuleAnimateGeneric
		animationName = Mk1Lights
		defaultActionGroup = Light
		actionGUIName = #autoLOC_502011 //#autoLOC_502011 = Toggle Lights
		startEventGUIName = #autoLOC_502012 //#autoLOC_502012 = Lights On
		endEventGUIName = #autoLOC_502013 //#autoLOC_502013 = Lights Off
	}

 

3 hours ago, Rocket In My Pocket said:

I'm not the worst lol.

I'm fairly confident I could make a passable emissive texture, if someone explained the steps involved and/or what programs are needed. (Or pointed me to a guide that explains these things.)

No tag. You can do windows two ways. Like the engines (the harder way) or just by using the stock color changing module. You just put the right material on the windows. Note the transform the windows are on in Unity and place it in  includedRenderer = X. and it will work.

MODULE
 {
  name = ModuleColorChanger
  shaderProperty = _EmissiveColor
  animRate = 0.8  // how fast they brighten and dim
  animState = false
  useRate = true
  toggleInEditor = true
  toggleInFlight = true
  toggleInFlight = true
  unfocusedRange = 5
  toggleName = #autoLOC_502011 //#autoLOC_502011 = Toggle Lights
  eventOnName = #autoLOC_502012 //#autoLOC_502012 = Lights On
  eventOffName = #autoLOC_502013 //#autoLOC_502013 = Lights Off
  toggleAction = True
  defaultActionGroup = Light // This ties emissive lighting to main lighting AG
  includedRenderer = windows  // This is the model mesh that has an emissive texture
  redCurve
  {
   key = 0 0 0 3
   key = 1 1 0 0
  }
  greenCurve
  {
   key = 0 0 0 1
   key = 1 1 1 0
  }
  blueCurve
  {
   key = 0 0 0 0
   key = 1 0.7 1.5 0
  }
  alphaCurve
  {
   key = 0 1
  }
 }

Link to comment
Share on other sites

1 minute ago, Mecripp said:

A quick look I see squad does it 2 ways 


MODULE
	{
		name = ModuleColorChanger
		shaderProperty = _EmissiveColor
		animRate = 0.8
		animState = false
		useRate = true
		toggleInEditor = true
		toggleInFlight = true
		toggleInFlight = true
		unfocusedRange = 5
		toggleName = #autoLOC_502011 //#autoLOC_502011 = Toggle Lights
		eventOnName = #autoLOC_502012 //#autoLOC_502012 = Lights On
		eventOffName = #autoLOC_502013 //#autoLOC_502013 = Lights Off
		toggleAction = True
		defaultActionGroup = Light
		redCurve
		{
			key = 0 0 0 3
			key = 1 1 0 0
		}
		greenCurve
		{
			key = 0 0 0 1
			key = 1 1 1 0
		}
		blueCurve
		{
			key = 0 0 0 0
			key = 1 0.7 1.5 0
		}
		alphaCurve
		{
			key = 0 1
		}
	}

 

 

That first method looks like it might work (quoted above).  I'm not familiar with the stock part-modules, but that looks to be about what the SSTU module does (although the SSTU one provides sane defaults so that the config is much simpler -- however you -can- manually specify the color curves in the SSTU setup as well).  Must be a recent addition, because I know that module did not exist when I wrote mine (or I probably wouldn't have needed to write it at all).

The second posted method will not work for this instance as it requires the animation be compiled into the model.

 

@Rocket In My Pocket

So, as that stock module looks like it would work, it sounds like you might need only TexturesUnlimited for its shader/texture updating properties (or TextureReplacer might work, but I have no experience with its use or capabilities).

Link to comment
Share on other sites

And on DDS you can get a DDS plugin for gimp but it one texture at a time the one @Shadowmage posted is good also you can pick a folder not sure why he doesn't like gimp sometimes looks like it does a better job just slower to do a mod

When I get home will look for the thread more on it but liked easy lol but it all does getting it to work well that's anther story :confused:

Link to comment
Share on other sites

Disclaimer: I am talking from an almost zero experience position here.

I have taken a stab at this in the 'stockiest' way I could think of - I imported the existing texture into paint.net, saved it with another name in paint's native format. I had to correct some artifacts from the lossy import (bunch of white pixels along edges), but could then relatively easily create a second layer to paint all black except for the parts that I want to glow. I then saved that new layer as a dds.

I then fired up Blender (at this point you're thinking 'ok, he used Blender but not GIMP, what an idiot' but I prefer the dds results from paint.net - with a plugin - over those of GIMP) and used the Mu importer to open the model.mu of the cockpit. I also imported the current Mk1 standard cockpit so I could compare them and see what needed to be changed. The differences I've found:

  • Editing the cfg is easy enough, I used the current standard Mk1 cockpit as a guide.
  • The shader in the old cockpit is KSP/Diffuse. The current one uses KSP/Emissive/Specular. This can be edited in Blender.
  • The shader has a bunch of color properties defined in the current one that sound related to the glow effect (eg. _EmissiveColor, etc). This too can be edited in Blender for the old cockpit.
  • The current cockpit mu has an animation defined somewhere, which I presume is what causes the gradual transition from off to on and back when toggling the light. However, I have not found this in Blender yet. I don't know if that is because I'm not looking in the right place, or that it cannot be edited with Blender (seems unlikely), or maybe the import plugin doesn't import animations. I'm leaning towards me just not looking in the right place and hopefully someone can point me to it. If the cause is that the plugin doesn't do the animations, then I am stuck, because even if I could add such an animation with Blender itself, if the plugin cannot export it it won't be in the mu file.

With the first steps done, and the mu exported, I loaded up the game, and it gave me an exception when trying to toggle the button (which only says 'Toggle') and no glow happened - obviously because the animation the button wants to trigger doesn't exist in the mu file.

Long story short: I think it can be done 'stock' just by editing the cfg and editing the mu file in Blender, but someone would need to explain where/how to add the gradual glow animation. I get the feeling I am simply not looking in the right place to find it from the current cockpit, but it could also be that the Blender plugin simply does not 'do' animations, in which case it would require some other tool (Unity editor?).

 

Link to comment
Share on other sites

31 minutes ago, Mecripp said:

MODULE
 {
  name = ModuleColorChanger
  shaderProperty = _EmissiveColor
  animRate = 0.8  // how fast they brighten and dim
  animState = false

I found this on the cupola... it looks like this might work without requiring a compiled animation. I'll give it a try.

Link to comment
Share on other sites

Wow, lot's of info coming in here all of a sudden; I picked the wrong time to actually go back to playing KSP for a bit lol. Thanks for all the suggestions guys!

Yes, If possible I'd like to stay as stock as I can if only to keep it as simple as possible. At the same time though it sounds like that's going to involve blender/unity editor work. I'm a lot more comfortable with module copy-pasting/editing; so I'm going to stick to trying to do it that way for now.

I'd hate to just ask one of you guys to do it for me, and I'm definitely a "teach a man to fish, don't catch him one" kind of guy..but if one of you should happen to accidentally succeed while fooling around; it certainly won't hurt my feelings if you share the results. (Also, I do enjoy dipping my toes into modding every once in a while as a hobby so this is all very interesting info to me; I'm enjoying learning more about this.)

Edited by Rocket In My Pocket
Link to comment
Share on other sites

10 minutes ago, Rocket In My Pocket said:

I'd hate to just ask one of you guys to do it for me, and I'm definitely a "teach a man to fish, don't catch him one" kind of guy..but if one of you should happen to accidentally succeed while fooling around; it certainly won't hurt my feelings if you share the results. (Also, I do enjoy dipping my toes into modding every once in a while as a hobby so this is all very interesting info to me; I'm enjoying learning more about this.)

I was already on it, you can find my first (very messy) result on this dropbox link: https://www.dropbox.com/s/143dile5o305d9b/Mk1PrototypeCockpit.zip?dl=0

The texture can definitely be a lot better, but you mentioned you can do textures, so feel free to improve or redo it entirely. The zip also includes the Blender and Paint.NET source files, for what they are worth. Take, use, edit and share at will, I reserve zero rights whatsoever.

Link to comment
Share on other sites

1 minute ago, swjr-swis said:

I was already on it, you can find my first (very messy) result on this dropbox link: https://www.dropbox.com/s/143dile5o305d9b/Mk1PrototypeCockpit.zip?dl=0

The texture can definitely be a lot better, but you mentioned you can do textures, so feel free to improve or redo it entirely. The zip also includes the Blender and Paint.NET source files, for what they are worth. Take, use, edit and share at will, I reserve zero rights whatsoever.

Whoa, you're quick! 

And here I thought this thread wouldn't even get any responses for a couple of days at least. Within a few hours someone already beat me to the punch! Lol. (I guess I was in over my head a bit.)

Wow, you even put an internal antenna on it? That's some attention to detail there. Can I at least give you a credit in the mod release page when I update it? Gonna see what I can do as far as tweaking it/cleaning it up.

Link to comment
Share on other sites

24 minutes ago, Rocket In My Pocket said:

At the same time though it sounds like that's going to involve blender/unity editor work. I'm a lot more comfortable with module copy-pasting/editing; so I'm going to stick to trying to do it that way for now.

Should not be necessary.  That was the whole point of using the 'config based emissive animation' setup that I proposed earlier -- which is available through stock code.

So you should be able to disregard any of the stuff concerning using Blender or messing with .mu models.  (Yes, it can be done that way, but doesn't need to -- KISS)

Link to comment
Share on other sites

1 minute ago, Shadowmage said:

Should not be necessary.  That was the whole point of using the 'config based emissive animation' setup that I proposed earlier -- which is available through stock code.

So you should be able to disregard any of the stuff concerning using Blender or messing with .mu models.  (Yes, it can be done that way, but doesn't need to -- KISS)

Yeah, sorry if I wasn't clear; that's what I meant. That I was going to try to do it the way you suggested vs. some of the alternatives involving blender that were mentioned. 

I was working on adding it via config like in the "Emissive on Windows" thread @Mecripp posted, but @swjr-swis was two steps ahead of me it seems lol.

Seeing how he did it now, it's nice to know that I was on the right track and also, I appreciate you taking time to explain a lot of this stuff to me.

Link to comment
Share on other sites

3 hours ago, Rocket In My Pocket said:

Wow, you even put an internal antenna on it? That's some attention to detail there. Can I at least give you a credit in the mod release page when I update it? Gonna see what I can do as far as tweaking it/cleaning it up.

Well, seeing as all stock command modules have that internal antenna, I figured why not, that way it's up to date.

Credit on the release page is fine, all I meant is I assert no rights whatsoever (to appease the forum mods). I noticed I left my name in the comments of the cfg file; that was meant to be temporary while editing, to quickly find back what I changed in the editor. Please remove those before publishing it (I didn't really create those sections anyway, they are straight copies out of the other Squad part files).

 

Hmm, I just noticed a message at game load saying it can't find a texture... without specifying what texture it is trying to find. The model loads properly, the lights toggle on and off (even with my icky glow texture)... which means it loads both the part texture and the emissive one I made. Anyone know why it complains, or how I can figure out what other texture it is trying to find?

Never mind, I already found the error: Blender (read: me fumbling about in Blender) added a third but empty texture entry into the model - due to it being empty, it doesn't show it's there unless you happen to click in the empty space below the second texture. Once deleted and re-exported, KSP no longer complains.

Edited by swjr-swis
texture load error - cause found
Link to comment
Share on other sites

So, I'm still working on getting a color I'm happy with; but I thought you guys would find this picture amusing.

8906626E46034F77B7A11E059CA8855F98B7011F

Lol. So I accidentally changed the hue/color levels of the entire layer because I was in a hurry, and this was the result. Kind of neat really! x D

Edited by Rocket In My Pocket
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...