New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fairings do not retain settings #40
Comments
This is caused by stock code. The stock code recreates the materials on the fairing at some point after it is loaded / after the texture switch is run. I'll look into it, but no guarantee I'll be able to solve it for TU. I have it working in SSTU, but only with a custom module that interacts closely with the fairing module/code... something I don't really want to implement in TU as it very ugly. This might have to wait until KSP 1.4 and the stock texture switch and fixes to the fairing module. Still might not be possible even then if they are still using the same material re-creation BS in the stock code. |
Does it only re-create the material once or at multiple times during flight? If just once, couldn't you just fire off a time-delayed re-paint? |
In flight scene -- just once if I remember correctly. Could be accommodated, but would still be a dirty hack that only adds clutter to the code. The current SSTU code re-applies the texture set + colors during the Start() method in the fairing-manipulating PartModule; (what I wouldn't give for some consistency in KSP code, where hacks aren't necessary because there are proper hooks...) A bigger problem is in the editor. Every time the user adjusts the fairing, the stock code recreates the materials (more than one), and they all need to be re-adjusted. And the real problem is that the only way I found to consistently adjust the materials on the fairing relies on explicitly messing with data from ModuleProceduralFairing -- obviously that cannot be a general solution as it is not going to work anywhere else or for any other part-modules. https://github.com/shadowmage45/SSTULabs/blob/master/Plugin/SSTUTools/SSTUTools/Module/SSTUResizableFairing.cs#L250-L269 So I guess the real problem is that I simply don't want to add stock-fairing-specific texture set handling code. I don't believe it should be necessary, and believe that hard-coding like that is about as 'bad' as you can get in programming. I'm willing to consider alternate solutions if some are provided, but I do not have time to be developing them myself right now. |
Hmmm... there might be an easy way to solve this.... A Fairing-specific texture switch module. (well... still a ton of work, but easier than trying to work around the stock inconsistencies, and more desirable from a functional perspective) |
Looking into this problem more -- at least part of it is likely being caused by an incomplete texture set definition. You need to explicitly specify the transform/mesh names for the fairing panels, and also explicitly specify the transform name for the base mesh. (this is to prevent the bleeding problem you describe above, where changes to one effect the other) Can I see the configs that you are using to adjust the fairing parts? The other portion of this, is that yes, some additional code will need to be put in place to update the fairing-panel materials during Start() (or later). |
@Electrocutor I think I have a solution in place for this -- do you have a config file that I could use to test the setup and solution? |
@REFLECTION_CONFIG[default]:NEEDS[TexturesUnlimited] { KSP_MODEL_SHADER {
} Also KSP_TEXTURE_SET {
} @part[fairingSize1,fairingSize2,fairingSize3] {
} |
Thanks, will see if I do indeed have this fixed tonight. |
Made a bit more progress last night, and have something in place that allows for setting the shader on the fairing panels. It doesn't set textures, or shader properties, just the shader itself. Going to do a bit more work on it to see if I can adapt it to also load shader properties. The module will point towards a texture-set, but it will only be able to effectively use the non-texture shader properties (e.g. attempts to use it to set textures will be unsupported; use the stock part-variant system for texture manipulation). Will aim to get these all wrapped up and ready for a release shortly after 1.4.3 is made available. There are a few config-node related fixes coming in stock code with that update that I really need to have in place. |
Have updated this to read from a texture set, and use a specific MATERIAL block for the fairing panels. Both the texture-set-name and material-block-index need to be specified in the config file for the new module. This setup allows for TU code to set shader and shader properties (e.g. _Metal), while still allowing the stock code to manipulate the textures. Will do some further testing and validation on this tonight, and probably call it 'solved'. At some point in the future I'll write the full Fairing-Texture-Switch module, but for now stock-based fairings will have to use the stock system for texture switching. |
New module based solution is verified to work in all tested cases.
It has the following limitations:
Simple Config example:
Complex config example - applies metallics to the base and structure, and non-metallics to the panels.
Will be available with the next update. |
Would it not be a simpler solution to just search for the Material used by the fairing and alter it? The meshes are created on-the-fly, but I believe the material used on it is static, is it not? It is named "FairingsMat" |
I do adjust that material (and the one for the cones as well); only it is not possible to adjust it for an already existing part before the panels are created. The material does not exist in the model itself, so I cannot adjust it as part of the model-database. Example: Edit: |
When setting a fairing part to any PBR shader along with properties, the visual is shown to have affected the fairing as well. For example, set the fairing part to metallic mirror and the fairing itself also becomes a mirror; but when changing scenes, the fairing loses its visual change.
From my perspective this can only mean that the code firing when switching between texturesets for KSPTextureSwitch is different from the code that fires during scene load, and the latter is missing something that allows the fairings to be included.
The text was updated successfully, but these errors were encountered: