Jump to content

Need a tiny bit of help getting started


Recommended Posts

I'm beginning to play around with custom parts, and I have been all over the forums trying to learn what I can, but I have not run into an explanation of a particular thing that is confusing me, and I'm having trouble turning it into a simple question that I can google.

I'm not messing about with actual 3d modelling at this point, but am just starting with using existing part models and textures, or modding existing parts. I'm getting the hang of making config files for mod manager, and all of that. Everything is working fine for me in terms of functionality, like adding, removing, or modifying modules. But I am confused about textures and meshes.

I get that I can specify a different texture for a part. In another thread, @nli2work gave the following example:

MODEL
{
      model = path/to/your/model
      texture = texture_toBeReplaced, Squad/Parts/model/texture  

}

 

I've seen a lot of examples of this. I've poked around in things like SXT, and seen the same simple specification of a texture, like:

    model = SXT/Parts/StationsBases/Hull/ServiceMod1/fuelSmall

    texture = model000 , Squad/Parts/Command/cupola/ksp_l_cupola_diff

 

What I don't get is this; Where is that first argument for the texture definition coming from? If I'm doing this myself, how do I know that texture_toBeReplaced should be "model000" or whatever? In case I'm being unhelpful in terms of how I ask the question, how about an example. Say I want to retexture the squad small fuel tank. I can open it's .cfg to see the model name, which matches what I see in the directory for the part. I can see that the directory also contains tank3.dds, and tank3_n.dds, which are obviously the texture and normal map. I get that. But I don't see those dds files being referenced ANYWHERE in fuelTankT200.cfg... so I'm not clear how that texture is associated with the part, nor am I sure what I am supposed to use as the texture name if I want to specify a different texture.

In other words, if I want to retexture the tank, I need to use:

MODEL

{

      model = Squad\Parts\FuelTank\fuelTankT200
      texture = ????, myparts/whatever/texture.png

}

I'd really appreciate a pointer in the right direction.

Link to comment
Share on other sites

That information is stored in the .mu file. When you export your model via Unity+Part tools, the .mu file it creates contains the 3d model and tells the game what textures it uses for what.

Generally you can tell what texture is what just by looking at it in the part directory. If the main texture for the fuel tank is called tank3.dds, then you would use:

texture = tank3, myparts/whatever/texture

If you want to look at more examples, download my VX series II and look at the Sigma and Omicron engine configs.

Edited by Randazzo
Link to comment
Share on other sites

1 minute ago, Randazzo said:

That information is stored in the .mu file. When you export your model via Unity+Part tools, the .mu file it creates contains the 3d model and tells the game what textures it uses for what.

Generally you can tell what texture is what just by looking at it. If the main texture for the fuel tank is called model000, then you would use:


texture = model000, myparts/whatever/texturenamewithoutextension

 

Ah, okay. So even if I'm not doing any editing of the 3d model itself, I still need to use Unity and Part Tools to dig up that information. Gotcha. Will that also help me troubleshoot texture alignment, or will I need additional software like Maya for that? When I have managed to replace a texture successfully, even if I am just replacing it with a slightly recoloured version of the original texture, in game it is completely misaligned relative to the model.

Link to comment
Share on other sites

2 minutes ago, Tokamak said:

Ah, okay. So even if I'm not doing any editing of the 3d model itself, I still need to use Unity and Part Tools to dig up that information. Gotcha. Will that also help me troubleshoot texture alignment, or will I need additional software like Maya for that? When I have managed to replace a texture successfully, even if I am just replacing it with a slightly recoloured version of the original texture, in game it is completely misaligned relative to the model.

Well, you don't really need Unity and part tools unless you're completely reskinning the model. You can find out what the texture names are literally just by looking at them in the directory.

It can be helpful to have the UV map, but really you can just align your new texture with the old one. It is important to note that DDS images are flipped vertically. So if you're using one as a guide, flip it vertically first, then align your new texture to it.

Edited by Randazzo
Link to comment
Share on other sites

1 minute ago, Randazzo said:

Well, you don't really need Unity and part tools unless you're completely reskinning the model. You can find out what the texture names are literally just by looking at them in the directory.

It can be helpful to have the UV map, but really you can just align your new texture with the old one. It is important to note that DDS images are flipped vertically. So if you're using one as a guide, flip it vertically first, then align your new texture to it.

Oh... so the name of the texture is just the file name? I thought that the name was an internal label that the model was using.

Also... DDS images are flipped vertically? That would explain a lot! I haven't been able to find a good guide to this sort of thing that isn't problematically out of date, and mostly expects part textures to be png files. I guess the next step is to go and find a dds converter that works.

Thanks!

Link to comment
Share on other sites

19 minutes ago, Tokamak said:

Oh... so the name of the texture is just the file name? I thought that the name was an internal label that the model was using.

Also... DDS images are flipped vertically? That would explain a lot! I haven't been able to find a good guide to this sort of thing that isn't problematically out of date, and mostly expects part textures to be png files. I guess the next step is to go and find a dds converter that works.

Thanks!

I would suggest DDS4KSP to convert your png to dds format. For opening dds files, I personally use GIMP with a plugin specifically for that purpose.

I'm on my phone atm or I would provide links, but I think google should be able to find it all.

Link to comment
Share on other sites

1 hour ago, Randazzo said:

I would suggest DDS4KSP to convert your png to dds format. For opening dds files, I personally use GIMP with a plugin specifically for that purpose.

I'm on my phone atm or I would provide links, but I think google should be able to find it all.

Awesome. I will google that. Thanks!

Link to comment
Share on other sites

Hmm. I'm still apparently doing something wrong. I'm just trying to apply a new texture to one of porkjet's inflatable habitats. The .cfg file for the part does actually not specify the texture anywhere in it, but the part's directory contains inflato1.dds and inflato1_NRM.dds, so it's clear that those are the texture files. I have created my own mm cfg file in a new "TokamakIndustries" directory in gamedata for my flailing attempt at modding, and I have my new inflato1.png texture file in that folder. For testing purposes I just took the original texture and made it bright pink, so it would be easy to spot the change.

 The following is in my new .cfg file:

@PART[inflato1]:NEEDS[UsiLifeSupport]
{
    @description ^= :$: Hello Kerbal
    @MODEL
    {
        texture = inflato1, TomakakIndustries/inflato1
    }
}

The UsiLifeSupport reference is because this project started by trying to make some parts USI-LS compatible.

I know that my patch is being loaded, because "Hello Kerbal" is added to the description of the part when I look at it in game in the VAB, but the texture that the part has is the original one.

I think I'm missing something.

Link to comment
Share on other sites

56 minutes ago, Tokamak said:

Hmm. I'm still apparently doing something wrong. I'm just trying to apply a new texture to one of porkjet's inflatable habitats. The .cfg file for the part does actually not specify the texture anywhere in it, but the part's directory contains inflato1.dds and inflato1_NRM.dds, so it's clear that those are the texture files. I have created my own mm cfg file in a new "TokamakIndustries" directory in gamedata for my flailing attempt at modding, and I have my new inflato1.png texture file in that folder. For testing purposes I just took the original texture and made it bright pink, so it would be easy to spot the change.

 The following is in my new .cfg file:

@PART[inflato1]:NEEDS[UsiLifeSupport]
{
    @description ^= :$: Hello Kerbal
    @MODEL
    {
        texture = inflato1, TomakakIndustries/inflato1
    }
}

The UsiLifeSupport reference is because this project started by trying to make some parts USI-LS compatible.

I know that my patch is being loaded, because "Hello Kerbal" is added to the description of the part when I look at it in game in the VAB, but the texture that the part has is the original one.

I think I'm missing something.

In this particular case, the problem (or at least part of it) is that the part config doesn't use the model node, it uses the old

mesh = model.mu

First, you would need to delete that with your MM config and then give it a complete model node. I'm rusty with MM but I think this should do it:

@PART[inflato1]:NEEDS[UsiLifeSupport]
    {
        !mesh = DELETE
        MODEL
        {
            model = HabitatPack/Parts/inflato1/model
            texture = inflato1 , TomakakIndustries/inflato1
            scale = 1,1,1
        }
    }

I'm not sure about some of those operators you're using, it looks like you might be learning from Ven's stuff which is akin to sorcery.

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Thank you for the help! I've made a lot of progress, but I've run into another snag.

I'm trying to make alternate versions of a parts, in this case I'm again using a couple of the porkjet inflatable habitats. I'm not even at the point of making major changes, I'm just trying to be able to make a copy of a part so I can make alternate versions without paving over the original versions.

PART:NEEDS[HabitatPack]
{
	name = tokamakinflato1
	module = Part
	author = Porkjet (model), Sirkut (Habitat plugin), Tokamak (alternate USI version)

	{
		model = HabitatPack/Parts/inflato1/model
		scale = 1,1,1
		texture = inflato1, HabitatPack/Parts/inflato1/inflato1

	}

	node_stack_top = 0.0, 3.5, 0.0, 0.0, 1.0, 0.0, 2
	node_stack_bottom = 0.0, -2.5, 0.0, 0.0, -1.0, 0.0, 2



	CrewCapacity = 0

	TechRequired = nanolathing
	entryCost = 10000
	cost = 10000
	category = Utility
	subcategory = 0
	title = P.E.R.M PA550 Block II
	manufacturer = Tokamak Industries
	description =  The Porkjet Expandable Recreation Module is a modification of the basic PA550 habitat which has been optimized for Kerbonaut recreation and relaxation. As such it does not provide any additional berths for long term habitation, but it should make Kerbals more tolerant of living in a tin can or giant space balloon, enabling longer stays in space before the onset of space madness and general grumpiness. The hydroponics garden is not able to produce any food, but contributes somewhat to overall life-support recycling. Note: warranty void if inflated.
	attachRules = 1,1,1,0,0

	mass = 4
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.3
	angularDrag = 2
	crashTolerance = 20
	breakingForce = 500
	breakingTorque = 500
	maxTemp = 2900

	stagingIcon = COMMAND_POD
	vesselType = Ship

	INTERNAL
	{
	  name = inflato1internal
	}
	.... snipped out the modules as they are not relevant here
}


PART:NEEDS[HabitatPack]
{
	name = tokamakinflato2
	module = Part
	author = Porkjet (model), Sirkut (Habitat plugin), Tokamak (alternate USI version)
	MODEL
	{
		model = HabitatPack/Parts/inflato2/model
		scale = 1,1,1
		texture = inflato2, HabitatPack/Parts/inflato2/Inflato2
	}
	node_stack_top = 0.0, 2.7, 0.0, 0.0, 1.0, 0.0, 1
	node_stack_bottom = 0.0, -1.9, 0.0, 0.0, -1.0, 0.0, 1



	CrewCapacity = 0

	TechRequired = composites
	entryCost = 5000
	cost = 5000
	category = Utility
	subcategory = 0
	title = P.E.R.M PA330 Block II
	manufacturer = Tokamak Industries
	description = 
	attachRules = 1,1,1,0,0
	
	description =  The Porkjet Expandable Recreation Module is a modification of the basic PA330 habitat which has been optimized for Kerbonaut recreation and relaxation. As such it does not provide any additional berths for long term habitation, but it should make Kerbals more tolerant of living in a tin can or giant space balloon, enabling longer stays in space before the onset of space madness and general grumpiness. Note: warranty void if inflated.

	mass = 2.5
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.3
	angularDrag = 2
	crashTolerance = 15
	breakingForce = 500
	breakingTorque = 500
	maxTemp = 2900

	stagingIcon = COMMAND_POD
	vesselType = Ship

	INTERNAL
	{
	  name = inflato2internal
	}
	.... snipped out the modules as they are not relevant here
}

Everything is just copypasta from the original part, with the exception of the MODEL definition, which is updated as per earlier in this thread. So here's the thing... KSP handles the new inflato2 with no problem, and chokes on inflato1, and I cannot for the life of me figure out why. 

The output log says:

PartLoader: Compiling Part 'TokamakIndustries/MiscTweaks/tokamakinflato1'
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

PartCompiler: Cannot clone model from 'TokamakIndustries' directory as model does not exist
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

PartCompiler: Cannot compile model
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

PartCompiler: Cannot compile part
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

PartLoader: Compiling Part 'TokamakIndustries/MiscTweaks/tokamakinflato2'
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

 

I cannot see how inflato2 is loading and inflato1 produces "model does not exist"

GameData\HabitatPack\Parts\inflato1\model.mu and GameData\HabitatPack\Parts\inflato2\model.mu both exist. As for the textures, the reason why Inflato2 is capitalized and inflato1 is not is because that is how the files are named in the porkjet habitat pack directory, so that's not an error.

So what is different between the two parts, such that KSP can find the model for one and not the other. 

What am I doing wrong?

 

Just for ease of comparison, here are both model definitions shown together:

 

	MODEL
	{
		model = HabitatPack/Parts/inflato1/model
		scale = 1,1,1
		texture = inflato1, HabitatPack/Parts/inflato1/inflato1
	}

and...

	MODEL
	{
		model = HabitatPack/Parts/inflato2/model
		scale = 1,1,1
		texture = inflato2, HabitatPack/Parts/inflato2/Inflato2
	}

The second works, the first one doesn't. So confused...

Link to comment
Share on other sites

PART:NEEDS[HabitatPack] won't do you any good, as you are not referencing a specific part with that line.

The line needs to be @PART[partname]:NEEDS[HabitatPack] and then you can fill in whatever you need in curly brackets underneath.

 

Link to comment
Share on other sites

1 hour ago, liquidhype said:

PART:NEEDS[HabitatPack] won't do you any good, as you are not referencing a specific part with that line.

The line needs to be @PART[partname]:NEEDS[HabitatPack] and then you can fill in whatever you need in curly brackets underneath.

 

Ah, good to know, thanks. That leaves the main question unanswered, though. 

Link to comment
Share on other sites

@Tokamak The broken one is missing a very important "MODEL".

This is what you have:
 

name = tokamakinflato1
    module = Part
    author = Porkjet (model), Sirkut (Habitat plugin), Tokamak (alternate USI version)

    {
        model = HabitatPack/Parts/inflato1/model
        scale = 1,1,1
        texture = inflato1, HabitatPack/Parts/inflato1/inflato1

    }

This is what you need:
 

Quote

 

    name = tokamakinflato1
    module = Part
    author = Porkjet (model), Sirkut (Habitat plugin), Tokamak (alternate USI version)

    MODEL      // this is the key difference
    {
        model = HabitatPack/Parts/inflato1/model
        scale = 1,1,1
        texture = inflato1, HabitatPack/Parts/inflato1/inflato1

    }

 

Your inflato2 is not missing that line, and thus is loading properly.

This is of course assuming you copy-pasted your configs. I see you have it on the comparison you put up.

Edited by Randazzo
Link to comment
Share on other sites

44 minutes ago, Randazzo said:

@Tokamak The broken one is missing a very important "MODEL".

This is what you have:
 


name = tokamakinflato1
    module = Part
    author = Porkjet (model), Sirkut (Habitat plugin), Tokamak (alternate USI version)

    {
        model = HabitatPack/Parts/inflato1/model
        scale = 1,1,1
        texture = inflato1, HabitatPack/Parts/inflato1/inflato1

    }

This is what you need:
 

Your inflato2 is not missing that line, and thus is loading properly.

This is of course assuming you copy-pasted your configs. I see you have it on the comparison you put up.

Oh god... how did I miss that? XD Thanks!

Link to comment
Share on other sites

On 7/30/2016 at 10:30 AM, liquidhype said:

PART:NEEDS[HabitatPack] won't do you any good, as you are not referencing a specific part with that line.

The line needs to be @PART[partname]:NEEDS[HabitatPack] and then you can fill in whatever you need in curly brackets underneath.

 

 

On 7/30/2016 at 0:04 PM, Tokamak said:

Ah, good to know, thanks. That leaves the main question unanswered, though. 

 

The "@PART[partname]" is for modifying an existing part, but this is all about a new part. I've never tried using MM "NEEDS" conditions on a straight add like that, but it should work. Also doable, is to copy an existing part, like:

+PART[oldPartName]:NEEDS[something]
{
    name = newPartName
    // and whatever other changes are needed can follow here
}

 

Link to comment
Share on other sites

Thanks for the help! I'm making progress. 

I'm continuing to mess with textures, using the porkjet hab as my test case. I played a lot with skinning in the old days (Descent, Oblivion, et cetera) so I THOUGHT I knew the basics I'd need here, but apparently I am missing something. I've been wading through various tutorials and guides, but most of them are out of date and they do not deal with the problem that I'm having.

I do understand how the flat UV textures are mapped onto the 3d models, not entirely unlike papercraft, and I get in principle what normal maps an AO maps are. I can edit textures so that things are in the right place, but transparency is confusing me.

When I open the habitat texture in GIMP, I see that it is almost entirely transparent, and the same is true for a lot of the official squad textures. But other textures (from Squad, and modders) are opaque like you'd normally expect. I can also see that a lot of the dark bits on the actual part in game (like the rib lines, and the dark gray cap) are not matched by any dark portions in the UV texture.

Is this because parts of the actual mesh are given a base colour that the semitransparant texture is being applied to? The parts of the texture where I would expect dark colours to be are just transparent and empty.

If that is the case, that still doesn't fully explain what is going wrong. So, I'm just trying to apply a slight tint to the texture for now. In the example here, I just edited the colour curves slightly, but I've also had the same problematic result when adding a mostly transparent layer of colour.

The texture files are the same except for the tint

 

gimp_by_maekern-dacdc75.png

But in game, the part DOES show the tint... and has large areas of black.

screenshot11_by_maekern-dacdc97.png

 

Clearly I am missing something important, but I'm not sure what I'm missing, or what specific thing to search for. Could somebody point me in the right direction, perhaps?

Link to comment
Share on other sites

2 minutes ago, Stone Blue said:

Layers & Alpha Channels:  Another Voodoo-Magical Aspect of Texturing

I was at least hoping I wouldn't need to use deep magic just to slightly change a colour :P

