Jump to content

KSP 1.8 Part Icon Shaders for custom Shaders


Recommended Posts

@JPLRepo

During the pre-update discussions regarding 1.8, it was brought up that there were issues with the Part Icons for any parts using non-KSP shaders.  IIRC you mentioned that a solution was being developed (or was at least going to be investigated?).

Did anything come out of this?  Is there a way for me to set the icon shader for any specific part/model/mesh?  Or, how could one specify the original shader -> icon shader mappings so that KSP will know to use the proper icon shader?


Notably, KSP 1.8 does not render the part-icons properly for any part using a non-KSP shader.  It looks like the icon defaults to using the KSP/Diffuse equivalent icon shader.

 

Alternatively, is there source available for the icon-shaders anywhere, so that I might develop properly functioning replacements (I haven't d/l the update part tools yet; was it included?)? 


Thanks;

Link to comment
Share on other sites

This didn't make it into 1.8.x. sorry about that.

That said, the materials can be changed for a part with a small piece of code.
The AvailablePart for your part has a reference to the iconPrefab template object.

You could search this for renderers/materials and replace them as you so desire.

EDIT:

Though reading your comment again now, I'm not sure it's understood what you are asking for.

Do you want to be able to specify your own materials to be used instead of the masked 3d objects shaders?
Do you want to be able to map your own shaders to one of the stock masked 3d objects shaders?

 

 

Link to comment
Share on other sites

  • 2 months later...
On 11/13/2019 at 8:59 PM, JPLRepo said:

This didn't make it into 1.8.x. sorry about that.

That said, the materials can be changed for a part with a small piece of code.
The AvailablePart for your part has a reference to the iconPrefab template object.

You could search this for renderers/materials and replace them as you so desire.

EDIT:

Though reading your comment again now, I'm not sure it's understood what you are asking for.

Do you want to be able to specify your own materials to be used instead of the masked 3d objects shaders?
Do you want to be able to map your own shaders to one of the stock masked 3d objects shaders?

 

 

Apologies as I must have completely missed this post when it was made.  Not sure how, as I thought I was keeping an eye on it specifically...

 

Going back through things -- I'm not sure what I'm looking for is even possible without changes to other portions of the loading code.

The end goal is to allow for custom shaders to be used on parts (non- KSP/ shaders; e.g. the PBR-Metallic shaders from TexturesUnlimited).  These custom shaders will generally also require a customized icon-shader to maintain equivalent functionality.

The first problem is that you cannot export parts using custom shaders through PartTools; the PartLoader code will throw an exception during KSP loading due to an unrecognized shader (the list of supported shaders appears to be hard-coded somewhere?). 

The second issue (and the reason for the original post) is that it appears that the current mapping of shader -> icon-shader is hard-coded somewhere in the part-loading routines;  I cannot find any publicly accessible dictionaries/maps/registry methods that would allow for me to add a mapping.

However, the second issue cannot be addressed until the first is made possible (i.e. loading of Parts with non KSP/ shaders).  This, by itself, doesn't seem to hard; add in a method to load the shaders from AssetBundles, add into the internal shader reference stores, and anywhere that Shader.Find() is currently used, replace with a method that first looks in the loaded shader cache (as shaders loaded from AssetBundles will never be visible to the Shader.FInd() method; that method only finds shaders that were compiled with the project at build-time).  I don't have access to the PartTools/PartExporter code, but might be some minor modifications needed there depending upon how the shader is stored in the .mu file (is it written as an int, is the name written as a string, etc).

 

In the meantime I've worked around this much as you propose above -- manually going through the game database, brute-force iterating through all transforms/renderers for all loaded parts, finding those that use one of the 'to be replaced' part shaders, and then manually replacing the icon-shaders in the materials for that part's icon prefab based on some config provided mappings.  Its ugly, its hacky, but it seems to (mostly) work.

 

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