Open RichardDastardly opened 8 years ago
This sounds very interesting. Geometry stuff is quite easy to modify independently so no need to worry about that (otherwise supporting both types would be a nightmare...). Just a matter of working out the maths
Not so sure about the patterns thing, that just sounds like bottled UI pain (I'm all for more patterns, that's relatively simple, but colourisable zones to that extent just sounds like a PITA if you ask me. Obviously not the target audience :P)
The pattern selection isn't really any different to the AO layer Bac9's shader does - I'm passing a colour to the shader to pick an RGB channel as a pattern, and then some maths to decide what colour to put where based on grey levels. Writing paint colours to the shader just means sending an array ( which is a slight pain in 5.2, 5.4 you will be able to just send an array as one ), the UI... well, yes.
I actually have a partmodule (ModuleTintable in my repo, at any given moment it might be in a working state - this is my "learn C# & Unity" thing ) to test out shader stuff, I haven't managed to get round to learning more complicated UI stuff than right-click menus yet - I was looking at U5 UI stuff & wondering how much to use directly or whether there's something KSP specific on top. I'll attempt to prototype as much as possible, anyway.
https://flic.kr/p/KcAoqy demo with temporary colour pickers.
ye, it's more the UI I'm concerned about. If you have an idea of how that could be a useable UI I can probably make it work in KSP (or atleast have an idea of where to start). Although I think I need to understand a bit more about how your shader works first and have the current functionality finished...
My current understanding:
UI Stuff: So assuming, the above assumptions are correct, patterns can be done with a single integer parameter and a bit of bit shifting and masking internally. That would leave essentially identical to how the B9 material is selected. Doesn't matter if they aren't continuous, just need to maintain a lookup table in that case.
That leaves the colour selection. I favour just having an array of coloured buttons to select the edit colour ( Should be extendable to large numbers of colours).
That would result in one pattern select, one select array, and one colour picker (only 1 extra row over the current appearance groups)
So, yep - pretty much what you were thinking. I still need to learn U5 UI though :P my own partmod has to handle blending existing textures which is a whole bunch of other sliders.
The shader demo uses 4 colours because I didn't want to write actual code to handle setting colours just to mess with it in the inspector. U5.2 writes arrays to shaders by having a single property for each array entry; thankfully 5.4 handles passing arrays properly.
ok, floats rather than bytes (I couldn't recall what Unity used for colours...) and a few extra colour variants but otherwise nothing extreme.
I think I need to look at modularising the appearance
Yeah, I can't actually think of any extreme things. Swapping actual textures, and possibly loading decals in ( note: I haven't written a shader which can load decals :P but it's only a couple of extra lines in the shader ) are the only future features I can think of. The latter would need some UV offset& scaling sliders, but let's worry about that some other time like when I've written support for it...
One thing from my own work I noticed is using www to load assets means you can use any name for a bundle, so if you chop the .ksp extension off you won't end up loading bundles twice. Also means you can unload unused stuff finally... modularising the appearance might not be necessary if the UI code can handle multiple UI versions, can just do a lot of them & load the one you want later.
removing the extension is probably a very good idea (infact, I should probably write my own exporter, but that can be some other time...) Just be very careful with unloading the bundle if it's for public work. You can do it immediately on 32 bit windows, but 64 bit requires a 25 frame wait here, and I don't know if that changes by machine or what linux/mac versions require
Seems not to need a timeout for shaders ( I test on 64bit everything ), but I did start writing a delay into my bundle manager anyway. Should probably make a comprehensive test for everything you can put in a bundle, really.
I did steal some code from the unity forums to build bundles, but the loader doesn't seem to like 'em.
OK, going to sit on this until 1.2 is actually out - I need to do some fiddling with PBR shaders & need a stable platform for that. We would need new assets, so I'd probably better deconstruct Bac9s at some point ( there is a bug in his control surface model I've been wanting to fix forever anyway ).
We should have a chat about shaders sometime, I have one somewhat like Bac9s, but it doesn't require messing with vertex data & supports up to 255 different colour areas per pattern ( and three switchable patterns ) if you're sufficiently mad. Can imagine the UI issues :p
Also I kinda want to work on a proc wing with changeable profiles which means doing a much more complex mesh, so if the mesh shaping part ( and FAR aero data ) can be modular that'd save a bunch of effort down the road. The other part of that was being able to slice a wing & have two parts, which ... is a lot more complicated than it sounds.
Call it ShapeWings or something for now, I'm sure the perfect name is out there somewhere.