Jump to content

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


Shadowmage

Recommended Posts

On 4/12/2020 at 5:56 AM, VoidCosmos said:

@Shadowmage

How do you write a Textures Unlimited config so as to making a part 'white'?

@Delay's suggestion would work if you wanted a complete flat-white part.

If you wanted to keep some of the original part texture details, it would require full setup of the recolor mask, normalization parameters or mask, and setting up the recolorable config for the part.  Can provide more details if that is what you were looking for.

Link to comment
Share on other sites

36 minutes ago, Shadowmage said:

@Delay's suggestion would work if you wanted a complete flat-white part.

If you wanted to keep some of the original part texture details, it would require full setup of the recolor mask, normalization parameters or mask, and setting up the recolorable config for the part.  Can provide more details if that is what you were looking for.

Nevermind. Sorry for the inconvenience

Link to comment
Share on other sites

@Shadowmage

For transparency, here are the options that stock shaders use:

most have _Cutout property default 0.5

Queue: Transparent, RenderType: Transparent
Queue: AlphaTest, RenderType: TransparentCutout
Queue: AlphaTest, RenderType: Opaque

some use alpha:fade
some use alpha:_Cutout

some have ZWrite On, some don't
some have ZTest LEqual, some don't
some have a Pass{} with ZWrite On, ColorMask 0, then later only ZTest LEqual

I don't think there is a need to cover everything, but the ability to use _Cutout would be most useful

----

I'm also trying to figure out what SurfaceOutput.Specular does. That is what the _Shininess value is put into.
For the time being using _SpecColor *= _Shininess seems to make the surface look how it does with stock shaders.

This is the actual shader code (from PartTools):
 

inline fixed4 LightingBlinnPhongSmooth(SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
{
	s.Normal = normalize(s.Normal);
	half3 h = normalize(lightDir + viewDir);

	fixed diff = max(0, dot(s.Normal, lightDir));

	float nh = max(0, dot(s.Normal, h));
	float spec = pow(nh, s.Specular*128.0) * s.Gloss;

	fixed4 c;
	c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten);
	c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
	return c;
}

 

Link to comment
Share on other sites

2 hours ago, Electrocutor said:

For transparency, here are the options that stock shaders use:

most have _Cutout property default 0.5

Queue: Transparent, RenderType: Transparent
Queue: AlphaTest, RenderType: TransparentCutout
Queue: AlphaTest, RenderType: Opaque

some use alpha:fade
some use alpha:_Cutout

some have ZWrite On, some don't
some have ZTest LEqual, some don't
some have a Pass{} with ZWrite On, ColorMask 0, then later only ZTest LEqual

I don't think there is a need to cover everything, but the ability to use _Cutout would be most useful

Thanks, will look into adding a cutoff shader for the next release (as soon as I can find some free-time and head-space to work on modding again...).  Sounds like it might be the missing key for many of the transparency issues currently experienced.

 

Link to comment
Share on other sites

Sorry if my question is not TU related or not, so sorry if this is the wrong thread to ask for help, but i'm having an issue with reflection, when if I make a fully reflective tank with procedural parts or ROTanks, they reflect just fine in VAB, but on flight mode they just show a black surface. Here's a video showing just that.

I have the mod version 1.5.8.23 installed from CKAN in a 1.7.3 KSP, with Realism Overhaul/RP1 and some recommended mods. This is my currently mod list:

Spoiler

000_ClickThroughBlocker
000_TexturesUnlimited
000_Toolbar
001_ToolbarControl
AJE
B9PartSwitch
BasicProceduralTextures
blackheart
Chatterer
CommunityResourcePack
ContractConfigurator
CraftManager
CustomBarnKit
DeadlyReentry
DMagicOrbitalScience
DMagicScienceAnimate
EasyVesselSwitch
EngineGroupController
FASA
FerramAerospaceResearch
Firespitter
FlareReplacer
FreedomTex
FShangarExtender
HullCameraVDS
JanitorsCloset
KerbalConstructionTime
KerbalHacks
KerbalJointReinforcement
Kopernicus
KSCSwitcher
KXAPI
MagiCore
MechJeb2
ModularFlightIntegrator
ModuleManager.4.0.3
NavHud
NoNonRO
NoNonRP0
PatchManager
Principia
ProceduralFairings
ProceduralParts
RealChute
RealEnginesPack
RealFuels
RealHeat
RealismOverhaul
RealPlume
RealSolarSystem
ReentryParticleEffect
RetractableLiftingSurface
ROEngines
ROTanks
RP-0
RSS-Textures
SCANsat
scatterer
SmokeScreen
SolverEngines
Squad
StretchySNTextures
SXT
Taerobee
TimeControl
TrackingStationEvolved
TriggerTech
VenStockRevamp

Any help would be much appreciated.

Link to comment
Share on other sites

@Shadowmage Is there any cfg syntax that can be used to add a reflection probe to the MainMenu? Using my plugin that uses procedural application of TU to everything, the visors of kerbals look very wrong with no reflection probe.

Also, could you add a _SpecAlphaInvert property that would apply to either color.a or spec.a maps depending on TU_STOCK_SPEC? The use case is for transparent shader, the alpha channel is generally exactly inverted to what you want for smoothness.

Edited by Electrocutor
Link to comment
Share on other sites

Hello! I'm making some reflective mirrors as an addon for Tarsier Space Tech, and noticed some weird artifacts:

 

F5Si4Ee.png

As you can see, the flag appears distorted. This happens because the reflection patterns appear to "break" in a cross pattern from the center; strangely enough, this effect varies quite a lot with distance.

The mesh itself is a parabola with a focus 10x its diameter away, and I'm using TU/Specular.

Link to comment
Share on other sites

14 hours ago, Tonas1997 said:

Hello! I'm making some reflective mirrors as an addon for Tarsier Space Tech, and noticed some weird artifacts:

As you can see, the flag appears distorted. This happens because the reflection patterns appear to "break" in a cross pattern from the center; strangely enough, this effect varies quite a lot with distance.

The mesh itself is a parabola with a focus 10x its diameter away, and I'm using TU/Specular.

That looks like your normal map has issues. And if you're not using a normal map, you need to enable the TU_BC5_NRM keyword because the default "bump" that unity assigns has one channel wrong.

Link to comment
Share on other sites

16 minutes ago, Electrocutor said:

That looks like your normal map has issues. And if you're not using a normal map, you need to enable the TU_BC5_NRM keyword because the default "bump" that unity assigns has one channel wrong.

Thanks for the help! However, I went to the repo and apparently that's only supported on the latest, 1.9-compiled TU, whereas I'm playing on 1.8.1. Is that release backwards-compatible?

EDIT: I updated TU and the config, but the issue seems to persist:

Spoiler

qbrMelq.png

mS1qIxi.png

The config (which I know is the bare minimum to get a reflective surface):

Spoiler

@REFLECTION_CONFIG[default]
{
    %enabled = true
}

KSP_MODEL_SHADER
{
    name = OpticalMirror
    model = TesteTelescopio/Parts/opticalTelescope/opticalTelescope
    MATERIAL // Metal
    {    
        shader = TU/Specular
        //texture specifications -- these are 'texture = <shader-slot>, <texture-path>'
        texture = _MainTex, TesteTelescopio/Parts/opticalTelescope/opticalTelescope/espelhoText
        keyword = TU_BC5_NRM
        // texture = _AOMap, SSTU-PBR/Assets/SC-ENG-F1-AO
        //you can specify multiple mesh = entries; one per line; this is the 'whitelist' mode
        mesh = mainMirror

        //alternatively you can specify one or more 'excludeMesh = meshName' lines; this is the 'blacklist' mode
        //if neither are specified, it will apply the material to all meshes in the model
    }
}

 

Edited by Tonas1997
Link to comment
Share on other sites

On 4/17/2020 at 7:39 PM, mateusviccari said:

Sorry if my question is not TU related or not, so sorry if this is the wrong thread to ask for help, but i'm having an issue with reflection, when if I make a fully reflective tank with procedural parts or ROTanks, they reflect just fine in VAB, but on flight mode they just show a black surface. Here's a video showing just that.

I have the mod version 1.5.8.23 installed from CKAN in a 1.7.3 KSP, with Realism Overhaul/RP1 and some recommended mods. This is my currently mod list:

  Reveal hidden contents

000_ClickThroughBlocker
000_TexturesUnlimited
000_Toolbar
001_ToolbarControl
AJE
B9PartSwitch
BasicProceduralTextures
blackheart
Chatterer
CommunityResourcePack
ContractConfigurator
CraftManager
CustomBarnKit
DeadlyReentry
DMagicOrbitalScience
DMagicScienceAnimate
EasyVesselSwitch
EngineGroupController
FASA
FerramAerospaceResearch
Firespitter
FlareReplacer
FreedomTex
FShangarExtender
HullCameraVDS
JanitorsCloset
KerbalConstructionTime
KerbalHacks
KerbalJointReinforcement
Kopernicus
KSCSwitcher
KXAPI
MagiCore
MechJeb2
ModularFlightIntegrator
ModuleManager.4.0.3
NavHud
NoNonRO
NoNonRP0
PatchManager
Principia
ProceduralFairings
ProceduralParts
RealChute
RealEnginesPack
RealFuels
RealHeat
RealismOverhaul
RealPlume
RealSolarSystem
ReentryParticleEffect
RetractableLiftingSurface
ROEngines
ROTanks
RP-0
RSS-Textures
SCANsat
scatterer
SmokeScreen
SolverEngines
Squad
StretchySNTextures
SXT
Taerobee
TimeControl
TrackingStationEvolved
TriggerTech
VenStockRevamp

Any help would be much appreciated.

Forget it, I just solved it by mistake... If anyone is having the same issue, the solution couldn't be more simpler:

Right click on KSP on steam, choose properties, Set launch options, and type:

-force-d3d11

If you don't have steam, just put this on the windows shortcut, after KSP.exe.

Now my game feels a lot better, and I can have THESE AMAZING REFLECTIONS

Link to comment
Share on other sites

1 hour ago, Cpt.Wuurd said:

Hey everyone o/ I have a rather noob question. Is there a way for me to learn how to patch these files for my own optimal preference somewhere on the internet? Like "file patching for dummies or something."

https://github.com/sarbian/ModuleManager/wiki/Module-Manager-Handbook

https://github.com/sarbian/ModuleManager/wiki/Module Manager Syntax

^^ Those are the basic instruction manual for using ModuleManager for patching files.

Link to comment
Share on other sites

On 4/19/2020 at 2:31 PM, Tonas1997 said:

Hello! I'm making some reflective mirrors as an addon for Tarsier Space Tech, and noticed some weird artifacts:

 

F5Si4Ee.png

As you can see, the flag appears distorted. This happens because the reflection patterns appear to "break" in a cross pattern from the center; strangely enough, this effect varies quite a lot with distance.

The mesh itself is a parabola with a focus 10x its diameter away, and I'm using TU/Specular.

Isn't this reflection also "inverted"? Wouldn't the flag be upside down in the actual reflection?  Or this would be a reflection of a flagpole behind the camera? (I'm assuming the flagpole in the background is what's being reflected in the disk)

Also "Kerbal" is clearly readable on the flag -- this isn't a reflection, it's a portal to another demension :)

Edited by Beetlecat
Link to comment
Share on other sites

@Beetlecat Would need to see the flag itself to say whether it is correct or not but as an example of how reflections behave on curved (concave) surfaces go grab a shiny spoon and check it out. Basically, things get inverted so if the text on the flag as viewed normally is backwards, which is the case on one side from memory due to how the texture is mapped on to the mesh, then the reflection might well be correct.

The behaviour on stock relay dishes seemed correct from recollection of my testing. Though saying that, I have seen a mesh in game behave strangely...

Spoiler

769764D697F3E61BC05C00A8C818EF209C457007

 

Edit: Alright, I was bored, so with the aid of some kitchen utensils and a bank statement envelope, plus some awkward backward writing, here's a demo...

Spoiler

098148907271F81C7ED35D1C4FE66522B2118650

 

Edited by Manwith Noname
Link to comment
Share on other sites

I have a query, the PBR/Metallic surfaces reflect however are very dim/dark almost as if they were made out of a dark material. I had an idea that it maybe a conflict with another graphics mod say "Scatterer" but I maybe wrong on that as I am a novice at lighting. I have tried changing launch options but that hasn't seemed to work either.

Image: https://ibb.co/zSJQDDC

Edited by Count Vitehud VII
Link to comment
Share on other sites

@Count Vitehud VII Two simple things to check:

1) In the games graphics options, your render settings need to be "good" or higher. At least I think it was good, essentially, at lower settings the reflection probe is disabled.

2) If you're using more recent builds of TU and KSP (It does at least look like it from the ground textures), you also want to ensure the reflection update mode (not sure of exact wording but it's along those lines) is set to something other than off. On older builds where TU handled everything externally, you need to edit the general configuration file so reflections are enabled.

Link to comment
Share on other sites

On 4/30/2020 at 6:27 PM, Count Vitehud VII said:

I have a query, the PBR/Metallic surfaces reflect however are very dim/dark almost as if they were made out of a dark material. I had an idea that it maybe a conflict with another graphics mod say "Scatterer" but I maybe wrong on that as I am a novice at lighting. I have tried changing launch options but that hasn't seemed to work either.

Image: https://ibb.co/zSJQDDC

I fixed this by accident, here's how:

On the steam library, right click on KSP, choose properties, then click on "Set launch options" and paste this:

-force-d3d11

This will force the game to run on DirectX 11.
Link to comment
Share on other sites

2 hours ago, mateusviccari said:

-force-d3d11

This will force the game to run on DirectX 11.

As of KSP 1.8 KSP runs in D3D11 mode by default if it's available.  OpenGL is used elsewhere (OSX, Linux, older Windows)

Link to comment
Share on other sites

  • 2 weeks later...

Saw this business pop up in my log, don't know if it's meaningful:

Quote

[LOG 18:57:03.486] [AddonLoader]: Instantiating addon 'TexturesUnlimitedDebug' from assembly 'TexturesUnlimited'
[EXC 18:57:03.492] NullReferenceException: Object reference not set to an instance of an object
    KSP.UI.Screens.ApplicationLauncher.RemoveModApplication (KSP.UI.Screens.ApplicationLauncherButton button) (at <55ba45dc3a43403382024deac8dcd0be>:0)
    KSPShaderTools.Addon.TexturesUnlimitedDebug.Awake () (at <d05d146f0f32458d9a30cf17e61f35a8>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.GameObject:AddComponent(Type)
    AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
    AddonLoader:StartAddons(Startup)
    AddonLoader:OnLevelLoaded(GameScenes)
    AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
    UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)
[LOG 18:57:03.493] [AddonLoader]: Instantiating addon 'FlightAstrogator' from assembly 'Astrogator'

Log is here: https://www.dropbox.com/s/76bt110xt5vjhar/KSPLog_TUError.log?dl=0

Link to comment
Share on other sites

Got the same exception in log, I've also got magpie reflection mod and Tantares now in colors installed, this maybe related? Sometimes the Tantares parts miss their color selection gui until I reenter the VAB, I dunno if this is TU or TNIC? @Drakenex

ksp log: https://yadi.sk/d/RvZ1wRYJn1DH-A

ksp player: https://yadi.sk/d/cUHOxTk-0eT6vQ

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