Shadowmage

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

Recommended Posts

@Electrocutor Out of curiosity I dropped your stock retextures into a heavily modded game. There seems to be a clash with some mod parts which reuse stock models with their own texturing that prevents some parts from loading. There were only 7 instances of this problem across the MANY parts in the game - mostly to do with drills.

Example:

Quote

PartLoader: Compiling Part 'UmbraSpaceIndustries/KarbonitePlus/Parts/ORE_Drill/ORE_DRILL'
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

PartLoader: Encountered exception during compilation. System.NullReferenceException: Object reference not set to an instance of an object
  at PartLoader.ReplaceTextures (UnityEngine.GameObject model, System.Collections.Generic.List`1 textureNames, System.Collections.Generic.List`1 newTextures) [0x00000] in <filename unknown>:0 
  at PartLoader.CompileModel (.UrlConfig cfg, .ConfigNode partCfg, Single scaleFactor, .AvailablePart partInfo) [0x00000] in <filename unknown>:0 
  at PartLoader.ParsePart (.UrlConfig urlConfig, .ConfigNode node) [0x00000] in <filename unknown>:0 
  at PartLoader+<CompileParts>c__Iterator66.MoveNext () [0x00000] in <filename unknown>:0 

The Karbonite drill contains this section in its part config:

	MODEL
	{
	   model = Squad/Parts/Resources/RadialDrill/TriBitDrill
	   texture = TriBitDrill, UmbraSpaceIndustries/KarbonitePlus/Assets/TriBitDrill_GY
	   scale = 2,2,2
	}

 

