Solved Can I have multiple textures in a single skin?

Discussion in 'Mod Support' started by Deleted member 160369, Aug 3, 2016.

  1. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    I've been working on some improvements for this mod.

    Among the additions, I've planned the introduction of different paint schemes for the body as selectable skins.

    I have multiple shell skins working already (thanks to @mumboking), but I'd also like to have matching rims and other painted mechanical bits for each paint scheme.

    Can I have a set of multiple textures/mappings into a single skin?

    Like, say, the material for the outer rim (one of the parts I'd like to change according to the selected paint scheme) is currently defined like this:
    Code:
    singleton Material(CRDTest_KlaytonRim)
    {
      mapTo = "KlaytonRim";
      diffuseColor[0] = "0.0 0.0 0.0 1";
      diffuseMap[1] = "KlaytonRim_d.dds";
      specular[0] = "0.5 0.5 0.5 1";
      specularMap[1] = "KlaytonRim_s.dds";
      translucentBlendOp = "None";
    };
    
    One of the skins in materials.cs:
    Code:
    singleton Material("MMBody.skin_F150_body.MetalMulisha")
    {
      mapTo = "MMBody.skin_F150_body.MetalMulisha";
      diffuseColor[0] = "1 1 1 0.1";
      diffuseMap[0] = "/Shells/MetalMulisha_d.dds";
      dynamicCubemap = true;
      doubleSided = "1";
    };
    
    Is it possible to make it so that the selection of a shell skin from the parts selector also determines a specific mapping (to a differently colored texture) for this part?
     
  2. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Pretty please with sugar on top and a cherry...? ;)
     
  3. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,696
    You can have multiple layers in a texture (Up to 4).
    If layer 4 has trasparency, you would be to look at layer 3, and so on.
     
  4. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Thanks! :)

    I don't need multiple layers though, I need to apply textures to different parts of the vehicle: I'd like my skin to be constituted of a set of textures, the main paint design going over the body, plus multiple, color-coded ancillary parts.

    Is that even possible with the skin system?
     
  5. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,696
    Yep.

    Also, note that the this is wrong

    Code:
    singleton Material("MMBody.skin_F150_body.MetalMulisha")
    {
      mapTo = "MMBody.skin_F150_body.MetalMulisha";
      diffuseColor[0] = "1 1 1 0.1";
      diffuseMap[0] = "/Shells/MetalMulisha_d.dds";
      dynamicCubemap = true;
      doubleSided = "1";
    };
    
    singleton Material("MATERIAL.skin.SKINNAME")
    Do not change 'skin' to anything else. This is also specified in the skin tutorial.
    Basically, whatever material you want to change when you select the skin, just specify it in the 'MATERIAL' part. SKINNAME must be the same as the 'global skin name'.
     
    • Like Like x 1
  6. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Thought it could be working like that, but so far had no success with it.

    Now you've motivated me to find what's wrong with my materials and fix it.

    Thanks again! :)
     
  7. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    One more question for @Nadeox1

    Can I worship you as my divinity of choice from now on? ;)

    (Works perfectly, thanks a lot!)
     
  8. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Yet another question.

    Now I have multiple bodies sitting on the same chassis. Can I make the selectability of the skins dependent on the body?

    Example: I have multiple paint schemes for the original body of the truck selectable through the skin system, but just one for the new body I've recently added.

    There's a dedicated material for each body mesh, of course, but all the chassis parts are in common, and I wish to skin some of them to match the colors scheme of the body.

    So I've made a skin for the new body as follows:

    Code:
    singleton Material("MaxDBody.skin.Gold")
    {
      mapTo = "MaxDBody.skin.Gold";
      diffuseColor[0] = "1.0 1.0 1.0 0.3";
      diffuseMap[0] = "vehicles/CRDTest/Textures/MaxD/MaximumDestruction.png";
      dynamicCubemap = true;
      doubleSided = "1";
    };
    
    singleton Material("MaxDHeadlights.skin.Gold")
    {
      mapTo = "MaxDHeadlights.skin.Gold";
      diffuseColor[0] = "1.0 1.0 1.0 0.5";
      diffuseMap[1] = "vehicles/CRDTest/Textures/MaxD/MaxDHeadlights.png";
      specular[0] = "0.5 0.5 0.5 1";
      specularPower[0] = "50";
      translucentBlendOp = "None";
      doubleSided = "1";
    };
    
    singleton Material("KlaytonRim.skin.Gold")
    {
      mapTo = "KlaytonRim.skin.Gold";
      diffuseColor[0] = "0.0 0.0 0.0 1";
      diffuseMap[1] = "vehicles/CRDTest/Rims/KlaytonRim_Gold_d.dds";
      specular[0] = "0.5 0.5 0.5 1";
      specularMap[1] = "vehicles/CRDTest/Textures/Main/KlaytonRim_s.dds";
      translucentBlendOp = "None";
    };
    
    [*snip*]
    It works just fine, but I can't prevent it to appear in the list of skins available for the other body type. Then the common parts are changed accordingly, but the main body and the headlights (shell-specific) obviously fail to load.

    The header of the two bodies as follows:

    Original body:
    Code:
    "CRDTest_body_F150":{
    "information":{
    "authors":"SealedGecko",
    "name":"Ford F150 Fiberglass Body",
    }
    "slotType":"CRDTest_body",
    "slots":[
    ["type", "default", "description"]
    ["paint_design","CRDTest_skin_Grinder","Shell Design"{"coreSlot":true}],
    ],
    Alternative body:
    Code:
    "CRDTest_body_maxd":{
    "information":{
    "authors":"F2YS",
    "name":"Max-D Fiberglass Body",
    }
    "slotType":"CRDTest_body",
    "slots":[
    ["type", "default", "description"]
    ["paint_design","CRDTest_skin_Gold","Shell Design"{"coreSlot":true}],
    ],
    I tried having dedicated slot types for the paint designs ("paint_design" renamed as "paint_design_F150" for the first body, "paint_design_maxd" for the second), but then skins didn't work anymore, so I guess that's a fundamental keyword in the skin system.

    What can I do, other than having two separate vehicles?
     
  9. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Pretty PRETTY please with sugar on top and a cherry and whipped cream...? :D
     
  10. meywue

    meywue
    Expand Collapse
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    346
    Hey,

    sorry for the late reply.

    You can actually use the global skin system for this purpose.

    First of all add a new slot to the second body. This slot's name must start with the tag 'skin_' followed by the part name 'body' = 'skin_body'

    After that create a new jbeam part for the skin. This is how it looks like:

    Code:
    "F150_skin_body_alt": {
        "information":{
            "authors":"BeamNG",
            "name":"Alternative Body Skin",
            "value":50,
        },
        "slotType" : "skin_body",
        "skinName" : "f150_alt_skin",
      },
    Last but not least create a material for the skin. It should look like this:

    Code:
    singleton Material("xxyyzz.skin_body.f150_alt_skin")
    {
       mapTo = "xxyyzz.skin_body.f150_alt_skin";
       
        overlayMap[2] ="vehicles/f150/alternative/f150_alternative_skin.dds";
       diffuseMap[2] = "vehicles/f150/f150_c.dds";
        specularMap[2] = "vehicles/f150/f150_s.dds";
        normalMap[2] = "vehicles/f150/f150_n.dds";
        diffuseMap[1] = "vehicles/f150/f150_d.dds";
        specularMap[1] = "vehicles/f150/f150_s.dds";
        normalMap[1] = "vehicles/f150/f150_n.dds";
        diffuseMap[0] = "vehicles/common/null.dds";
        specularMap[0] = "vehicles/common/null.dds";
        normalMap[0] = "vehicles/f150/f150_n.dds";
        specularPower[0] = "128";
        pixelSpecular[0] = "1";
        specularPower[1] = "32";
        pixelSpecular[1] = "1";
        specularPower[2] = "128";
        pixelSpecular[2] = "1";
        diffuseColor[0] = "1 1 1 1";
        diffuseColor[1] = "1 1 1 1";
        diffuseColor[2] = "1 1 1 1";
        useAnisotropic[0] = "1";
        useAnisotropic[1] = "1";
        useAnisotropic[2] = "1";
        castShadows = "1";
        translucent = "1";
        translucentBlendOp = "None";
        alphaTest = "0";
        alphaRef = "0";
        dynamicCubemap = true;
        instanceDiffuse[2] = true;
        materialTag0 = "beamng"; materialTag1 = "vehicle";
    };
    As you can see the string in the materials.cs file ("xxyyzz.skin_body.f150_alt_skin") contains three parts which are separated by dots.

    The first part can be whatever you want.
    The second part needs to coincident with the part name.
    And the third part must be the same as the skinName defined in the jbeam part.

    I hope this will work out properly.
     
    • Like Like x 1
  11. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Thanks, I got it to work as suggested by @mumboking, which is basically the same solution you gave here. :)
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice