Jump to content

Can only get one emissive to work.


Recommended Posts

Ok, so I haven't worked on KSP with Unity for some time.  But some things you don't forget.  So I have to ask, what the hell happened to emissives???  I first tried to get this working in my trusty old 2017 Unity.  No luck. Upgraded to 2019 per the part tools post, still no luck.

I have a part. 4 emissives, 4 point lights.  Everything looks great in Unity.  I write the part, load it into KSP and only one emissive works.  The other 3 and apparently the point lights don't work.

  • All 4 parts are set to KSP/Emissive/Diffuse.
  • All 4 parts use the same texture and same emissive texture.
  • All 4 parts have the same emissive color, black.
  • I've tried creating the animation on both the root gameobject and the main part with the same results..
  • I add the mesh renderer material emissive color for all 4 parts.
  • I add the light color for all 4 point lights.
  • Animation duration 60 seconds.
  • I scrub to 0 sec, I set all of the parts colors to 0.
  • I scrub to 60 sec, I set all of the parts colors to 1.
  • When I play the animation in Unity, all 4 emissives and all 4 point lights work.
  • I write the part and it's definitely going in the correct directory. I know this because I've intentionally changed all the emissive colors to white and it's obvious in-game.

Load up ksp, turn the lights on. ONE emissive works.

Ok, so I know this type animation worked in the past so I was trying to figure out what the hell I was doing wrong.

I have a lantern.  1 bulb, one point light.  Animation changes the color of the bulb, intensity of the light.  Now here goes.

  • If I have the emissive and point light on the animation, only the emissive works.
  • If I have only the point light on the animation and the bulb set to ksp/diffuse nothing works
  • If I have the point light on the animation AND the bulb set to emissive/diffuse... THE BULB ANIMATES!  WHAT?????
  • Doesn't matter what I do, the pointlight won't animate. Tried realtime and baked mode both.  Got liquided, set the intensity to 5000... no light.

 

Now I know that tutorial from like 6 years ago about making emissives.  But I've never need to use that in the past.  What's changed and why won't just point lights animate???

And just for the sake of argument. I gave it a try, it animated nothing caused a null ref.


Showing the animation and emissives at 0 sec

roWjv3N.png

Showing the animation and emissives at 60 sec showing all 4 work.

MrLqFjz.png

Part loaded into KSP, ONE emissive works

P5mumRp.png

Edited by Fengist
Link to comment
Share on other sites

Ok, this took some digging.  A post I did 7 years ago about emissives.
 

In that post I got some help figuring out a way to edit the animation files to make them compatible with a newer version of KSP (using unity 4 at the time).

Now, here' the gist of it.  If I just write the part with the animation, Unity bombs with out of memory errors (Unity 2019) or stream read errors (Unity 2017).  However, if I edit the animation file as mentioned above, the part will load fine but only one of the emissives and none of the point lights work.  Haven't tried this in 2019 yet.  Took me long enough to find this post.  Done working on it for the night.

Link to comment
Share on other sites

Things got changed in 1.11.0

LightOn/Off events have been replaced with a toggle event on the PAW to reduce PAW redraw. The events still exist and can be triggered, but are hidden from the PAW.

ModuleLight no longer uses animations to control color and brightness of the lights.Instead this is done by the part module itself.

That is a quote from here.

Also check this for some info.

For pure emissives that don't cast light this module is generally used.

Spoiler

    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_6001409     //#autoLOC_6001409 = Lights On
        eventOffName = #autoLOC_6001408     //#autoLOC_6001408 = 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
        }
    }

And this is generally used to toggle animated lights that cast light,

Spoiler

    MODULE
    {
        name = ModuleAnimateGeneric
        animationName = Commander_lights
        layer = 9
        startEventGUIName = Work Lights ON
        endEventGUIName = Work Lights OFF
        actionGUIName = Toggle Work Lights
        defaultActionGroup = Light
    }

 

Link to comment
Share on other sites

Thanks @ColdJ, @Stone Blue

Well, I got the lights and emissives working with the modules you guys suggested.  But that created an entirely new problem.

My old way of doing lights was to add a point light for each emissive that's slightly offset from the part.  That way, it casts a bit of a glow.  I animated both the emissive and the lights in the same module/action.  By adding both an animate generic and the color changer I now have 2 buttons on the part for turning lights on and off.  So here's where that gets even more screwed up.  I can go on the part module and turn on just the point lights.  So now, the portholes in the picture above has this white light glow effect.  I then toggle all of the vessel lights and the point lights go out and the emissives come on.  If I try to get slick and remove all of the GUI events from the animategeneric in the cfg, it politely reminds me that I forgot and adds a button to the part called 'toggle'.  So either way, I end up with both a button for the emissives and a button for the point lights or I confuse the end user with two 'toggle lights' buttons.

I do have another solution but I'm real hesitant to use it further.  In my Kerbal Electric mod I wrote my own module to handle lights because of some of the limitations of module light.  It still seems to be working and it does handle emissives as well as point lights but I'm thinking it only does one emissive.  I have that in the Kerbal Electric plugin and didn't really want to toss that into my big plugin I use for everything else.

Any other ideas on how to do this without the two buttons?

Thanks guys.

F.

Oh and one other thing that made me go... why?  I couldn't get it to work with animating the light intensity, only the color.

Link to comment
Share on other sites

15 hours ago, Fengist said:

Any other ideas on how to do this without the two buttons?

Not as yet. I am constantly learning new things but haven't got to that yet. I just turn lights on using the U key and that turns it all on at once. If you have turned on a light separately in the UI then just turn it back before hitting them all at once.

Link to comment
Share on other sites

@Fengist

I may have a solution for you, upon studying the new lights from stock that use the new modulelight module. I was able to successfully make a double light where both emissives lit up and both spotlights worked, all from a single toggle. As long as all the emissive surfaces are within a single mesh it seems to work. Separate ones cause my .mu plugin to have an error on re-import. The new system uses 2 meshes, the main body and then the emissive mesh which gets referenced in the module. I will try something more complex and get back to you.

Link to comment
Share on other sites

@Fengist

Ok, I have tried it on a model with multiple windows and it works, you even have the ability to change the colour of both the emissive and your light source in game. All on 1 toggle. So just study the configuration of the dome light and it's .mu model and you will see how to make your portholes all light up.

Link to comment
Share on other sites

Ah.  Well, that answers that question then. Thanks.  I'm pretty sure that at least half of the models I have  with multiple emissives use multiple meshes.  It does explain what I was seeing though.  With the old module lights I could get one emissive to work but not the other 3.

Not sure this late in the game if I wanna go to all the trouble though of re-doing a bunch of meshes.  That or I may study my old light code and see if I can get them to  work that way.  And there is one other solution. That part had 4 emissive portholes.  I may just remove the part entirely since an empty fuel tank and 4 of my stick-on port holes would look exactly the same as the emissives with the lights.  Then again, I may just get the multiple emissive to work and be done.

Thanks again @ColdJ Hope you'll be around for ksp2 stoopid modding questions ;).

Link to comment
Share on other sites

59 minutes ago, Fengist said:

Thanks again @ColdJ Hope you'll be around for ksp2 stoopid modding questions ;).

Someone would have to give me a new computer :)

In the blender environment with the .mu plugin you could just join the separate meshes into one if they combine to less than 10,000 vertices.

Link to comment
Share on other sites

57 minutes ago, ColdJ said:

Someone would have to give me a new computer :)

In the blender environment with the .mu plugin you could just join the separate meshes into one if they combine to less than 10,000 vertices.

Dunno a THING about Blender. Took a look at it a couple times and went what???  I use Wings 3D.  I could likely merge them there but it would be a chore.  And honestly, just for a slight glow effect, I'm not sure anyone keeps their vessels in one piece long enough to notice.

Link to comment
Share on other sites

8 hours ago, Fengist said:

Dunno a THING about Blender. Took a look at it a couple times and went what???  I use Wings 3D.  I could likely merge them there but it would be a chore.  And honestly, just for a slight glow effect, I'm not sure anyone keeps their vessels in one piece long enough to notice.

Actually, you wouldnt even need the Mu plugin to do this in Blender.
But... Seriously, you cant join objects in Wings3D? :O
You cant select the 4 meshes & use "Combine"..??

Edited by Stone Blue
Link to comment
Share on other sites

1 hour ago, Stone Blue said:

Actually, you wouldnt even need the Mu plugin to do this in Blender.
But... Seriously, you cant join objects in Wings3D? :O
You cant select the 4 meshes & use "Combine"..??

Keep in mind, it's been years since I was deep into modelling.  There's likely a way to do it, I just don't remember it offhand.  I've used the free version of autocad to do some 3d printing and I can tell you Wings works nothing like that.  It's more of a point and vector editor.  It does have ways to combine objects by using 'bridge'  but that basically takes 2 polygons and connects the vectors.

Link to comment
Share on other sites

Ok @ColdJ, finally got a little time to play around with these emissives.

1. Your technique doesn't work all the time.  I have a part with 3 point lights and 1 emissive. No matter WHAT I did, I could only get one point light and 0 emissives to work with animateLights.
2. Nothing seems to work now with animating the light intensity of point lights. You have to animate the color. Sooo if you're like me and animated intensity for just about every single part, all of your lights are busted.
3. The module color changer does work for emissives. But here's the problem.  It costs the player nothing to turn the lights on.  Color changer has no way of draining a resource.  For a game buried in realism that kinda seems silly.

This is the part about modding for KSP I always hated.  Every patch they ever came out with modders ended up spending more time un-breaking their mods that they did to create them in the first place.  

Link to comment
Share on other sites

13 hours ago, Fengist said:

Ok @ColdJ, finally got a little time to play around with these emissives.

1. Your technique doesn't work all the time.  I have a part with 3 point lights and 1 emissive. No matter WHAT I did, I could only get one point light and 0 emissives to work with animateLights.
2. Nothing seems to work now with animating the light intensity of point lights. You have to animate the color. Sooo if you're like me and animated intensity for just about every single part, all of your lights are busted.
3. The module color changer does work for emissives. But here's the problem.  It costs the player nothing to turn the lights on.  Color changer has no way of draining a resource.  For a game buried in realism that kinda seems silly.

This is the part about modding for KSP I always hated.  Every patch they ever came out with modders ended up spending more time un-breaking their mods that they did to create them in the first place.  

Did you look at the way the new stock Dome Lights work? I believe that would solve your dilema. Their module combined with the way they set up the mesh.

Link to comment
Share on other sites

12 hours ago, ColdJ said:

Did you look at the way the new stock Dome Lights work? I believe that would solve your dilema. Their module combined with the way they set up the mesh.

The problem isn't getting 1 light and 1 emissive to work.  Lights like that are easy enough as Module Lights will do both the light and the emissive without the module color.  It's when you want multiple lights with emissives.  Module lights requires the exact light name so it won't do 2 lights (like a spot light and a point light). Animate generic won't do the emissive because you can't put the emissive on the animation any more and module color will do the emissive but it won't do the light and it won't consume a resource.  And, if you  try to combine any of the above you get multiple buttons to turn lights on and off.  I have one part that has like 6 animations, 6-8 lights and an emissive.  I simply gave up on trying.

Edited by Fengist
Link to comment
Share on other sites

Yeah... and it *looks* like they *might* have tried to make ModuleColorChanger work with specific &/or multiple materials/meshes, which would help the issue of multiple emissives...

 

//		includedRenderer = NavLight_W
//		excludedRenderer = TailLights
//		useMaterialsList = true
//		materialsNames   = ERS_EmissMat

..BUT... of *course* this part of the module is *very* broken & does not work... :face_palm:

Edited by Stone Blue
Link to comment
Share on other sites

  • 1 month later...
On 4/25/2022 at 3:27 AM, Fengist said:

The problem isn't getting 1 light and 1 emissive to work.  Lights like that are easy enough as Module Lights will do both the light and the emissive without the module color.  It's when you want multiple lights with emissives.  Module lights requires the exact light name so it won't do 2 lights (like a spot light and a point light). Animate generic won't do the emissive because you can't put the emissive on the animation any more and module color will do the emissive but it won't do the light and it won't consume a resource.  And, if you  try to combine any of the above you get multiple buttons to turn lights on and off.  I have one part that has like 6 animations, 6-8 lights and an emissive.  I simply gave up on trying.

I have been happily getting a mix of spotlights and point lights working with multiple sections being lit up with emissives, using the new module. As long as the lights have the same name , but configured  with different properties, and the emissives are all considered part of the same named mesh. Then you can have them all light up with just one toggle in the UI. I use the Squad materials set up as a base, because I don't know how to create the Colour Animation material from scratch. Just duplicate the lights as needed, then go in and change their properties. As for the mesh I just change the material set up to look for my textures. The only time I need to add an extra module is if I put an emissive on a moving animation and so can't join them into a different mesh. It all works well. If you are unwilling to use the .mu plugin and a blender environment then you can PM me if you like and give me a link to download your model, and I will rig it for you. I know a site that does free 1 off per download file hosting if you don't have your own.

Link to comment
Share on other sites

  • 8 months later...

Hi guys!

The thread a bit old but I would try my luck. Doing my small futuristic engines project to use with FTL and  GU mod. My first engine would be multimode engine for atmosheric flights and for vacuum. Basically I need to do emission animation. So what I did.

  1. Used KSP/Emissive/Bumped Specular shader.
  2. Prepared an emission RGB map
  3. Added Animation Component to a root object where were all coliders and needed Part Tools components.
  4. Added animation clip where I manipulate _EmissiveColor parameter thru keyframes.
  5. Added this module into my config.
MODULE
	{
		name = FXModuleAnimateThrottle
		animationName = trustAnimation // This is exactly the animation clip name I use in Unity.
		responseSpeed = 0.001
		dependOnEngineState = True
		dependOnThrottle = True
	}

 And nothing. Not even in SPH inventory. But it was before and I've already tested it. It works fine.

So, what I did wrong? Maybe someone could point me to any up to date documentation? Some guides maybe? Another question I there a way to combine two emissive maps to visualize different glow effects for different modes?
Thanks in advance.

Some image. It's still a placeholder.

uc?id=1wiQRuUe8hI7sm2kJ2qatWwyPUsDVBMOQ

Link to comment
Share on other sites

On 2/20/2023 at 8:07 AM, kremonia said:

So, what I did wrong?

Not my area, but if I understand correctly and this is like the animation to show heat building up on an engine, then try removing the following line from the module. I have noticed that it is only include for physical animation like the afterburner cone narrowing and widening.

dependOnThrottle = True

Also there is no

layer = 2

etc to make sure that other animations do not interfere within the same part.

Edited by ColdJ
Link to comment
Share on other sites

27 minutes ago, ColdJ said:

layer = 2

Thanks for the reply! Could you please point me to the knowledge base or any docs described all that FXModuleAnimateThrottle parameters? Because all I have at the moment is heavily outdated https://wiki.kerbalspaceprogram.com/wiki/Module#FXModuleAnimateThrottle , and there is no description for layer. Is it unity layer system? What actual object or abstraction it corresponds to? Maybe animation layers?
Also I've managed to solve the problem same day with  this

MODULE
	{
		name = ModuleColorChanger
		moduleID = throttleColor
		animRate = 1
		shaderProperty = _EmissiveColor
		includedRenderer = Electric_Hull
		toggleInEditor = false
		toggleInFlight = false
		redCurve
		{
			key = 0 1
			key = 1 1
		}
		greenCurve
		{
			key = 0 1
			key = 1 1
		}
		blueCurve
		{
			key = 0 1
			key = 1 1
		}
		alphaCurve
		{
			key = 0 0
			key = 1 1
		}
	}

It's from ReStock I believe. If someone could teach me about this module would be greate, because hell knows what is the second value in key. I'm assuming the first one is for channel value.

Link to comment
Share on other sites

On 2/23/2023 at 9:19 AM, kremonia said:

Could you please point me to the knowledge base or any docs described all that FXModuleAnimateThrottle parameters?

I think I wrote it somewhere, but would have to go look.

Put simply it only relates to animations that are referenced within the same configuration file. If you have more that one animation on a part then within the configuration file you assign each module that uses one of them a layer. There is no correct layer. They only need to be different from each other. The layer does not relate to the animation layer when you are building it within blender or unity.

It just stops the configuration from mixing the animations into 1 when it runs.

Looking at stock configurations is a good way to get an idea of how things work.

Here is an example out of the stock Ramjet engine.

    MODULE
    {
        name = FXModuleAnimateThrottle
        animationName = TurboRamJetNozzle
        dependOnEngineState = True
        dependOnThrottle = True
        responseSpeed = 1
        layer = 1
    }
    MODULE
    {
        name = FXModuleAnimateThrottle
        animationName = TRJ_Heat
        dependOnEngineState = True
        responseSpeed = 0.0005
        layer = 2
    }

So a physical animation and a colour animation. each assigned a layer so they don't get merged.

Link to comment
Share on other sites

19 hours ago, ColdJ said:

MODULE
    {
        name = FXModuleAnimateThrottle
        animationName = TurboRamJetNozzle
        dependOnEngineState = True
        dependOnThrottle = True
        responseSpeed = 1
        layer = 1
    }
    MODULE
    {
        name = FXModuleAnimateThrottle
        animationName = TRJ_Heat
        dependOnEngineState = True
        responseSpeed = 0.0005
        layer = 2
    }

Just to figure out we are on the same page. So, this layer parameter it's just regarding KSP and how it understands animation layers. So, it independent of my object hierarchy and organization of animation components. I'm assuming that if I have a need in animation for let say material so i just need to put Animation component in unity on an object with renderer component name animation specifically and KSP would search thru the whole hierarchy to find that specific animation clip. Am I right?
So, is there any community documentation at least for native KSP, or every team of moders has its own? Not to bother community.

Link to comment
Share on other sites

On 2/25/2023 at 10:00 AM, kremonia said:

Just to figure out we are on the same page. So, this layer parameter it's just regarding KSP and how it understands animation layers. So, it independent of my object hierarchy and organization of animation components. I'm assuming that if I have a need in animation for let say material so i just need to put Animation component in unity on an object with renderer component name animation specifically and KSP would search thru the whole hierarchy to find that specific animation clip. Am I right?
So, is there any community documentation at least for native KSP, or every team of moders has its own? Not to bother community.

Yes it is just for KSP. It does not relate to the heirachy or layers in your model.

On 2/25/2023 at 10:00 AM, kremonia said:

I'm assuming that if I have a need in animation for let say material so i just need to put Animation component in unity on an object with renderer component name animation specifically and KSP would search thru the whole hierarchy to find that specific animation clip. Am I right?

You are right.

On 2/25/2023 at 10:00 AM, kremonia said:

So, is there any community documentation at least for native KSP, or every team of moders has its own? Not to bother community

You could try to google it. I have found some not very detailed stuff in the past. Mostly I worked stuff out through trial and error.

All my stuff has been done in the Blender environment. There seems to be only outdated stuff about part tools and unity.

I keep hoping that someone who works with those will create an up to date thread for the rest of us.

Link to comment
Share on other sites

13 hours ago, ColdJ said:

All my stuff has been done in the Blender environment. There seems to be only outdated stuff about part tools and unity.

TBH never was successful to export anything thru mu export in blender. Maybe because I'm a long time Maya and Unity user. Not sure if part tools are dramatically outdated, because it is for Unity 2019.4.18f and I believe it was the last Unity version KSP1 build with.  Surely in comparison to the last updates to github by taniwha on 25th of Oct 2022 they may be outdated. But it works fine for me and I'm able to use the shaders from TU to figure out actual look.

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...