Jump to content

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


Shadowmage

Recommended Posts

On 11/22/2017 at 7:21 AM, Electrocutor said:

The new transparency PBR shader works well. I've set it up on @RoverDude's Life Support pods that have transparent domes. The Viewing Cupola actually has an armchair inside.

PXIcRzC.jpg

How I can make transporent glass? Help please

Edited by alexus
Link to comment
Share on other sites

I'm trying to make a shiny sputnik like in the 2nd post of this thread but it ends up really dark.  I'm using the SXT part which has this specified in its config: texture = model000 , Squad/Parts/Command/probeStackSphere/model000

That model000 texture is pure black, so I tried overriding it in my config, but that had no effect.  Im on KSP 1.3.1 using TU 1.0.0.8  What am I doing wrong?

Spoiler

KSP_MODEL_SHADER
{
    name = UltraMetal

    model = SXT/Parts/Probes/Command/Dontstay/model

    TEXTURE // Metal
    {
        shader = SSTU/PBR/Metallic

        excludeMesh = flagTransform
        excludeMesh = Flag
        
        texture = _MainTex, Squad/Parts/Command/probeStackSphere/model000

        PROPERTY
        {
            name = _Metal
            float = 1
        }
        PROPERTY
        {
            name = _Smoothness
            float = 1
        }
        PROPERTY
        {
           name = _Color
           //for color properties, specify a 'color=' value
           color = 1.0, 1.0, 1.0, 1.0
        }
        
    }
}

 

Cw2NqBa.jpg

Edited by Telanor
Link to comment
Share on other sites

50 minutes ago, Telanor said:

I'm trying to make a shiny sputnik like in the 2nd post of this thread but it ends up really dark.  I'm using the SXT part which has this specified in its config: texture = model000 , Squad/Parts/Command/probeStackSphere/model000

That model000 texture is pure black, so I tried overriding it in my config, but that had no effect.  Im on KSP 1.3.1 using TU 1.0.0.8  What am I doing wrong?

  Reveal hidden contents

KSP_MODEL_SHADER
{
    name = UltraMetal

    model = SXT/Parts/Probes/Command/Dontstay/model

    TEXTURE // Metal
    {
        shader = SSTU/PBR/Metallic

        excludeMesh = flagTransform
        excludeMesh = Flag
        
        texture = _MainTex, Squad/Parts/Command/probeStackSphere/model000

        PROPERTY
        {
            name = _Metal
            float = 1
        }
        PROPERTY
        {
            name = _Smoothness
            float = 1
        }
        PROPERTY
        {
           name = _Color
           //for color properties, specify a 'color=' value
           color = 1.0, 1.0, 1.0, 1.0
        }
        
    }
} 

 

Cw2NqBa.jpg

Sputnik Lionhead mod made a good one also here is one I try to keep updates https://www.dropbox.com/s/qmy4u41ptq2qjm1/Lionhead_Aerospace_Inc_v1.42.zip?dl=0

Link to comment
Share on other sites

SSTU/PBR/MetallicTransparent

Does this shader work?

KSP_x64_2018_09_09_15_12_15_13.jpg

Spoiler

@REFLECTION_CONFIG[default]
{
    %enabled = true
}
KSP_MODEL_SHADER
{
    name = Stock_FullMetal
    

        model = PlanetaryBaseInc/BaseSystem/Parts/Command/CentralHub/Central_Hub


    MATERIAL
    {
        shader = SSTU/PBR/MetallicTransparen
        inheritTexture = _MainTex
        inheritTexture = _BumpMap
        inheritTexture = _Emissive
//        mesh = windows
//        mesh = Windows


        PROPERTY
        {
            name = _Metal
            float = 1
        }
        PROPERTY
        {
            name = _Smoothness
            float = 0.9
        }
    }

}

 

Edited by alexus
Link to comment
Share on other sites

On 9/8/2018 at 7:16 PM, Telanor said:

I'm trying to make a shiny sputnik like in the 2nd post of this thread but it ends up really dark.  I'm using the SXT part which has this specified in its config: texture = model000 , Squad/Parts/Command/probeStackSphere/model000

