Jump to content

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


Shadowmage

Recommended Posts

Just now, bcink said:

Is that code only or does that actually adjust the texture files?

Code only.  But it requires very specialized texture inputs + some config files -- the diffuse/spec/met textures have to be authored specifically for it, you can't use regular textures for it.  More than willing to guide you through the process if truly interested, but I would caution that it is a bit 'complex', and not without some limits on what it can do.

(hoping to have a solution 'soon' that will allow for using standard textures while still allowing for proper recoloring; still will require some additional setup, but at least it would all be config/patch based rather than requiring new textures)

Just now, dundun93 said:

Does Textures unlimited add shine to DCK?

TU doesn't add anything to anything.

Seriously, this mod does absolutely nothing by itself.

Link to comment
Share on other sites

2 minutes ago, dundun93 said:

Does Textures unlimited add shine to DCK?

I haven't tried it yet, but DCK swaps the texture using Firespitter, or their version of same, it is possible TU will work with it, if there is a config for the part, like Electrocutors Stock parts configs, but it may mess up, or look better than the stock parts.

Link to comment
Share on other sites

Some very early work on a system that would allow for proper recoloring of existing textures.  First step is figuring out the math to extract the details from any given texture.  So far I have something mostly working using HSV for color specifications -- taking an input texture and a list of colors + ranges, and outputting a 'base color map' of the original texture sans details.

This is a random texture from KerbalFoundries (don't even know what part it goes to...just picked one at random to start working on things).  As can be seen there is still some work to do in setting up the config (adjusting the base/min/max ranges), and likely even a change to how the configs are specified.

Input:

Tr7ZgLz.png

Output:

hDEjiTY.png

Config:

BASEMAP_CREATE
{
    texture = test.png
    
    //brown wheel color stuff
    COLOR
    {
        base = 85, 74, 61
        //hsv = 33, 28, 33
        hueRange = 8
        satRange = 20
        valRange = 20
    }
    
    //light gray colored stuff
    COLOR
    {
        base = 144, 144, 144
        hueRange = 5
        satRange = 20
        valRange = 20
    }
    
    //dark gray colored stuff
    COLOR
    {
        base = 58, 63, 66
        // 220, 4, 28
        hueRange = 60
        satRange = 20
        valRange = 20
    }    
}

Essentially it works like the 'area select by color' tools in gimp/PS (the magic wand ones) -- find all colors in a texture that are within a specified range of another specified color, and replace it with another output color as specified in the config.  So color select + flood fill with a replacement.

What this does is to give me a clean representation of the textures sans detailing.  Some math in the shader will compare this 'base color map' with the existing diffuse texture to extract the details from the diffuse texture, and then add (or subtract) those details back onto whatever the user specified color is for that masked portion.  So the output color for any given pixel will be exactly what the user set in the GUI + whatever the details are (minor highlights/shadows/noise).

 

All still very early/WIP.  None of the code is even in TU at the moment, having been written as an external stand-alone console application to allow for faster development and restarting.  Ideally this code would run inside of a shader, but I'm not sure how feasible that would be.  Might have to resort to startup-time texture manipulation and dynamic texture creation of the base color masks, caching the created textures to disk, and feeding them into the shader to simplify its internal math.

Its still not a 'hands-off' process -- you still need to get dirty and setup the configs for every texture that you would want to be able to recolor.  And that will likely require opening up the original textures to examine color values.  But you wouldn't have to -create- any new textures, or ship any extra textures with your mods/etc (just write the configs).  Would also be fairly slow (you all remember the ATM days of waiting for -hours- for it to do its first compression run?  Yeah, that kind of slow).

Ideally though -- this would remain as a stand-alone application that one would use to create the base map textures in advance  You would then be able to use the stand-alone app to make the textures, do any minor fixes by hand that are needed (inevitable), ship the base-map textures with your mod, and just feed the base-map texture into the recoloring shader through config setup.  So a 'recoloring mod' that added recoloring to stock parts would ship only a bunch of base-color-maps + configs to activate them.  For proper metallic/specular support, spec/met base-color maps would also need to be created and provided (if that information was not already correct in the original textures).

 

And this all comes back to -- it is going to be impossible to recolor existing textures properly without some additional data input into the system.  You have to be able to extract the details out of the existing diffuse texture, and there is no singular, unified, 100% reliable method to extract details from existing textures in an automated fashion.  Some form of human intervention/setup/work will be required.

Just need to pick what is going to be the easiest method to generate and supply this data:

  1. Supply configs and calculate the base colors at runtime (either cache to file, or run all in the shader).  Potentially slow, and will likely have problems with complex/busy input textures.
  2. Supply discrete base-map textures, created by hand either through PS/GIMP, or created semi-automatically by the stand-alone program I'm currently writing/using and cleaned up manually.

Uh... that's pretty much it for options.  Pick one.

#2 will likely be present regardless -- it is the only proper way to do it.
#1 is a bit more undecided.  Certainly possible, but I'm not convinced of the benefits given the inherent limitations.

 

Link to comment
Share on other sites

Further to some previous posts I decided to try something and thought it might be fun to play a little game...spot Jeb's reflection...

Spoiler

3B387BB3FCB4230FC4B84BC0C0DDA025F9AECA3B

P.S. Yes, I read the OP but given the wording I thought this might be worth posting.

 

Edit:

I wasn't going to post the answer right away but....this is a spoiler alert, the following picture shows where Jeb's reflection is...

 

Edited by Manwith Noname
Link to comment
Share on other sites

This is not a mod but an API, it doesn't do anything by itself. You either use it for your own mods that you build, or check out what people like Electrocuter are doing with it to retexture stock or existing mods.

Edited by Jimbodiah
Link to comment
Share on other sites

btw how do i use this mod? can't figure out

8 hours ago, Jimbodiah said:

This is not a mod but an API, it doesn't do anything by itself. You either use it for your own mods that you build, or check out what people like Electrocuter are doing with it to retexture stock or existing mods.

 

Link to comment
Share on other sites

@[INDO]dimas_1502

If you have not realised by now, there's a post one up from yours that should be enough to explain everything. If not....

1) Download and install Textures Unlimited. (You appear to have done this already)

 

2) Go to the thread linked above and download Electrocutor's "Stock" config from the top of the table in the opening post. The file can be placed anywhere inside the GameData folder of KSP. Feel free to load up the game at this point and marvel at the glorious look of the stock parts.

3) From the same thread above, download the "Stock - Porkjet" config in the opening post. Again, place it anywhere inside the KSP GameData folder, though I do suggest for now you could create a folder in GameData called something along the lines of "Electrocutors Textures Unlimited Configs"...or whatever you want that makes sense to you so you know where to find them. Again, feel free to load up the game and throw some parts in the editor. Right click on them and change the texture sets around so you can see and understand what that config does.

4) Follow the link in my post above and download my mask pack. There are instructions similar to this in that post that outline, hopefully clearly enough, how to install the masks and configs I have made to work alongside Electrocutors work.

 

Good luck. Have fun.

 

Edit: Sorta ninja'd

Edited by Manwith Noname
Link to comment
Share on other sites

I have a problem with TU. I use some .cfg of Electrocutor and other users and some of my own .cfg. But there are a bug with all configs. The Parts have reflections but in direct sunlight they are very dark. Happens with DX11 and OpenGL (I know the bug of DX9).

Here are some Pics of NSS/Octosat-Parts and DECQs Spaceshuttle (made a config for the radiators).
https://imgur.com/a/rm0sq
In VAB and at Launchpad the reflections work but not in space.

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