Advertisement
poikilos

coderskins.md

Apr 26th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.77 KB | None | 0 0
  1. # coderskins
  2.  
  3. Coderskins manages setting skins in Bucket_Game. However, it is also an asynchronous framework for overlaying multiple textures onto a player's
  4. character model. Coderskins is compatible with both rectangular and square (2-layer) skins and automatically detects the ratio. (Presumably in September
  5. 2021 releases or later:) It also allows applying a mask, badge, or other "decal" onto the second character layer or even over the armor layer.
  6.  
  7. Compatibility with 3d_armor:
  8. - A modified version of 3d_armor (presumably available in September 2021 or later releases of Bucket_Game) utilizes coderskins, so that version of
  9. 3d_armor should be used to ensure that mods don't fight over what textures to apply, and to ensure compatibility with both rectangular and square
  10. (2-layer) skins.
  11. - You can choose whether the decal is over or under the armor by way of the texture's resolution (See "Designing accessories")
  12.  
  13.  
  14. ## Designing accessories
  15. - Place items that are close to the body in any of the 2nd-layer area(s) of a square (64x64) image (search for 1.8 skin guide online).
  16. - Leave other areas (first-layer areas) transparent otherwise there will be visual glitches due to "z-fighting": glittering or flashing glitches.
  17. - Place items that should appear on top of the armor in a rectangular (64x32) texture. See
  18. [modern_armor/3d_armor_character.md](https://github.com/poikilos/modern_armor/blob/main/modern_armor/3d_armor_character.md) in Poikilos' modern_armor
  19. repo (Use the [64x32 template](https://github.com/poikilos/modern_armor/blob/main/modern_armor/projects/3d_armor_template-rect-64.png) but you can refer
  20. to the [oversized guide image](https://github.com/poikilos/modern_armor/blob/main/modern_armor/projects/3d_armor_template-rect-512.png) that is enlarged
  21. only to fit descriptive labels).
  22. - Put the word "badge" in the filename to guarantee that the texture will appear over the armor.
  23. - The armor covers the right appendages and several faces are mirrored on that side and forward on the left.
  24. - See the music badge code for an example of code that uses coderskins to make an accessory that isn't a 3d_armor accessory.
  25. - For 3d_armor accessories, use the 3d_armor documentation.
  26. - The texture string must be either a plain texture filename; or a filter where the second `^`-separated substring is a plain texture filename and the
  27. first substring contains "transparent" or "trans.png". This filename must start with the name of the mod where its textures directory resides (for
  28. example: "3d_armor_helmet_gold.png" residing in "3d_armor/textures/"), unless the texture is in "coderskins/textures" since that is the fallback
  29. directory. This is necessary since Minetest must know the full path of an image file to obtain its dimensions.
  30.  
  31.  
  32. ## Development
  33. This section explains how to add or maintain character meshes or coderskins code.
  34.  
  35. #### What are material IDs?
  36. An object can have multiple materials so that different parts of it can have different textures that do not intersect. This is useful for variety, for
  37. making square textures that apply to oddly-shaped objects, or for adding parts to a model when the texture is already filled (such as when backward
  38. compatibility or resolution prevents reworking its UVs to make space). The material stores UVs. The UV map describes which parts of the texture go on
  39. which parts of the object. Even if there is only one material, the texture or modified texture is in an ordered table in the entity. An entity's
  40. "textures" property stores entries that correspond to the material IDs in the model. Each entry is either a texture filename or modified texture string
  41. (See [Texture modifiers](https://git.minetest.org/minetest/minetest/src/branch/master/doc/lua_api.txt#L407) in lua_api.txt).
  42.  
  43. #### Apply a texture to a model
  44. Lua code using the Minetest API specifies which texture(s) to apply to the model (Minetest uses the material but not the texture filename if any in a 3D
  45. model file). The 3D model file specifies which material ID applies to which subset of faces on the model.
  46.  
  47. #### What material IDs does a character model need?
  48.  
  49. The character model in Bucket_Game is moving toward the following standard order of material IDs: `{skin_ratio_2, armor, wielditem, skin_ratio_1}`. In
  50. other words, armor will be included in the default character model file. No matter what you do, the character model would always be that in Bucket_Game
  51. (presumably September 2021 or later releases) (or `{skin_ratio_2, armor, wielditem}` in the stujones11 version of the model). In previous releases, the
  52. order is `{skin_ratio_2, skin_ratio_1}` (armor applied manually on top of the skin), so `skin_ratio_1` is being moved to the 4th ID to make room for
  53. compatibility with the three 3d_armor IDs (The 2nd and 3rd are 3d_armor specific).
  54.  
  55. However, the modified 3d_armor in Bucket_Game (as planned as of September 2021) uses coderskins, so as long as coderskins is consistent with whatever
  56. model is being used, the mod calling 3d_armor or coderskins will work (The API is backward compatible). To maintain backward compatibility with mods
  57. that do not utilize the 3d_armor API, keeping at least the first 3 elements the same is advisable. To be compatible with square skins and current plans
  58. for coderskins, the model must have 4 material IDs and be in the order above (A Minetest character model editing tutorial for Blender is at [Minetest
  59. with Minecraft 1.8 Square Textures - Player Character Model Editing](https://www.youtube.com/watch?v=eiG_IvsFQq4) on YouTube,
  60. [Odysee](https://odysee.com/@Poikilos:a/2021-09-02-Minetest-with-Minecraft-1.8-Square-Textures---Player-Character-Model-Editing:6) or
  61. [LBRY](https://open.lbry.com/2021-09-02-Minetest-with-Minecraft-1.8-Square-Textures---Player-Character-Model-Editing:68687ab1b4d5c4d68305eeee1785f09fa7eb93c2)).
  62.  
  63. There is "armor" in the model itself. Not conceptually, physically: Each of the 4 IDs is a physically different part of the model. No matter what you
  64. call it, it will always be `{skin_ratio_2, armor, wielditem, skin_ratio_1}`. If you say `textures = {foo, bar, bologna, cheese}`, the resulting behavior
  65. is:
  66. ```
  67. skin_ratio_2 = foo
  68. armor = bar
  69. wielditem = bologna
  70. skin_ratio_1 = cheese
  71. ```
  72.  
  73. The model itself has 4 IDs which are called "material IDs" in 3D graphics, and correspond respectively to the 4 indices of the textures table. In
  74. Blender, the material IDs are assigned to:
  75. - [1] classic-style body mesh & hat layer with right appendages being mirrored from the left (rectangular texture)
  76. - [2] armor (floats outside of body by about .03 Minetest meters (.3 Irrlicht units); and shield square in the player's left hand)
  77. - [3] wielditem (It is a square in the player's right hand.)
  78. - [4] The mesh (new Sep 2021) matches the specs of square skins: a copy of [1] that only uses the top half of the texture, and a new mesh that is only
  79. slightly raised from the surface in every direction, like the armor but less--about .02 meters (.3 Irrlicht units)
  80.  
  81. #### Automatic Square Skin Detection
  82. ID 4 is for a rectangular texture, but isn't used for overlays. When a square skin is used, it is used for ID 4.
  83. - When the texture ratio is 1:1 (64x64 square):
  84. - A transparent texture is placed on ID 1.
  85. - A 1:1 texture is placed on ID 4.
  86. - A 1:1 decal is placed on ID 2 (over the skin)
  87. - Only use the areas marked 2nd layer on a skin guide for the decal if the decal is square (See "ID 1 is not compatible with the ID 4." below).
  88. - When the texture ratio is 2:1 (64x32 rectangular):
  89. - A transparent texture is placed on ID 4
  90. - A 2:1 skin is placed on ID 1.
  91. - A 2:1 decal is placed on ID 2 (over the armor).
  92.  
  93. #### ID 1 is not compatible with the ID 4
  94. The reason that the first ID isn't used for overlays is that the layer isn't used when a player is using a square skin. It can't be since it is
  95. co-planar with the first layer portion of the square skin mesh. Co-planar visible parts generally would cause visible "z-fighting". The first is usable
  96. only for a skin and is: See "Automatic Square Skin Detection" below). The problem with using the armor layer for a mask is that is that it is raised too
  97. much. For that reason, a rectangular overlay would be good for things like a badge but not a mask.
  98.  
  99. Ways to allow decals on the first layer:
  100. - Convert all rectangular skins to square skins in real-time using a long series of transforms (See <https://imgur.com/a/hfaqL> for human-readable
  101. steps) and never use the first material ID (cut it down to a single plane or something to reduce the file size but don't delete it since the material ID
  102. order must be preserved).
  103. - Slightly inflate the ID 4 model's first layer so that it is just slightly higher than the material ID 1's, such as by 0.01 Blender units (0.001
  104. Minetest meters) to make ID 4 compatible with ID 1 (prevent z-fighting).
  105.  
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement