Jump to content

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


Shadowmage

Recommended Posts

4 hours ago, Manwith Noname said:

I would like to open a bit of a discussion with regard to standardising texture switching. [...]

If you do come up with something out of this, and as long as it is merely a framework/guideline for others to optionally use for stock parts (doesn't actually adjust any parts, and doesn't target any mods' parts), I would be willing to include it in the base TU distribution.  If there are any code-side changes that would help this along, please let me know and I can at least look into it.

 

Re: Fairings -- I recently added a module that is capable of adjusting the shaders on the stock fairings while still allowing to use the stock PartVariant feature for control of the texture sets.  Not entirely relevant to your post, but thought I would bring it up.  https://github.com/shadowmage45/TexturesUnlimited/blob/master/Plugin/SSTUTools/KSPShaderTools/Module/KSPFairingShader.cs

(ping me/PM me if you have questions on its setup or use)

 

2 hours ago, Jimbodiah said:

I smell a Community Textures Pack in the making.

I would not be opposed to something like that being put together, at least for stock parts.

Other mod authors though... some have not been very accepting of TU patches to their parts, with a few going so far as to state (paraphrased) 'please don't distribute patches for my mods parts; I want them to use the stock KSP shaders and textures'.  Unfortunately that is not a problem that I, or any of the patch/config authors, can fix.

Link to comment
Share on other sites

[RANT]

How can modmakers prohibit someone else from modding the mod parts with some shiny bling bling, when no sources are redistributed? It's purely some MM patches.

I know KSPI/MKS/NFE and a whole bunch of others actually alter the mechanics of other mods' parts; stripping modules completely, adding extra ones or heavily altering them. That would seem a lot more objectionable, yet I don't see any modders going after those? Why be so petty and complain about adding metallic textures via MM patches?

Heck, I basically mollest your parts into my own clones for personal gameplay, I actually feel guilty when uploading a new version so 5 other people can download them :)   

But metallic effects???? Come on....  They should give in and join the shiny side, there is even a texture switch to chose the stock version or the metallic version. What could be onjectionable?

[/RANT]

Edited by Jimbodiah
Link to comment
Share on other sites

1 hour ago, Shadowmage said:

If you do come up with something out of this, and as long as it is merely a framework/guideline for others to optionally use for stock parts (doesn't actually adjust any parts, and doesn't target any mods' parts), I would be willing to include it in the base TU distribution.

Ultimately, I'm not sure bundling with TU is a good idea. The plan is however for it to be optional. I can't force people to adopt it but I hope that those making texture sets would consider it as I feel it would benefit everyone. It is intended as a framework because right now, none exists. It's open season on stock parts and through my own experience there's just too many headaches without something like this. I've spent far too much time trying to build a config that works with and without certain patches when I could have just been working on textures. I could ultimately just carry on doing my own thing and ignore the problems I see arising but this leaves players with deciding if they want one pack over another, when with a bit of thought and effort, they could have multiple sets in their game and choose as they feel.

There's also the issue that the texture switch module takes precedent over the model shader, so by distributing a texture switch patch, model shader configs get overridden. Now, model shader patches fall in to the category I'm trying to avoid but they have one bonus right now and that is with some nesting, you can make them work with stock variants.

1 hour ago, Shadowmage said:

Re: Fairings -- I recently added a module that is capable of adjusting the shaders on the stock fairings while still allowing to use the stock PartVariant feature for control of the texture sets.  Not entirely relevant to your post, but thought I would bring it up.  https://github.com/shadowmage45/TexturesUnlimited/blob/master/Plugin/SSTUTools/KSPShaderTools/Module/KSPFairingShader.cs

I did have a play with this some time ago when I noticed it. I didn't get it working with recolouring or texture switching (heh, presumably for obvious reasons) so I left it for another day. That's why the fairing code in the example is still pre 1.4 setup.

Link to comment
Share on other sites

16 hours ago, Manwith Noname said:

I did have a play with this some time ago when I noticed it. I didn't get it working with recolouring or texture switching (heh, presumably for obvious reasons) so I left it for another day. That's why the fairing code in the example is still pre 1.4 setup.

Indeed -- the current implementation for stock fairings is intended to work along-side the stock PartVariant system, which does not support recoloring.  I do intend to release a 'stand alone' fairing-texture-switch-with-recoloring in the future -- but it would require the complete removal of the stock PartVariant stuff from the parts (can't have two texture manipulating systems on the same part without some level of conflict).

Link to comment
Share on other sites

I got some problems with this mod.

I use it the way that you told.

But it just looks like this:

CcCB28.jpg

I think it should at least be some where near whats its like in the Unity.Like this:

CcC08f.png

 

And I almost check everything including the cfg part.

Is there anyway to fix that? Or what should I do to cerrect it?

 

Thanks man, really looking forward to use your mod.

I'm the author of MNWS modern Navy Weapon System.

I'm using gl mode in a version of 1.4.3. 

Link to comment
Share on other sites

1 hour ago, Johnny005611 said:

I got some problems with this mod.

I use it the way that you told.

But it just looks like this:

CcCB28.jpg

I think it should at least be some where near whats its like in the Unity.Like this:

CcC08f.png

 

And I almost check everything including the cfg part.

Is there anyway to fix that? Or what should I do to cerrect it?

 

Thanks man, really looking forward to use your mod.

I'm the author of MNWS modern Navy Weapon System.

I'm using gl mode in a version of 1.4.3. 

 

Looks like reflections have not been enabled in the configs.  All you are seeing in your KSP screenshot is the specular highlights, but it is missing the environment-map reflections.  Try adding this config file to your GameData directory somewhere...

@REFLECTION_CONFIG[default]
{
	%enabled = true
}

 

Link to comment
Share on other sites

27 minutes ago, Shadowmage said:

Try adding this config file to your GameData directory somewhere...

Should I put it with cfg I write for the missile?

like:

KSP_MODEL_SHADER
{    
    name = TEST2
    model = Johnny/Part/AGM258/AGM258    
    
    TEXTURE 
    {
      shader = SSTU/PBR/Metallic

      texture = _MainTex, Johnny/Part/AGM258/AGM258_DefaultMaterial_AlbedoTransparency
        texture = _BumpMap, Johnny/Part/AGM258/AGM258_DefaultMaterial_Normal_NRM
      texture = _MetallicGlossMap, Johnny/Part/AGM258/DefaultMaterial_MetallicSmoothness
      texture = _AOMap, Johnny/Part/AGM2588/AGM258_DefaultMaterial_AO
    

      REFLECTION_CONFIG
        {
           name = TEST2
           enabled = true
        }
    
    }
}

 

And another thing is that I find a Reflectionsteup.cfg in your file, should I changed the reflection_config enable = true?

Thanks a lot

Link to comment
Share on other sites

2 minutes ago, Johnny005611 said:

Should I put it with cfg I write for the missile?

like:

KSP_MODEL_SHADER
{    
    name = TEST2
    model = Johnny/Part/AGM258/AGM258    
    
    TEXTURE 
    {
      shader = SSTU/PBR/Metallic

      texture = _MainTex, Johnny/Part/AGM258/AGM258_DefaultMaterial_AlbedoTransparency
        texture = _BumpMap, Johnny/Part/AGM258/AGM258_DefaultMaterial_Normal_NRM
      texture = _MetallicGlossMap, Johnny/Part/AGM258/DefaultMaterial_MetallicSmoothness
      texture = _AOMap, Johnny/Part/AGM2588/AGM258_DefaultMaterial_AO
    

      REFLECTION_CONFIG
        {
           name = TEST2
           enabled = true
        }
    
    }
}

 

And another thing is that I find a Reflectionsteup.cfg in your file, should I changed the reflection_config enable = true?

Thanks a lot

No, that config that I posted should go in a new file somewhere in your GameData directory, and the name must be 'name = default'.  You can see how I do it for SSTU here - https://github.com/shadowmage45/SSTULabs/blob/master/GameData/SSTU-PBR/Reflection-Enabler.cfg

Basically there is a single value in a config file that controls if reflections are enabled.  You need to patch that value to enable it (or edit it manually); creating a new config will not fix the problem.

 

Link to comment
Share on other sites

3 hours ago, Shadowmage said:

No, that config that I posted should go in a new file somewhere in your GameData directory, and the name must be 'name = default'.  You can see how I do it for SSTU here - https://github.com/shadowmage45/SSTULabs/blob/master/GameData/SSTU-PBR/Reflection-Enabler.cfg

Basically there is a single value in a config file that controls if reflections are enabled.  You need to patch that value to enable it (or edit it manually); creating a new config will not fix the problem.

 

Thanks man. That solve everything!!!

What a cool mod!!!!!!!!!

Link to comment
Share on other sites

Xn38r5z.png

Guess I'll be trying out the new directx fix, then.

Anyone know if there's a way around this that doesn't have the mentioned "slightly more overhead"? I'm not sure yet if it'll be a problem, so maybe I don't need a solution.

Link to comment
Share on other sites

2 hours ago, StarkRG said:

Anyone know if there's a way around this that doesn't have the mentioned "slightly more overhead"? I'm not sure yet if it'll be a problem, so maybe I don't need a solution.

If you are referring to the 'slightly more overhead' in the DX-fix of TU... it really should not be noticeable.  Its not doing any additional rendering, only manipulating a few additional objects in the rendering.

I used to have a registry-based fix for this particular problem, but I don't seem to know where the file is anymore; haven't needed it in a few years.  IIRC it involved manually adjusting the 'fullscreen mode' and/or resolution parameters.  Notably, if you try changing this key through regedit:

Computer\HKEY_CURRENT_USER\Software\Squad\Kerbal Space Program   -   Screenmanager Is Fullscreen mode

And set the value to '0x00000001' (1)

It _might_ resolve the issue.

 

Link to comment
Share on other sites

1 hour ago, Gordon Dry said:

@Jesusthebird

Interesting fact:

The link in the Reddit post from 0-0-1 to Dropbox is from April 28th and the config is 92.8 KB.
The Spacedock link from 0-0-1 is from April 29th and the config is 38.8 KB.

Choose yourself.

The file on reddit has multiple mods as well. lots of which i dont use. So i made this one. Spacedock one is strictly stock parts.

Link to comment
Share on other sites

I just got back on playing Kerbal again and this mod interests me. I kinda did a quick rough PBR texture in Substance painter of the mainsail engine without disturbing it's geometry and UVs. I ripped it using the mu to blender tool then export as fbx to 3ds Max

I don't really know how to do all this stuff. If anyone want to experiment with it, I've attached the TGAs. It is using Unity Standard shader, the smoothness is embedded in the metallic map alpha channel. 

ifWmRa1.png

NOTE: That the normal map may not work correctly as I modified the smoothing group for the map baking. I have a modified FBX of the Mainsail but I think they might be legal issue of me posting it.

https://www.dropbox.com/s/y1csnzrd8fufnmy/mainsail-tga.zip?dl=0

Link to comment
Share on other sites

4 hours ago, Jeorge said:

I just got back on playing Kerbal again and this mod interests me. I kinda did a quick rough PBR texture in Substance painter of the mainsail engine without disturbing it's geometry and UVs. I ripped it using the mu to blender tool then export as fbx to 3ds Max

I don't really know how to do all this stuff. If anyone want to experiment with it, I've attached the TGAs. It is using Unity Standard shader, the smoothness is embedded in the metallic map alpha channel. 

 

NOTE: That the normal map may not work correctly as I modified the smoothing group for the map baking. I have a modified FBX of the Mainsail but I think they might be legal issue of me posting it.

https://www.dropbox.com/s/y1csnzrd8fufnmy/mainsail-tga.zip?dl=0

Glad you are getting some enjoyment out of the improved shaders :)

What you propose would be the 'correct' way to add support for PBR shaders to the stock parts.  To fully support the features of the new shaders, entirely new textures should be authored with proper values for all channels in use (albedo/diff, spec/smooth/rough, metallic, AO, NRM, and GLOW).  Nice work on that conversion, looking good :)  It is pretty amazing what the stock models can look like with modern texturing and shading....

Normal map / smoothing groups -- your output NRM might work fine.  I've noticed that the blender .mu importer often loses the edge-split/smoothing groups, so they have to be recreated.  As long as the recreated ones match the originals, the normal map should work on the stock model just fine.

 

I have noticed that for stock textures, the existing DIFF and SPEC data can mostly be used as-is.  It is really the MET data that needs to be created for stock parts (and many could benefit from a good NRM map as well).  I actually have a shader written specifically for this setup, that takes the existing stock DIFF(RGB)/SPEC(A) textures and only requires the addition of a MET texture (with MET stored in the R channel of the texture).

 

Link to comment
Share on other sites

5 minutes ago, Dave-Daring said:

TexturesUnlimited currently requires the use of the OpenGL-Core graphics API.  This may be activated by using the '-force-glcore' command line option to launch KSP

Fine but how & where do I do that?

Probably goes to show how old I am.... but how can you not know how to use a command-line option?  (mostly kidding; I know that these days most people don't even know what a command prompt is, let alone how to use one)

These are the unity docs on it:

https://docs.unity3d.com/Manual/CommandLineArguments.html

And how to use them in Steam (this page is tailored to Valve/Source-Engine games, but the methodology applies equally to any game)

https://support.steampowered.com/kb_article.php?ref=1040-JWMT-2947

The important bits from the article above:

Quote

Set Launch Options

  1. Right-click on the game title under the Library in Steam and select Properties.
  2. Under the General tab click the Set launch options... button.
  3. Enter the launch options you wish to apply (be sure to separate each code with a space) and click OK.
  4. Close the game's Properties window and launch the game.

 

Link to comment
Share on other sites

I found out that interestingly this mod co-exists with the DCK colouring mod, obviously the textures being different from stock make the TU UI elements un-usable but it does give an overall nice metallic sheen to the colored parts.

Link to comment
Share on other sites

I'm interested in creating PBR texture sets (possibly taking the Substance Painter route like @Jeorge) for some stock parts but I'm unclear as to how to go about this.

I've checked through chunks of this thread, in particular the first and last few pages, but I'm not clear on what I need to add to my KSP enable me to provide a texture set for a stock part (or part that looks like stock) to TU to render. I've seen a couple of image and multiple mentions of the TU GUI and recoloring GUI (which might be my jumping off point), but I can't info on how to access them.

So if someone with information on this could point me in the right direction, it would be much appreciated.

Link to comment
Share on other sites

On 5/27/2018 at 4:08 AM, purpleivan said:

I'm interested in creating PBR texture sets (possibly taking the Substance Painter route like @Jeorge) for some stock parts but I'm unclear as to how to go about this.

Create your textures, using the Unity-Metallic preset in substance painter.  Export all of them (diff, met/smooth, nrm, ao).

Create a config file to apply those textures to the model(s) of choice:

https://github.com/shadowmage45/SSTULabs/blob/master/GameData/SSTU/Shaders/DefaultShaderAssignments-SolarPanels.cfg#L50-L69

In the shader/texture config, for the 'shader =' entry, use 'SSTU/PBR/Metallic'.  All other paths should point to the model and/or textures, as appropriate.

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