Link to comment
Share on other sites

8 minutes ago, Tokamak said:

I was at least hoping I wouldn't need to use deep magic just to slightly change a colour :P

It's not too complicated.

  1. On your texture layer, create a new layer mask (right click on it in the 'Layers -Gradients' window in GIMP) and select "Transfer Layer's Alpha Channel".
  2. Right click on the layer mask and click "Disable Layer Mask"
  3. Click once on the texture layer to ensure you are not editing the mask. Change what you wish to change.
  4. Right click again on the layer mask and click "Apply Layer Mask"

Textures with transparency like this are specular textures. The transparencies allow you to define what parts are shiny (and by how much) and what parts are dull.

Diffuse textures are the ones with no alpha channel and are generally not shiny.

P.S. - If you do anything with multiple layers and then flatten them on to the existing texture, it's going to erase the layer mask. If you want to preserve the existing alpha channel:

  • Do step 1 above.
  • Click once on the layer mask to select it, then press ctrl+a (select all), then ctrl+c (to copy it)
  • Create a new transparent layer.
  • Paste the layer mask to this layer, then make it invisible so you can work on the texture.
  • Do your thing. Merge visible layers when done. This will remove the layer mask from the original image.
  • On the combined texture layer, add a layer mask and select "White (Full Opacity)"
  • Make the layer you transferred the alpha channel to earlier visible. Select it, select all, copy it. Paste it into the layer mask on the texture layer. You should now have the original alpha channel restored. Delete the extra layer.

Ok, maybe it's a little complicated. There's probably a better way to do it, but that works for me.

Link to comment
Share on other sites

3 minutes ago, Randazzo said:

It's not too complicated.

  1. On your texture layer, create a new layer mask (right click on it in the 'Layers -Gradients' window in GIMP) and select "Transfer Layer's Alpha Channel".
  2. Right click on the layer mask and click "Disable Layer Mask"
  3. Click once on the texture layer to ensure you are not editing the mask. Change what you wish to change.
  4. Right click again on the layer mask and click "Apply Layer Mask"

Textures with transparency like this are specular textures. The transparencies allow you to define what parts are shiny (and by how much) and what parts are dull.

Diffuse textures are the ones with no alpha channel and are generally not shiny.

P.S. - If you do anything with multiple layers and then flatten them on to the existing texture, it's going to erase the layer mask. If you want to preserve the existing alpha channel:

  • Do step 1 above.
  • Click once on the layer mask to select it, then press ctrl+a (select all), then ctrl+c (to copy it)
  • Create a new transparent layer.
  • Paste the layer mask to this layer, then make it invisible so you can work on the texture.
  • Do your thing. Merge visible layers when done. This will remove the layer mask from the original image.
  • On the combined texture layer, add a layer mask and select "White (Full Opacity)"
  • Make the layer you transferred the alpha channel to earlier visible. Select it, select all, copy it. Paste it into the layer mask on the texture layer. You should now have the original alpha channel restored. Delete the extra layer.

Ok, maybe it's a little complicated. There's probably a better way to do it, but that works for me.

Hrmm, okay. I will try that. Thank you for the very precise instructions. :) I believe I understand about using the alpha channel for reflectivity instead of transparency, but I am still a bit confused as to what is going wrong with the super simple texture changer above. In the case of the porkjet habitat, are the dark colours that we see in game on the seams and cap defined on the mesh itself? Where are they coming from? Is that just the result of having low shininess? 

Link to comment
Share on other sites

3 minutes ago, Tokamak said:

Hrmm, okay. I will try that. Thank you for the very precise instructions. :) I believe I understand about using the alpha channel for reflectivity instead of transparency, but I am still a bit confused as to what is going wrong with the super simple texture changer above. In the case of the porkjet habitat, are the dark colours that we see in game on the seams and cap defined on the mesh itself? Where are they coming from? Is that just the result of having low shininess? 

I don't know how it works well enough to explain why it happens, but if you make a change to a texture with transparency like that without moving the transparency into the alpha channel, it will break.

Link to comment
Share on other sites

4 minutes ago, Stone Blue said:

Are you using Blender?... i know Blender has buttons to flip thru the alpha/RGB channels....

In this case, since all I have is the MU files, I'm just using gimp to edit the texture itself. No 3d editing involved.

Link to comment
Share on other sites

2 minutes ago, Randazzo said:

I don't know how it works well enough to explain why it happens, but if you make a change to a texture with transparency like that without moving the transparency into the alpha channel, it will break.

Hence... Where the voodoo-magical-mystical-auras of Keinstein's Postulate of Photons and Energy Kuanta manifest themselves... :P

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