For the moment I can just comment out the model lines in your config that clash (or not use your mod until it's finished) but I felt it was something you should be aware of.

Share this post


Link to post
Share on other sites

Hmm - I guess I shall stop porting my old colourizing plugin! only thing this doesn't do over everything else I was working on is let you recolour existing maps,  which is just fancy shader maths & some menus. And maybe decals, I think.

Share this post


Link to post
Share on other sites
1 hour ago, Van Disaster said:

let you recolour existing maps,  which is just fancy shader maths & some menus. And maybe decals, I think.

It actually does include recoloring shaders / support, though they are intended to be used with base-gray detail textures and 3-channel area masks (up to 3 independent sections per part).  Might be able to add a shader property that would control the expected base texture albedo, to allow for use of recoloring/tinting on existing parts.  Sounds like a worthwhile feature to add.

Decals, however, I'm much less familiar with.  Sounds like a 'textures' related feature, fitting with the theme of the mod, and I would be open to some collaboration or contributions if you were so inclined.  Probably more-so the functionality than including any specific resources; I would like to keep this to an API-only distribution.

2 hours ago, Aelfhe1m said:

@Electrocutor Out of curiosity I dropped your stock retextures into a heavily modded game. There seems to be a clash with some mod parts which reuse stock models with their own texturing that prevents some parts from loading. There were only 7 instances of this problem across the MANY parts in the game - mostly to do with drills.

Example:

[...snip...]

For the moment I can just comment out the model lines in your config that clash (or not use your mod until it's finished) but I felt it was something you should be aware of.

Please open an issue on the TexturesUnlimited repository regarding this.  It would appear to be something that will need to be handled at the plugin level, and likely not caused directly by the patches.

Share this post


Link to post
Share on other sites
4 hours ago, Aelfhe1m said:

@Electrocutor Out of curiosity I dropped your stock retextures into a heavily modded game. There seems to be a clash with some mod parts which reuse stock models with their own texturing that prevents some parts from loading. There were only 7 instances of this problem across the MANY parts in the game - mostly to do with drills.

Example:

The Karbonite drill contains this section in its part config:


	MODEL
	{
	   model = Squad/Parts/Resources/RadialDrill/TriBitDrill
	   texture = TriBitDrill, UmbraSpaceIndustries/KarbonitePlus/Assets/TriBitDrill_GY
	   scale = 2,2,2
	}

 

For the moment I can just comment out the model lines in your config that clash (or not use your mod until it's finished) but I felt it was something you should be aware of.

I've just started working on building a USI cfg for TU, so I'll probably run into this before long. If I had to make a random guess, I'd say that USI is perhaps hanging onto a material reference and TU replaces the mesh renderer's material with a new one.

Share this post


Link to post
Share on other sites
2 hours ago, Shadowmage said:

It actually does include recoloring shaders / support, though they are intended to be used with base-gray detail textures and 3-channel area masks (up to 3 independent sections per part).  Might be able to add a shader property that would control the expected base texture albedo, to allow for use of recoloring/tinting on existing parts.  Sounds like a worthwhile feature to add.

Decals, however, I'm much less familiar with.  Sounds like a 'textures' related feature, fitting with the theme of the mod, and I would be open to some collaboration or contributions if you were so inclined.  Probably more-so the functionality than including any specific resources; I would like to keep this to an API-only distribution.

I knocked up a bunch of shaders involving blending based on some input - originally it was the source albedo converted to HSV, but then I did something a bit more tricky involving masked areas based on greyscale ( which is "a lot" of possible colour areas - I can't say how many because it depends on the boundaries of the greyscale map and I've also forgotten exactly what I did! ).  I had some working prototypes and a plan but I was too ill to work on anything for a year, and it looks like you picked up most of what I wanted to do.

My paint tinting proof of concept demo ( this was in a usable state in 1.1, had a lot of the stuff you've implemented like only applying to certain parts of the model ) and there was some work to support other types of shader. I've got the shaders around somewhere or other. Bits that matter are somewhere around 1 min onwards I think.

Spoiler

 

Decals are just other textures you paint in an area on the model - just need to scale & place, and obviously probably limited to a single map for sanity. It would probably not be like players are expecting ( ie place anywhere on the craft ) but useful for things like text or aircraft markings which don't overlap parts.

Edit: I think this was a demo of one of the greyscale mask shaders - a selector for RGB channel & then colour areas dependent on greyscale level in the selected channel ( and iirc alpha mask for all of it ). There was some other stuff I wanted to check like instancing which I think would probably be good for KSP, but I'm well out of touch there.

Spoiler

28354531720_db18330af9_b.jpg

 

 

Edited by Van Disaster

Share this post


Link to post
Share on other sites
23 hours ago, Van Disaster said:

I knocked up a bunch of shaders involving blending based on some input - originally it was the source albedo converted to HSV, but then I did something a bit more tricky involving masked areas based on greyscale ( which is "a lot" of possible colour areas - I can't say how many because it depends on the boundaries of the greyscale map and I've also forgotten exactly what I did! ).  I had some working prototypes and a plan but I was too ill to work on anything for a year, and it looks like you picked up most of what I wanted to do.

My paint tinting proof of concept demo ( this was in a usable state in 1.1, had a lot of the stuff you've implemented like only applying to certain parts of the model ) and there was some work to support other types of shader. I've got the shaders around somewhere or other. Bits that matter are somewhere around 1 min onwards I think.

  Reveal hidden contents

 

Decals are just other textures you paint in an area on the model - just need to scale & place, and obviously probably limited to a single map for sanity. It would probably not be like players are expecting ( ie place anywhere on the craft ) but useful for things like text or aircraft markings which don't overlap parts.

Edit: I think this was a demo of one of the greyscale mask shaders - a selector for RGB channel & then colour areas dependent on greyscale level in the selected channel ( and iirc alpha mask for all of it ). There was some other stuff I wanted to check like instancing which I think would probably be good for KSP, but I'm well out of touch there.

  Reveal hidden contents

28354531720_db18330af9_b.jpg

 

 

That's some nice and interesting work also. 

Share this post


Link to post
Share on other sites

Updated release is available:

https://github.com/shadowmage45/TexturesUnlimited/releases/tag/0.9.0.3

Adds some additional shader properties, cleans up compatibility with the stock texture-replacement function on empty texture slots, and includes a new SubSurfaceScattering based solar panel shader.  Should be fully backwards compatible (e.g. should not break anything if updated in place).

Share this post


Link to post
Share on other sites

Mind if we add this to CKAN? You've already got one dependent mod trying to bundle this one, and there will probably be more before long. It would be cleaner to have one standalone entry they can all depend on.

Share this post


Link to post
Share on other sites

I am not puting anything on the end of my ksp exe to change the driver to gl 11 or anything. I am seeing everything okay... So I don't understand the warning in the OP.
This is amazing and my mid end pc doesn't even blink with this installed. Ksp is looking much nicer every day... Now I want a new graphics card for that clouds.... ( although I play with them installed anyways but low fps :( )
Anyway, Just want to pass by and say thank you so much for sharing this with everyone this is unbelievable.
I really am super excited to play with this much level of inmersion in my KSP universe...

Edited by Agustin

Share this post


Link to post
Share on other sites

I'm happy about anything that makes loading renderers and shaders easier.  I'm sure it was obvious to most others, but I frequently had a hard time figuring out exactly what was supposed to be loaded to get me beautiful looking environments and shading.

 

Share this post


Link to post
Share on other sites
14 hours ago, HebaruSan said:

Mind if we add this to CKAN? You've already got one dependent mod trying to bundle this one, and there will probably be more before long. It would be cleaner to have one standalone entry they can all depend on.

Sounds like a good idea for this mod, being an API and all.  Kind of important that others can bundle it correctly.

Please let me know if there is anything I need to do on this end.

Share this post


Link to post
Share on other sites

d5mV2rS.png

In the spirit of collaboration, may I ask why my solar panel's reflections seem to be in the opposite direction? It should reflect the dark of the night, or maybe even better the stars behind....

Maybe it's a known limitation, or planned fix, or maybe my installation is broken, or ultimately I just found a glitch...
You know, it's upside down or something... The dark side of the sky is reflected when I look fro below:

VBiLLS6.png

BHasically reflections see to be upside down in my modded install..

Edited by Agustin

Share this post


Link to post
Share on other sites
6 hours ago, Agustin said:

d5mV2rS.png

In the spirit of collaboration, may I ask why my solar panel's reflections seem to be in the opposite direction? It should reflect the dark of the night, or maybe even better the stars behind....

Maybe it's a known limitation, or planned fix, or maybe my installation is broken, or ultimately I just found a glitch...
You know, it's upside down or something... The dark side of the sky is reflected when I look fro below:

 

BHasically reflections see to be upside down in my modded install..

Would likely be related to the normals.  However, I did not create the stock patches, so no idea what is being applied to them or how.

Is it all reflections, or just those on the solar panels?

 

42 minutes ago, sardia said:

This isn't a rival to textureReplacerReplaced right?

Define 'rival'?

Different intended purposes, but with perhaps some feature overlap.  This mod adds PBR shaders and methods to replace textures.  The shaders happen to support reflections along with a ton of other features.

TRR offers skybox and visor texture replacement, which this mod does not.

Share this post


Link to post
Share on other sites

It is all reflections, not only those solar panels. they are big and plane, so they are easy to see what's going on I guess

Edited by Agustin

Share this post


Link to post
Share on other sites
9 hours ago, sardia said:

This isn't a rival to textureReplacerReplaced right?

I mean, you could have read the OP and seen that they do completely different things...

Share this post


Link to post
Share on other sites
8 hours ago, Shadowmage said:

Would likely be related to the normals.  However, I did not create the stock patches, so no idea what is being applied to them or how.

Is it all reflections, or just those on the solar panels?

The normals would only be light vector, and you can't make the blue channel be negative, only red and green. Regardless of whether Squad made the normals correctly or not for the panels, it should not be showing the inverse plane. Perhaps this is related to the bug that removes the skybox?

Share this post


Link to post
Share on other sites
1 hour ago, Electrocutor said:

The normals would only be light vector, and you can't make the blue channel be negative, only red and green. Regardless of whether Squad made the normals correctly or not for the panels, it should not be showing the inverse plane. Perhaps this is related to the bug that removes the skybox?

I'm pretty sure you can get the normals to face backwards through a normal map. RGB =  0.5, 0.5, 0 would be a vector with components 0, 0, -1.  Whether Unity supports this or not is unknown, as it does some weird swizzling with its normal maps.

Which is why I was asking if it was all parts or just the solar panels.  I should have been more specific -- I need to know if the 'backwards reflection' problem exists on a stock part that actually has a real NRM texture, or if it is just on those parts using the run-time provided (which I could have specified incorrectly, not sure what Unity expects at runtime).  More to the point, I do not see this problem on SSTU's parts that all use their own proper normal maps.  The reflections all point the proper direction.

If you assign a proper (flat) NRM map to those solar panels does the problem exist?  (this is what I really need answered; will tell me if it is a problem with the mesh, the textures, or a more far-reaching problem with the refl. calculations)

Share this post


Link to post
Share on other sites

Very strange... when I try the solar panel parts in my install there are no issues -- the reflection direction is properly set.  This is using the 'stock patches' from earlier in the week though.  Going to try updating to the latest to see if it might be something there.

Properly reflecting the sun, right where it should be:
jYryV0E.png

Properly reflecting Kerbin, also right where it should be:

1MAAq5e.png

 

Edit:  One more idea to try.  @Agustin appears to be running DX9, and it would absolutely not surprise me if had issues other than the mip-map/cubemap blurring problems..

Edit2:  No change under DX9 with any of the stock solar panels.  All appear to reflect the proper directions, regardless of orbit altitude or inclination.

 

@Agustin is that an otherwise stock craft file that you could share? (any part-mods used on it?)

Edited by Shadowmage

Share this post


Link to post
Share on other sites

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

Edited by Electrocutor

Share this post


Link to post
Share on other sites

@Electrocutor Very nice.  Glad that shader is working, as I completely forgot to do any testing on it.

Something I'll still have to look into will be adding support for texture replacement for IVA use (props, base IVA model, etc).  Might work as-is, but have never tried it...

Share this post


Link to post
Share on other sites
2 hours ago, Shadowmage said:

@Electrocutor Very nice.  Glad that shader is working, as I completely forgot to do any testing on it.

Something I'll still have to look into will be adding support for texture replacement for IVA use (props, base IVA model, etc).  Might work as-is, but have never tried it...

The IVA is actually much easier because IVA uses a fake sun (Unity light source) so you don't have to worry about pulling in the fake lights from PQS.

Share this post


Link to post
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.