Jump to content

[1.9.x] Textures Unlimited - PBR-Shader, Texture Set, and Model Loading API


Shadowmage

Recommended Posts

Shadowmage,  how do I apply shader without color change ?

For example, The boby of model was white and after I applyed shader the color changed on gray.

I tryed to set color for it but the shader stopped working.

And I can not understand how SSTU/Masked shader work.

 

Edited by alexus
Link to comment
Share on other sites

8 hours ago, Shadowmage said:

By using Blender ( https://www.blender.org/download/ ), and the .mu import plugin made by Taniwha  ( https://github.com/taniwha/io_object_mu ).

That is the only way that I know of.  .mu files are a proprietary KSP model format, and you won't likely find support in any other software.

Edit:  While not to the same extent as viewing the models in Blender... Sarbian's DebugStuff mod will allow you to view model hierarchy and meshes from within KSP --

 

I can not install plugin. help please

Link to comment
Share on other sites

Just wanted to share this here.

My MK1-3 Command Pod texture overhaul is done! All textures are made from scratch. Because the original diffuse is too "paint-like" to be used in PBR in my opinion. 

Textures: Diffuse, Metal_Gloss and Normals. i forgot to make a glow texture but that'll be easy to add later

MOAR PICS HERE: https://imgur.com/a/xVL0GlE

Spoiler

nc8ElWI.png

 
Edited by ensou04
Link to comment
Share on other sites

6 hours ago, alexus said:

Shadowmage,  how do I apply shader without color change ?

For example, The boby of model was white and after I applyed shader the color changed on gray.

Shader does not change the color.  What you are likely seeing is the change in shading.  Notably, most things will appear closer to neutral color when using PBR, but will also change based on lighting.

6 hours ago, alexus said:

And I can not understand how SSTU/Masked shader work.

Good luck :) Nobody else has used it properly either.  Examples for all of it are here:   https://github.com/shadowmage45/SSTULabs

Basically -- make your diffuse/spec/metal textures flat gray (127,127,127), use a mask texture to specify portions that the user can recolor, and the users' selected color in the GUI will replace they gray in the diff/spec/met.

5 hours ago, alexus said:

I can not install plugin. help please

Sorry, I do not offer tech support for Blender.

Link to comment
Share on other sites

9 hours ago, alexus said:

If the mesh has two textures how do I do?

The same way if it only has one texture...

KSP does not support multiple materials, so if a mesh has multiple textures on it, they are used in different slots.  Put them in the corresponding slots in the config.

Link to comment
Share on other sites

9 minutes ago, alexus said:

What is slots?

Texture slots.  You know -- the things you plug textures into in the Unity Editor.  There is one for Diffuse, one for Specular, one for Normal, etc, yadda.

The configs have slots for textures as well, denoted by 'texture = <SlotName>,<TextureName>'

 

 

Link to comment
Share on other sites

9 minutes ago, alexus said:

model = Squad/Spaces/Mk1-3/model

Is has one mesh and 2 textures .

1.) You are referring to an IVA
2.) Texture != Material.  Model != Mesh.
3.) No, it doesn't have one mesh with multiple textures.  It has one MODEL (XXXXXX.mu), that has MULTIPLE meshes inside of it, that each have multiple textures.
4.) You need to find the mesh-names and target them in your patch specifically.

Here is the model mesh hierarchy for that model.  Find which mesh each texture targets in the existing model, and patch it accordingly.

[LOG 09:49:09.157] [DebugStuff] +S2000 T:Untagged L:0 (Default)
|   Transform - S2000
|   Part - S2000
|   Highlighter - S2000
|   ModuleControlSurface - S2000
|   KSPTextureSwitch - S2000
|   AudioSource - S2000
|   Rigidbody - S2000
| 
 --+model T:Untagged L:0 (Default)
   |   Transform - model
   | 
   |--+Squad/Spaces/Mk1-3/model(Clone) T:Untagged L:0 (Default)
   |  |   Transform - Squad/Spaces/Mk1-3/model(Clone)
   |  | 
   |   --+rotation T:Untagged L:0 (Default)
   |     |   Transform - rotation
   |     | 
   |     |---Mk1_3_IvaShell T:Untagged L:0 (Default)
   |     |      Transform - Mk1_3_IvaShell
   |     |      MeshFilter - Mk1_3_IvaShell
   |     |      MeshRenderer - Mk1_3_IvaShell
   |     |    
   |     |---Mk1_3_IvaProps T:Untagged L:0 (Default)
   |     |      Transform - Mk1_3_IvaProps
   |     |      MeshFilter - Mk1_3_IvaProps
   |     |      MeshRenderer - Mk1_3_IvaProps
   |     |    
   |     |---Mk1_3_IvaMask T:Untagged L:0 (Default)
   |     |      Transform - Mk1_3_IvaMask
   |     |      MeshFilter - Mk1_3_IvaMask
   |     |      MeshRenderer - Mk1_3_IvaMask
   |     |    
   |     |---pilotCamera_01 T:Untagged L:0 (Default)
   |     |      Transform - pilotCamera_01
   |     |      Camera - pilotCamera_01
   |     |    
   |     |---pilotSeat_01 T:Untagged L:0 (Default)
   |     |      Transform - pilotSeat_01
   |     |    
   |     |--+pilot seat_01 T:Untagged L:0 (Default)
   |     |  |   Transform - pilot seat_01
   |     |  | 
   |     |   --+seat T:Untagged L:0 (Default)
   |     |     |   Transform - seat
   |     |     | 
   |     |     |---Cylinder007 T:Untagged L:0 (Default)
   |     |     |      Transform - Cylinder007
   |     |     |      MeshFilter - Cylinder007
   |     |     |      MeshRenderer - Cylinder007
   |     |     |    
   |     |     |---Left Arm Mount T:Untagged L:0 (Default)
   |     |     |      Transform - Left Arm Mount
   |     |     |      MeshFilter - Left Arm Mount
   |     |     |      MeshRenderer - Left Arm Mount
   |     |     |    
   |     |     |---Left Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Left Rudder 2
   |     |     |      MeshFilter - Left Rudder 2
   |     |     |      MeshRenderer - Left Rudder 2
   |     |     |    
   |     |     |---Right  Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Right  Rudder 2
   |     |     |      MeshFilter - Right  Rudder 2
   |     |     |      MeshRenderer - Right  Rudder 2
   |     |     |    
   |     |     |---Right Arm mount T:Untagged L:0 (Default)
   |     |     |      Transform - Right Arm mount
   |     |     |      MeshFilter - Right Arm mount
   |     |     |      MeshRenderer - Right Arm mount
   |     |     |    
   |     |     |---Rudder Anchor T:Untagged L:0 (Default)
   |     |     |      Transform - Rudder Anchor
   |     |     |      MeshFilter - Rudder Anchor
   |     |     |      MeshRenderer - Rudder Anchor
   |     |     |    
   |     |     |---Seat002 T:Untagged L:0 (Default)
   |     |     |      Transform - Seat002
   |     |     |      MeshFilter - Seat002
   |     |     |      MeshRenderer - Seat002
   |     |     |    
   |     |      ---Stick002 T:Untagged L:0 (Default)
   |     |            Transform - Stick002
   |     |            MeshFilter - Stick002
   |     |            MeshRenderer - Stick002
   |     |          
   |     |---pilotSeat_02 T:Untagged L:0 (Default)
   |     |      Transform - pilotSeat_02
   |     |    
   |     |---pilotCamera_02 T:Untagged L:0 (Default)
   |     |      Transform - pilotCamera_02
   |     |      Camera - pilotCamera_02
   |     |    
   |     |--+pilot seat_02 T:Untagged L:0 (Default)
   |     |  |   Transform - pilot seat_02
   |     |  | 
   |     |   --+seat T:Untagged L:0 (Default)
   |     |     |   Transform - seat
   |     |     | 
   |     |     |---Cylinder007 T:Untagged L:0 (Default)
   |     |     |      Transform - Cylinder007
   |     |     |      MeshFilter - Cylinder007
   |     |     |      MeshRenderer - Cylinder007
   |     |     |    
   |     |     |---Left Arm Mount T:Untagged L:0 (Default)
   |     |     |      Transform - Left Arm Mount
   |     |     |      MeshFilter - Left Arm Mount
   |     |     |      MeshRenderer - Left Arm Mount
   |     |     |    
   |     |     |---Left Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Left Rudder 2
   |     |     |      MeshFilter - Left Rudder 2
   |     |     |      MeshRenderer - Left Rudder 2
   |     |     |    
   |     |     |---Right  Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Right  Rudder 2
   |     |     |      MeshFilter - Right  Rudder 2
   |     |     |      MeshRenderer - Right  Rudder 2
   |     |     |    
   |     |     |---Right Arm mount T:Untagged L:0 (Default)
   |     |     |      Transform - Right Arm mount
   |     |     |      MeshFilter - Right Arm mount
   |     |     |      MeshRenderer - Right Arm mount
   |     |     |    
   |     |     |---Rudder Anchor T:Untagged L:0 (Default)
   |     |     |      Transform - Rudder Anchor
   |     |     |      MeshFilter - Rudder Anchor
   |     |     |      MeshRenderer - Rudder Anchor
   |     |     |    
   |     |     |---Seat002 T:Untagged L:0 (Default)
   |     |     |      Transform - Seat002
   |     |     |      MeshFilter - Seat002
   |     |     |      MeshRenderer - Seat002
   |     |     |    
   |     |      ---Stick002 T:Untagged L:0 (Default)
   |     |            Transform - Stick002
   |     |            MeshFilter - Stick002
   |     |            MeshRenderer - Stick002
   |     |          
   |     |---pilotSeat_03 T:Untagged L:0 (Default)
   |     |      Transform - pilotSeat_03
   |     |    
   |     |---pilotCamera_03 T:Untagged L:0 (Default)
   |     |      Transform - pilotCamera_03
   |     |      Camera - pilotCamera_03
   |     |    
   |     |--+pilot seat_03 T:Untagged L:0 (Default)
   |     |  |   Transform - pilot seat_03
   |     |  | 
   |     |   --+seat T:Untagged L:0 (Default)
   |     |     |   Transform - seat
   |     |     | 
   |     |     |---Cylinder007 T:Untagged L:0 (Default)
   |     |     |      Transform - Cylinder007
   |     |     |      MeshFilter - Cylinder007
   |     |     |      MeshRenderer - Cylinder007
   |     |     |    
   |     |     |---Left Arm Mount T:Untagged L:0 (Default)
   |     |     |      Transform - Left Arm Mount
   |     |     |      MeshFilter - Left Arm Mount
   |     |     |      MeshRenderer - Left Arm Mount
   |     |     |    
   |     |     |---Left Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Left Rudder 2
   |     |     |      MeshFilter - Left Rudder 2
   |     |     |      MeshRenderer - Left Rudder 2
   |     |     |    
   |     |     |---Right  Rudder 2 T:Untagged L:0 (Default)
   |     |     |      Transform - Right  Rudder 2
   |     |     |      MeshFilter - Right  Rudder 2
   |     |     |      MeshRenderer - Right  Rudder 2
   |     |     |    
   |     |     |---Right Arm mount T:Untagged L:0 (Default)
   |     |     |      Transform - Right Arm mount
   |     |     |      MeshFilter - Right Arm mount
   |     |     |      MeshRenderer - Right Arm mount
   |     |     |    
   |     |     |---Rudder Anchor T:Untagged L:0 (Default)
   |     |     |      Transform - Rudder Anchor
   |     |     |      MeshFilter - Rudder Anchor
   |     |     |      MeshRenderer - Rudder Anchor
   |     |     |    
   |     |     |---Seat002 T:Untagged L:0 (Default)
   |     |     |      Transform - Seat002
   |     |     |      MeshFilter - Seat002
   |     |     |      MeshRenderer - Seat002
   |     |     |    
   |     |      ---Stick002 T:Untagged L:0 (Default)
   |     |            Transform - Stick002
   |     |            MeshFilter - Stick002
   |     |            MeshRenderer - Stick002
   |     |          
   |     |---light_1 T:Untagged L:0 (Default)
   |     |      Transform - light_1
   |     |      Light - light_1
   |     |    
   |     |---light_hatch T:Untagged L:0 (Default)
   |     |      Transform - light_hatch
   |     |      Light - light_hatch
   |     |    
   |     |---light_1RED T:Untagged L:0 (Default)
   |     |      Transform - light_1RED
   |     |      Light - light_1RED
   |     |    
   |     |---light_1 (1) T:Untagged L:0 (Default)
   |     |      Transform - light_1 (1)
   |     |      Light - light_1 (1)
   |     |    
   |     |--+WindowFocusPoint T:Untagged L:0 (Default)
   |     |  |   Transform - WindowFocusPoint
   |     |  |   BoxCollider - WindowFocusPoint
   |     |  | 
   |     |   ---WindowEyeTransform T:Untagged L:0 (Default)
   |     |         Transform - WindowEyeTransform
   |     |       
   |     |--+WindowFocusPoint02 T:Untagged L:0 (Default)
   |     |  |   Transform - WindowFocusPoint02
   |     |  |   BoxCollider - WindowFocusPoint02
   |     |  | 
   |     |   ---WindowEyeTransform02 T:Untagged L:0 (Default)
   |     |         Transform - WindowEyeTransform02
   |     |       
   |     |--+WindowFocusPoint03 T:Untagged L:0 (Default)
   |     |  |   Transform - WindowFocusPoint03
   |     |  |   BoxCollider - WindowFocusPoint03
   |     |  | 
   |     |   ---WindowEyeTransform03 T:Untagged L:0 (Default)
   |     |         Transform - WindowEyeTransform03
   |     |       
   |     |--+WindowFocusPoint04 T:Untagged L:0 (Default)
   |     |  |   Transform - WindowFocusPoint04
   |     |  |   BoxCollider - WindowFocusPoint04
   |     |  | 
   |     |   ---WindowEyeTransform04 T:Untagged L:0 (Default)
   |     |         Transform - WindowEyeTransform04
   |     |       
   |      --+WindowFocusPoint05 T:Untagged L:0 (Default)
   |        |   Transform - WindowFocusPoint05
   |        |   BoxCollider - WindowFocusPoint05
   |        | 
   |         ---WindowEyeTransform05 T:Untagged L:0 (Default)
   |               Transform - WindowEyeTransform05
   |             
    ---Surface Attach Collider T:Untagged L:0 (Default)
          Transform - Surface Attach Collider
          SphereCollider - Surface Attach Collider

 

And because I'm 99% sure you'll not know what I'm talking about... here is an example that applies the existing stock textures to the existing meshes.  Replace with your texture names, or whatever....

KSP_MODEL_SHADER
{
	name = Stock-MK1-3-IVA
	model = Squad/Spaces/Mk1-3/model
	MATERIAL
	{
		shader = SSTU/PBR/StockMetallicBumped
		texture = _MainTex, Squad/Spaces/Mk1-3/Mk1_3_IvaShell_Diffuse
		texture = _BumpMap, Squad/Spaces/Mk1-3/Mk1_3_IvaShell_Normal
		texture = _Emissive, Squad/Spaces/Mk1-3/Mk1_3_IvaShell_Emissive
		mesh = Mk1_3_IvaShell
	}
	MATERIAL
	{
		shader = SSTU/PBR/StockMetallicBumped
		texture = _MainTex, Squad/Spaces/Mk1-3/Mk1_3_IvaProps_Diffuse
		texture = _BumpMap, Squad/Spaces/Mk1-3/Mk1_3_IvaProps_Normal
		excludeMesh = Mk1_3_IvaShell
	}
}

 

Link to comment
Share on other sites

10 hours ago, Shadowmage said:

And because I'm 99% sure you'll not know what I'm talking about... here is an example that applies the existing stock textures to the existing meshes.  Replace with your texture names, or whatever.... 

 

Thanks for help. I know you  are talking about.

The problem is that I was unable to deduce a list of meshes in DebugStuff. When I was in the interior of the command module, I clicked on the objects  ( by holding shift and moving the cursor over model ) as usual, but nothing happened.

Meanwhile,  I had understood how the solar shader works. Look at my screenshots.

Spoiler

KSP_x64_2018_10_01_12_03_43_08.jpgKSP_x64_2018_10_01_12_03_48_16.jpgKSP_x64_2018_10_01_12_03_52_67.jpgKSP_x64_2018_10_01_12_04_01_55.jpgKSP_x64_2018_10_01_12_06_09_00.jpgKSP_x64_2018_10_01_12_06_31_98.jpgKSP_x64_2018_10_01_12_07_36_45.jpg

 

Edited by alexus
Link to comment
Share on other sites

4 hours ago, alexus said:

Look at transparent windows of StationPartsExpansionRedux Greenhouse.  You can see the moisture on the glass

what do you think?

 

 

Very nice work on that greenhouse piece :)

 

15 hours ago, alexus said:

Meanwhile,  I had understood how the solar shader works. Look at my screenshots. 

Fun, isn't it :)

 

15 hours ago, alexus said:

The problem is that I was unable to deduce a list of meshes in DebugStuff. When I was in the interior of the command module, I clicked on the objects  ( by holding shift and moving the cursor over model ) as usual, but nothing happened.

Haha, yeah, I cheated to get that output from DebugStuff.  I created a new part.cfg, and referenced the IVA's model inside of the MODEL node for the part.  Gets you a new part with the IVA mesh for its 'model' -- only really useful debugging stuff, but it works.  (I also tried importing the .mu into blender, but apparently there is something in the iva model that is unsupported and crashes the plugin).

Link to comment
Share on other sites

9 hours ago, Shadowmage said:

I created a new part.cfg, and referenced the IVA's model inside of the MODEL node for the part.  Gets you a new part with the IVA mesh for its 'model' -- only really useful debugging stuff, but it works.

may I get code please?

9 hours ago, Shadowmage said:

Fun, isn't it

oh yeah

 

Link to comment
Share on other sites

WARNING -- KSP 1.5 releases of TexturesUnlimited will not be entirely backwards compatible.

Shader variants are being consolidated (TU/Metallic), with all other features being keyword activated (Bump-Map, AO-Map, Emissive-Map, Sub-Surface-Scattering, Recoloring Mode A, Recoloring Mode B, etc).  The only separate shader variant in the current plans would be a 'TU/MetallicTransparent' variant, as you cannot activate transparency with keywords.  Configs will need to be updated to add keywords to activate the shader features needed for each MATERIAL definition;  in places where textures are defined or inherited the keywords should be automatically activated for those slots, but some features -will- require config-based keyword enabling.

There -may- be some option to load the old shaders as a separate shader pack; the config syntax should not be changing, so with that shader pack you would still have 'full backwards compatibility'.  Entirely speculative at this point, but if at all possible I will do what I can to enable some form of legacy support to ease the transition while configs are updated.

 

16 minutes ago, alexus said:

may I get code please?

Sadly I already trashed that file; was just something I put together for a quick debug... but I'll make up a quick example for you that should do the same....  (untested...)

Put this into a .cfg file, and place it somewhere in your GameData folder...

PART
{
	name = IVAModelDebugRig
	module = Part
	author = shadowmage
	MODEL
	{
		model = Squad/Spaces/Mk1-3/model
	}
	scale = 1
	rescaleFactor = 1
	TechRequired = start
	entryCost = 0
	cost = 0
	category = Aero
	subcategory = 0
	title = IVA Test
	manufacturer = Test Industries
	description = Test Things
	attachRules = 0,1,0,1,1
	node_attach = 0.000005, 0.0, 0.0, 1.0, 0.0, 0.0
	mass = 1
	crashTolerance = 12
	maxTemp = 2400
}

 

Replace the name in the MODEL block with the path of the model that you need to look at.

Edited by Shadowmage
Link to comment
Share on other sites

It is screenshots of some parts StationPartsExpansionRedux mod.

Spoiler

KSP_x64_2018_10_02_12_12_46_75.jpgKSP_x64_2018_10_02_14_08_13_60.jpgKSP_x64_2018_10_02_14_08_20_91.jpgKSP_x64_2018_10_02_14_08_27_81.jpgKSP_x64_2018_10_02_14_08_35_71.jpgKSP_x64_2018_10_02_14_08_42_23.jpgKSP_x64_2018_10_02_14_08_56_08.jpgKSP_x64_2018_10_02_14_09_02_19.jpgKSP_x64_2018_10_02_14_09_04_22.jpgKSP_x64_2018_10_02_14_09_11_50.jpgKSP_x64_2018_10_02_14_09_24_51.jpgKSP_x64_2018_10_02_14_09_33_90.jpgKSP_x64_2018_10_02_14_09_47_33.jpgKSP_x64_2018_10_02_14_09_54_16.jpgKSP_x64_2018_10_02_14_09_58_04.jpgKSP_x64_2018_10_02_14_10_04_55.jpgKSP_x64_2018_10_01_19_18_13_97.jpg

Shadowmage, look at greenhouse windows. You can see the plants are in front of the window visually.  Does it possible to fix it?

And can I access to lunchpad parts for TU? Debugstaff displays it  but there are not path to model.

p.s. very sorry that cupola has not windows mesh :(

Edited by alexus
Link to comment
Share on other sites

9 hours ago, alexus said:

Shadowmage, look at greenhouse windows. You can see the plants are in front of the window visually.  Does it possible to fix it?

As long as you are using the transparent shader there shouldn't be a problem.  Is that still happening even with the MetallicTransparent shader?

9 hours ago, alexus said:

And can I access to lunchpad parts for TU? Debugstaff displays it  but there are not path to model.

You can't adjust that type of stuff with TU -- only models that are registered in the model database.

Link to comment
Share on other sites

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