That model000 texture is pure black, so I tried overriding it in my config, but that had no effect.  Im on KSP 1.3.1 using TU 1.0.0.8  What am I doing wrong?

  Hide contents

KSP_MODEL_SHADER
{
    name = UltraMetal

    model = SXT/Parts/Probes/Command/Dontstay/model

    TEXTURE // Metal
    {
        shader = SSTU/PBR/Metallic

        excludeMesh = flagTransform
        excludeMesh = Flag
        
        texture = _MainTex, Squad/Parts/Command/probeStackSphere/model000

        PROPERTY
        {
            name = _Metal
            float = 1
        }
        PROPERTY
        {
            name = _Smoothness
            float = 1
        }
        PROPERTY
        {
           name = _Color
           //for color properties, specify a 'color=' value
           color = 1.0, 1.0, 1.0, 1.0
        }
        
    }
}

 

 

Your patch looks good, but you are overriding the texture.... with the same texture.

Replace the line of : texture = _MainTex, Squad/Parts/Command/probeStackSphere/model000

with something that points to your custom (not black) texture.

Alternatively, you could try sometihing like (delete that line and use this instead):

'textureColor = _MainTex,255,255,255,255'

Which _should_ replace the MainTex slot with a full white default texture.  (edit:  not sure if this works in the 1.3.1 versions or not.... it was one of the newer features, don't remember when it was added)

 

 

On 9/8/2018 at 11:44 PM, alexus said:

SSTU/PBR/MetallicTransparent

Does this shader work?

KSP_x64_2018_09_09_15_12_15_13.jpg

  Hide contents

@REFLECTION_CONFIG[default]
{
    %enabled = true
}
KSP_MODEL_SHADER
{
    name = Stock_FullMetal
    

        model = PlanetaryBaseInc/BaseSystem/Parts/Command/CentralHub/Central_Hub


    MATERIAL
    {
        shader = SSTU/PBR/MetallicTransparen
        inheritTexture = _MainTex
        inheritTexture = _BumpMap
        inheritTexture = _Emissive
//        mesh = windows
//        mesh = Windows


        PROPERTY
        {
            name = _Metal
            float = 1
        }
        PROPERTY
        {
            name = _Smoothness
            float = 0.9
        }
    }

}

 

Yes it works, but you have mis-spelled it in your patch.  You have ' SSTU/PBR/MetallicTransparen ' --- missing the 't' at the end  ( ' SSTU/PBR/MetallicTransparent ')

On 9/9/2018 at 8:15 AM, alexus said:

Help me, please

Have some patience, please.  I work full time +, and have extremely limited time that I can devote to modding duties (that includes forum posts and helping others figure things out).

I will try and write up an example patch for you later that will show you how to replace the metallic texture with one you have created (really though; you should be able to figure that out from the examples in SSTU).

Edited by Shadowmage
Link to comment
Share on other sites

On 9/6/2018 at 4:43 PM, alexus said:

Ok. I make texture ( Which one for cupola? It has texture files cupola_Emissive,ksp_l_cupola_diff ) and what should I make change in TU config file ?

The texture you need to make is a _new_ texture -- cupola_Metallic.png (or .dds, whichever way you want to encode it).  It needs to be a metallic mask, white in areas of metal, black in areas of non-metals (glass should be non-metal).  Note that many of the stock models do not have proper specular/roughness/smoothness values for PBR use, so it may require additional work beyond just adding a metallic map.

You then apply it to your part using a standard shader-replacement setup (patch provided below, fill in your texture name and it should 'just work')

KSP_MODEL_SHADER
{
	name = CupolaCustomMetallicMap
	model = Squad/Parts/Command/cupola/model
	MATERIAL
	{	
		// this shader uses the ALPHA channel of the diffuse texture
		// for 'roughness'/'smoothness' input (which should already exist in the stock texture)
		// and the RED channel of the metallic-gloss-map for the metallic input value
		shader = SSTU/PBR/StockMetallicBumped
		
		// this points to your texture file, relative to the GameData folder;
		// e.g. if your texture is in GameData/MyMod/MyTexture.png 
		// this line would be 'texture = _MetallicGlossMap, MyMod/MyTexture
		// note that the extension is NOT included in the path specification
		texture = _MetallicGlossMap, pathToYourTexture
		
		//any other PROPERTY blocks go here
		//... but if your texture is created properly you shouldn't need them....		
	}
}

 

Link to comment
Share on other sites

9 hours ago, Shadowmage said:

The texture you need to make is a _new_ texture -- cupola_Metallic.png (or .dds, whichever way you want to encode it).  It needs to be a metallic mask, white in areas of metal, black in areas of non-metals (glass should be non-metal).  Note that many of the stock models do not have proper specular/roughness/smoothness values for PBR use, so it may require additional work beyond just adding a metallic map.

You then apply it to your part using a standard shader-replacement setup (patch provided below, fill in your texture name and it should 'just work')

 

Thanks for help. But How can I separate parts of the model (for shader) that do not have a separate mesh? For example, cupola model has not separate  window mesh.

Edited by alexus
Link to comment
Share on other sites

5 hours ago, alexus said:

But How can I separate parts of the model (for shader) that do not have a separate mesh?

You can't (without potentially violating copyright and/or eula), as I already stated.  But... also... you don't need to.  Create the textures and apply them as I've outlined above, and you don't need to split the meshes off -- the textures take care of the per-mesh differences.

Link to comment
Share on other sites

Im having a hicup with my cfg.

Focus: airplane plus

Part: cf34 engine, stubby nosecone type B

 

These are the only models not affected by TU so far. I thought at first it was because the texture wasnt in the part parent folder(nose cone texture points to squads nose cone texture and has a placeholder itself ie: texture = placeholder , squad/parts/..) however the cf34 engine has its own texture and only has  model =  parameter. Thus using the texture in the parent folder.

Theres another stubby nosecone too..using the same texture = placeholder , squad/parts/... Parameter. And i was able to apply a shader to it. Only difference i see in the cfg is the actual model used. All textures seem to have an alpha channel. And ive tried using the stock diffuse-a shader instead of the pbr metallic one. 

 

Anyone have some insight to make this work with these 2 parts? Once i figure it out i can make some real progress on my project(TU configs for many..many mods!) as im guessing most parts that dont work right off the bat like this have relatable issue like this. I can post my cfgs when i get home if needed. Thanks!

Link to comment
Share on other sites

34 minutes ago, Jesusthebird said:

Im having a hicup with my cfg.

Focus: airplane plus

Part: cf34 engine, stubby nosecone type B

Would you mind posting your config / a link to it / PM'ing the information to me?  Hard to diagnose config-level problems, without seeing the .cfg file :)

Link to comment
Share on other sites

9 hours ago, Shadowmage said:

You can't (without potentially violating copyright and/or eula), as I already stated.  But... also... you don't need to.  Create the textures and apply them as I've outlined above, and you don't need to split the meshes off -- the textures take care of the per-mesh differences.

Do I understand correctly:

if I want to make 2 shaderes on model and on windows separately I need make two textures and make config for it.

But the textures will be the same and how the game will understand how to separate the windows from the rest?

Link to comment
Share on other sites

Hey @Shadowmagehttps://drive.google.com/file/d/1EO5B1m13i-v_8uWwVB7PPg1LeRNxMBgK/view?usp=sharing Link to my cfg for Airplane Plus. Using the StockMetalicBumped shader, it'll provide a strange sheen to the part(thats the _Smoothness property right?); but still no _Metal property still, thanks for looking it over for me as well as any feedback you may think of :) you rock man!

Edit: I placed the models in question in a separate KSP_MODEL_SHADER node at the bottom as to not confuse anyone right now and they are easier to find. But I originally had it with the rest of the models above. obviously as stated earlier, the pbr/metallic shader didnt apply per the rest of the models, so here we are :)

