Page 1 of 1

Multiple textures

Posted: Thu Mar 14, 2013 7:59 pm
by Shipbuilder
Does anyone know if it is possible to produce a texture for a ship and then produce a series small texture file which could be randomly added to the main texture.

For example a ship texture could be created which would be applied to all versions of a particular ship. A choice of a series of ship serial numbers could then be randomly applied over the 'base' texture.

Re: Multiple textures

Posted: Thu Mar 14, 2013 8:08 pm
by Thargoid
Yes you can - either set the model up with two textures (one for the main bulk of the ship and a second specifically for the sections you want to change) and then swap the second one by script, or do something similar with a shader.

In the second case just add the two textures together, with suitable "holes" in each to match the other so that when added together you get a single complete texture. Then each ship would use the same shader but with different textures fed to it.

Re: Multiple textures

Posted: Fri Mar 15, 2013 8:13 am
by Griff
If you fancy trying this with shaders Jens wrote a decal shader that's perfect for this kind of task start here https://bb.oolite.space/viewtopic.php?p=42045#p42045 for the code examples (with lots of explanation) and continue on for the next few pages as more and more features get added in to the code.
I find it a complex thing to follow but I did (after much trial and error) manage to get the multiple decal version working as a function inside the shaders in my shipset, if you feel this might something you want to try in your oxp we could have a go transplanting this code into a new shader in your simple shaders request thread ( mind you the last time I tried to move this code into a different shader I ended up with decals that only appeared in sunlight, they vanished on the shadowed side of the ship :lol: I got things confused somewhere!)

Re: Multiple textures

Posted: Fri Mar 15, 2013 8:36 am
by submersible
See also some of the griff ship shader uniforms, particularly those with decals, and ones using 'randomUnitVector' . I too am looking into way of producing variant ships based on one original.

Investigate 'randomUnitVector' as a shader uniform . Not sure if 'randomFloat' or 'randomInt' exists but you could modulate something to be a 0-4 integer then use that as a mask in your shader to mix() between your default texture and another, in patterns defined by the r,g,b or a channel of a third texture.