Jump to content

Difficulty with Unity/KSP and textures


Recommended Posts

Hello... I am attempting to make a KSP mod. Everything is fine except the texture on my part does not show up. I load the mesh into unity (as a .dae from my 3D program) and apply the KSP Diffuse shader to it, and associate an image with the shader using the little 'select' button on the shader's section of the inspector panel. Depending on what image I use, the part appears either completely black or a dull green. When I run KSP, the part appears white with no texture.

The images I've been adding as assets to unity are 256x256 PNGs created with the GIMP. I am having Part Tools save them as mbm but I also tried saving as PNG and it does not matter. The mbm files appear and my part.cfg is pointing to them, and KSP tries to load them. The log says:


[WRN 21:07:52.629] PartLoader: Cannot replace model texture with 'Kerbalrad/Parts/Kerbalrad2M/textures/test3'

Please advise - thank you for your time.

Link to comment
Share on other sites

Hello! Seeing as you are having some trouble with modding, I would like to try and help you.

You said you load in a .dae mesh from your 3d modelling program, correct? Well, here's the thing, overlaying meshes created in 3d programs are something of the past.

Kerbal space program doesn't use .dae anymore, meaning what you are seeing is likely your overlaying mesh.

To solve this problem, delete the overlaying mesh, go into unity with your part, select your part, and scroll over the tab labelled "Component" at the top of the unity screen and click it. This should show a menu, in the menu there is a tab labelled "Physics". Inside this tab, there will be something labelled "Mesh Collider". With your part selected, click this button once. This should add a component to your part, listed on the side of the page, to your right. It's labelled "Mesh Collider". Open it, if its not already open, and click the button labelled "Convex". This should then highlight your part in green, signalling that your part now has a mesh! Repeat for all parts.

[EDIT] I forgot to mention, that you have to give your part a texture instead of your mesh if that's what you are also doing. Like I said, delete the .dae mesh you made. Also, PNG files should work perfectly fine, considering that is what I used for making some basic parts. And to make sure your part uses the texture made for it, in your part.cfg file, make sure to do this:

PART

{

// Kerbal Space Program - Part Config

// Industrial Rocket Mk-12

//

// --- general parameters ---

name = liquidengine

module = Part

author = Mr.Desmond Tiny

// --- asset parameters ---

mesh = model.mu

scale = 0.1

---------------------------

This is the beginning of one of the part configs for one of my parts, as you can see, the mesh is specified as "model.mu"

Convex means it is a continuous mesh by the way, and your welcome!

Edited by Mr.Desmond Tiny
Link to comment
Share on other sites

Normally you dont need to point a cfg file at a texture, I believe it uses the ones the model file specifies, and the texture lines in a cfg file are to replace the texture stated in the model with another. So the error might be being caused by ksp getting confused trying to replace a texture with itself.

Link to comment
Share on other sites

You certainly do NOT want to make a mesh collider from your main mesh... Unless your main mesh is just a cube, or something extremely simple and already convex... .dae should also import fine into Unity, and that part.cfg isn't what you're trying to use if you're getting that error.

I think you have a compound issue.

You're trying to do a replace with a MODEL {} node and keep all the textures in one folder, correct? Try keeping the part.cfg, model.mu, and any associated .mbm files all in the same folder, just temporarily till you get the rest sorted out. You won't need a texture reference at all then in part.cfg, so comment them out.

What program made this mesh? It could be that it's exporting something screwing into the .dae file, but no idea what may fix that without knowing the program. But try to export the model with no materials, only UV mapped, and see below how to make and apply material in Unity.

Also, in Unity, try getting rid of the material currently on your model completely. Does the model itself show up okay then? If so, make an all new material in Unity, by right clicking assets area and picking it out of the menu. Set your tex to it again, and the KSP shader, then drag and drop it onto the model. Does that help?

Link to comment
Share on other sites

  • 2 years later...

I'm having the same problem. Here's what I have done so far:

- created a cylinder in Blender with 12 vertices and added a texture of colour red (it's for testing purposes)

- imported the blender file in .fbx to the asset folder in Unity along with the texture in .png

- created a new project in Unity (blender file and texture file in the asset folder), imported Part Tools, created a new empty game object

- dropped the fbx file in the game object and dropped the texture on it, not surprisingly I got a red cilinder

- created the mesh and chose KSP diffuse 

- imported the mu file and the texture in tga

- added a .cfg file with roughly the same parameters as a similar sized stock tank and referenced the mu file as 'tank.mu' (which is the actual file name, not 'model')

- after reloading everything, the part appears in the menu white and is invisible when dropped in VAB (attach points can be seen)

 

I've tried to debug it and I could find both the texture and the part, they showed up in Database. I also tried to reload the database, delete the material in re-do it and nothing changed. Any ideas? 

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