Edited by Jesusthebird
Link to comment
Share on other sites

13 hours ago, alexus said:

Do I understand correctly:

if I want to make 2 shaderes on model and on windows separately I need make two textures and make config for it.

But the textures will be the same and how the game will understand how to separate the windows from the rest?

Not entirely -- you make one texture, and use one shader for the entire model.  The shaders are entirely capable of being used for the entire model as a single mesh -- as long as the textures are set up properly.  All this nonsense about needing to have windows as separate meshes is only because nobody wanted to take the time to create the proper texturing.  Finally, as this model doesn't have the windows already separated, your only way to get it to work properly for the PBR shaders will be to create and use new textures.

Link to comment
Share on other sites

14 hours ago, Jesusthebird said:

Hey @Shadowmagehttps://drive.google.com/file/d/1EO5B1m13i-v_8uWwVB7PPg1LeRNxMBgK/view?usp=sharing Link to my cfg for Airplane Plus. Using the StockMetalicBumped shader, it'll provide a strange sheen to the part(thats the _Smoothness property right?); but still no _Metal property still, thanks for looking it over for me as well as any feedback you may think of :) you rock man!

Edit: I placed the models in question in a separate KSP_MODEL_SHADER node at the bottom as to not confuse anyone right now and they are easier to find. But I originally had it with the rest of the models above. obviously as stated earlier, the pbr/metallic shader didnt apply per the rest of the models, so here we are :)

Thanks, have d/l the cfg, and will take a look at it in the next few days (likely over the weekend, is when I have most of my 'free' time).  Most often these end up being small syntax errors, but there always exists the possibility of a bug in the mod.  Will let you know what I find out.

Link to comment
Share on other sites

5 hours ago, alexus said:

Shadowmage, if the model has not the separate window`s mesh I can not assign it a separate transparent shader?

That is correct.  KSP does not support multiple shaders (materials) for a single mesh.

I still believe that what you are trying to accomplish can be done with the creation of custom textures -- although, with the added information that you are needing transparency, it complicates things a bit more.  In this case you would need to supply the metallic-gloss-map and an updated/fixed diffuse/alpha texture (where RGB is regular color, and the A channel is alpha-transparency).  Apologies that I didn't catch your need for transparency before, could have made things a lot clearer, sooner.

 

Link to comment
Share on other sites

1 hour ago, alexus said:

It is working. But while I do not understand how combine _MetallicGlossMap  and _MainTex. It made by _MainTex.

ut

It all looks to be working properly to me?

Are you trying to make the window transparent when viewing the model from the outside?  (that will likely not work properly, as there is no internal mesh for the models; you would see through the window, and through the back-face of the models external geometry)

Or are you trying to get the shaders working for IVAs?

Link to comment
Share on other sites

3 hours ago, Shadowmage said:

It all looks to be working properly to me?

Are you trying to make the window transparent when viewing the model from the outside?  (that will likely not work properly, as there is no internal mesh for the models; you would see through the window, and through the back-face of the models external geometry) 

Or are you trying to get the shaders working for IVAs? 

How can I get the window transparent if it has not separate mesh? :(

Link to comment
Share on other sites

1 hour ago, alexus said:

How can I get the window transparent if it has not separate mesh? :(

Again, I will ask:  Are you trying to make the window transparent when viewing the model from the outside?  Or are you trying to get the shaders working for IVAs?  (although that is mostly academic to the actual steps needed)

Yes - you can have transparent windows even if they are not a separate mesh, and the work you have done to create the metallic texture can be re-used and would have still been needed.  There will just be a couple of extra steps to get it all set up to work with transparency.

Transparent shaders such as the one used by Textures Unlimited usually get the 'transparency' level from the alpha channel of the diffuse texture; this allows you to have parts of the mesh that are transparent, and other parts that are opaque, simply based on the value in the alpha channel.  It also allows for 'partial' transparency by using a value other than black/white in the alpha channel.

In order to get this set up and working, you will need the following textures:

 

Diffuse Texture with Transparency in alpha channel (RGB albedo, A transparency)

Take the existing diffuse texture, remove any existing alpha channel information (store this for later if you want to use it for spec/smooth map).  Add a new alpha channel that is white/1.0f/FF in areas that you want to be opaque, black/0.0f/00 in areas that you want to be entirely transparent.  So the windows that you want to be transparent will have 0's / black in the alpha channel in the diffuse texture (or gray if you want semi-transparent).

MetallicGlossMap (R metal, A smoothness)

This is more than likely what you have already created, at least in part.  You should have Metallic information in the R/G/B channels, and smoothness information in the A channel.  You seem to already have this bit mostly figured out.

(Optional) Normal Map

Standard normal map; lots of information out there on these.

(Optional) AO Map

AO is mostly baked into the stock diffuse textures, and would be difficult to extract properly.  The texture slot exits if you want it though...

(Optional) Emissive/Glow Texture (RGB emissive)

This texture is used for glowing windows.  RGB = Color of glow.  A = should be set to white/1.0f/FF.

 

 

Once you have at least the Diffuse/transparency texture and the MetallicGlossMap, you can create a config to apply them to the model.  This will be nearly identical to the example I already posted, with a small change to the shader name.

KSP_MODEL_SHADER
{
	name = CupolaCustomMetallicMap
	//this is the path to the model.mu that you want to adjust, minus the extension
	model = Squad/Parts/Command/cupola/model
	MATERIAL
	{	
		// this shader uses the ALPHA channel of the diffuse texture
		// for transparency data
		shader = SSTU/PBR/MetallicTransparent
		
		// this points to your diffuse/transparency texture file, relative to the GameData folder;
		// e.g. if your texture is in GameData/MyMod/MyTexture.png 
		// this line would be 'texture = _MetallicGlossMap, MyMod/MyTexture
		// note that the extension is NOT included in the path specification
		texture = _MainTex, pathToYourDIFFTexture
		
		// this points to your metallicGlossMap texture file, relative to the GameData folder;
		texture = _MetallicGlossMap, pathToYourMETTexture
		
		//custom NRM map, disabled by comment
		//texture = _BumpMap, pathToYourNRMTexture
		
		//AO texture, disabled by comment
		//texture = _AOMap, pathToYourAOTexture
		
		//emissive texture, disabled by comment
		//texture = _Emissive, pathToYourGLOWTexture
		
		//any other PROPERTY blocks go here
		//... if your textures are created properly you shouldn't need them....	
		//... but they do still have occasional use for special setups and workarounds
	}
}

 

 

 

Edit:  Reworded message to be more explanatory...

Edited by Shadowmage
Link to comment
Share on other sites

While the conversation is on this track...

Is it possible to have a recolour shader that respects transparency or is there a technical limitation? It's been a while since I tried and I only really needed it for parachutes thus far but back when I was covering them I had this occur...

Spoiler

77F9FD94593723318E6A26F0442E8028C1C74A0A

Also, I think Alexus wants the windows transparent from the outside (so you can see in to the cockpit) which to my knowledge isn't possible without remodelling it to the requirements of the transparent cockpit mod thingamiejig.

Link to comment
Share on other sites

13 minutes ago, Manwith Noname said:

While the conversation is on this track...

Is it possible to have a recolour shader that respects transparency or is there a technical limitation? It's been a while since I tried and I only really needed it for parachutes thus far but back when I was covering them I had this occur...

  Reveal hidden contents

77F9FD94593723318E6A26F0442E8028C1C74A0A

Also, I think Alexus wants the windows transparent from the outside (so you can see in to the cockpit) which to my knowledge isn't possible without remodelling it to the requirements of the transparent cockpit mod thingamiejig.

KSP has an exterior model and an interior model. Upon activating the IVA-visible mode, it puts cameras and render textures in to pretend to be like transparency. It gives the appearance like the insides are being rendered in the main game camera, but they are not: the IVAs exist in their own separate root object and there are merely cameras that allow you to see them.

The screenshot @alexus used earlier of RoverDude's cupola with the chair inside is visible because he modeled the interior of the glass within the exterior model.

Edited by Electrocutor
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...