mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-16 19:51:50 +00:00
Free Texture packing workflow.
This allows for an alternate workflow for texture and loading textures into the atlas allowing for more users to create more content for the game.
This commit is contained in:
parent
8c01cc23d0
commit
7675984e7e
@ -49,6 +49,7 @@ This project is based on ES5. Some ES2015 features are used but most of them are
|
|||||||
|
|
||||||
For most assets I use Adobe Photoshop, you can find them in `assets/`.
|
For most assets I use Adobe Photoshop, you can find them in `assets/`.
|
||||||
|
|
||||||
You will need a <a href="https://www.codeandweb.com/texturepacker" target="_blank">Texture Packer</a> license in order to regenerate the atlas. If you don't have one but want to contribute assets, let me know and I might compile it for you. I'm currently switching to an open source solution but I can't give an estimate when thats done.
|
You can use the Texture Packing python script in [res_pipeline](/res_pipeline) to generate packed textures. Default builds over [res_built/atlas](/res_built/atlas). Requires [free-tex-packer-cli](https://github.com/odrick/free-tex-packer-cli). Thanks to [Theisen1337](https://github.com/theisen1337) for intergrating.
|
||||||
|
|
||||||
|
|
||||||
<img src="https://i.imgur.com/W25Fkl0.png" alt="shapez.io Screenshot">
|
<img src="https://i.imgur.com/W25Fkl0.png" alt="shapez.io Screenshot">
|
||||||
|
|||||||
64
res_pipeline/Pack_images.py
Normal file
64
res_pipeline/Pack_images.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@author: Thomas Theis
|
||||||
|
June 2020
|
||||||
|
GNU General Public License v3.0
|
||||||
|
|
||||||
|
"""
|
||||||
|
os.system("free-tex-packer-cli --project .\shapez_size_100.ftpp")
|
||||||
|
os.system("free-tex-packer-cli --project .\shapez_size_75.ftpp")
|
||||||
|
os.system("free-tex-packer-cli --project .\shapez_size_50.ftpp")
|
||||||
|
os.system("free-tex-packer-cli --project .\shapez_size_25.ftpp")
|
||||||
|
os.system("free-tex-packer-cli --project .\shapez_size_10.ftpp")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def update_file( filename, match , replacement ):
|
||||||
|
"""
|
||||||
|
|
||||||
|
Update Line in file, where match.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Read File
|
||||||
|
with open(filename, 'r') as file:
|
||||||
|
# Read list of lines into a list object
|
||||||
|
data = list(file.readlines())
|
||||||
|
|
||||||
|
# Loop through lines in file backwards, (meta: I know the keyword is at the bottem of the file.)
|
||||||
|
for i in range(len(data) -1, 0, -1):
|
||||||
|
|
||||||
|
# Check for Match
|
||||||
|
if match in data[i]:
|
||||||
|
|
||||||
|
# Print data before updated.
|
||||||
|
print("\n\nUpdated the line:")
|
||||||
|
print(data[i])
|
||||||
|
print("New line:")
|
||||||
|
|
||||||
|
|
||||||
|
# Update data
|
||||||
|
data[i] = replacement
|
||||||
|
|
||||||
|
# Print New data
|
||||||
|
print(data[i],"\n\n")
|
||||||
|
|
||||||
|
# Break loop
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
# Re-Open file to write
|
||||||
|
with open(filename, 'w') as file:
|
||||||
|
|
||||||
|
# Write modified data.
|
||||||
|
file.writelines( data )
|
||||||
|
|
||||||
|
|
||||||
|
update_file("../res_built/atlas/atlas0_100.json", "image", ' "image": "atlas0_100.png",\n')
|
||||||
|
update_file("../res_built/atlas/atlas0_75.json", "image", ' "image": "atlas0_75.png",\n')
|
||||||
|
update_file("../res_built/atlas/atlas0_50.json", "image", ' "image": "atlas0_50.png",\n')
|
||||||
|
update_file("../res_built/atlas/atlas0_25.json", "image", ' "image": "atlas0_25.png",\n')
|
||||||
|
update_file("../res_built/atlas/atlas0_10.json", "image", ' "image": "atlas0_10.png",\n')
|
||||||
9
res_pipeline/Steps.txt
Normal file
9
res_pipeline/Steps.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
You need to download free-tex-packer-cli from node.
|
||||||
|
|
||||||
|
1. npm install -g free-tex-packer-cli
|
||||||
|
|
||||||
|
2. run the python script.
|
||||||
|
|
||||||
|
|
||||||
|
*** NOTE ***
|
||||||
|
If you see flashing on the edges of animation textures i.e. belts. Try changing the "alphaThreshold" (between 0 and 1.0) key in the *.ftpp files
|
||||||
38
res_pipeline/shapez_size_10.ftpp
Normal file
38
res_pipeline/shapez_size_10.ftpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"version": "0.6.5"
|
||||||
|
},
|
||||||
|
"savePath": "",
|
||||||
|
"images": [],
|
||||||
|
"folders": [
|
||||||
|
"C:/Users/tnt/Documents/GitHub/shapez_tnt.io/res_raw/sprites"
|
||||||
|
],
|
||||||
|
"packOptions": {
|
||||||
|
"textureName": "../res_built/atlas/atlas0_10",
|
||||||
|
"textureFormat": "png",
|
||||||
|
"removeFileExtension": false,
|
||||||
|
"prependFolderName": true,
|
||||||
|
"scale": 0.1,
|
||||||
|
"scaleMethod": "BICUBIC",
|
||||||
|
"filter": "none",
|
||||||
|
"exporter": "JSON (hash)",
|
||||||
|
"base64Export": false,
|
||||||
|
"tinify": false,
|
||||||
|
"tinifyKey": "",
|
||||||
|
"fileName": "pack-resultxx",
|
||||||
|
"savePath": "",
|
||||||
|
"width": 2048,
|
||||||
|
"height": 2048,
|
||||||
|
"fixedSize": false,
|
||||||
|
"powerOfTwo": false,
|
||||||
|
"padding": 0,
|
||||||
|
"extrude": 2,
|
||||||
|
"allowRotation": false,
|
||||||
|
"allowTrim": true,
|
||||||
|
"trimMode": "trim",
|
||||||
|
"alphaThreshold": 0.5,
|
||||||
|
"detectIdentical": true,
|
||||||
|
"packer": "MaxRectsBin",
|
||||||
|
"packerMethod": "BestShortSideFit"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
res_pipeline/shapez_size_100.ftpp
Normal file
38
res_pipeline/shapez_size_100.ftpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"version": "0.6.5"
|
||||||
|
},
|
||||||
|
"savePath": "",
|
||||||
|
"images": [],
|
||||||
|
"folders": [
|
||||||
|
"C:/Users/tnt/Documents/GitHub/shapez_tnt.io/res_raw/sprites"
|
||||||
|
],
|
||||||
|
"packOptions": {
|
||||||
|
"textureName": "../res_built/atlas/atlas0_100",
|
||||||
|
"textureFormat": "png",
|
||||||
|
"removeFileExtension": false,
|
||||||
|
"prependFolderName": true,
|
||||||
|
"scale": 1,
|
||||||
|
"scaleMethod": "BICUBIC",
|
||||||
|
"filter": "none",
|
||||||
|
"exporter": "JSON (hash)",
|
||||||
|
"base64Export": false,
|
||||||
|
"tinify": false,
|
||||||
|
"tinifyKey": "",
|
||||||
|
"fileName": "pack-resultxx",
|
||||||
|
"savePath": "",
|
||||||
|
"width": 2048,
|
||||||
|
"height": 2048,
|
||||||
|
"fixedSize": false,
|
||||||
|
"powerOfTwo": false,
|
||||||
|
"padding": 0,
|
||||||
|
"extrude": 2,
|
||||||
|
"allowRotation": false,
|
||||||
|
"allowTrim": true,
|
||||||
|
"trimMode": "trim",
|
||||||
|
"alphaThreshold": 0.5,
|
||||||
|
"detectIdentical": true,
|
||||||
|
"packer": "MaxRectsBin",
|
||||||
|
"packerMethod": "BestShortSideFit"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
res_pipeline/shapez_size_25.ftpp
Normal file
38
res_pipeline/shapez_size_25.ftpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"version": "0.6.5"
|
||||||
|
},
|
||||||
|
"savePath": "",
|
||||||
|
"images": [],
|
||||||
|
"folders": [
|
||||||
|
"C:/Users/tnt/Documents/GitHub/shapez_tnt.io/res_raw/sprites"
|
||||||
|
],
|
||||||
|
"packOptions": {
|
||||||
|
"textureName": "../res_built/atlas/atlas0_25",
|
||||||
|
"textureFormat": "png",
|
||||||
|
"removeFileExtension": false,
|
||||||
|
"prependFolderName": true,
|
||||||
|
"scale": 0.25,
|
||||||
|
"scaleMethod": "BICUBIC",
|
||||||
|
"filter": "none",
|
||||||
|
"exporter": "JSON (hash)",
|
||||||
|
"base64Export": false,
|
||||||
|
"tinify": false,
|
||||||
|
"tinifyKey": "",
|
||||||
|
"fileName": "pack-resultxx",
|
||||||
|
"savePath": "",
|
||||||
|
"width": 2048,
|
||||||
|
"height": 2048,
|
||||||
|
"fixedSize": false,
|
||||||
|
"powerOfTwo": false,
|
||||||
|
"padding": 0,
|
||||||
|
"extrude": 2,
|
||||||
|
"allowRotation": false,
|
||||||
|
"allowTrim": true,
|
||||||
|
"trimMode": "trim",
|
||||||
|
"alphaThreshold": 0.5,
|
||||||
|
"detectIdentical": true,
|
||||||
|
"packer": "MaxRectsBin",
|
||||||
|
"packerMethod": "BestShortSideFit"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
res_pipeline/shapez_size_50.ftpp
Normal file
38
res_pipeline/shapez_size_50.ftpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"version": "0.6.5"
|
||||||
|
},
|
||||||
|
"savePath": "",
|
||||||
|
"images": [],
|
||||||
|
"folders": [
|
||||||
|
"C:/Users/tnt/Documents/GitHub/shapez_tnt.io/res_raw/sprites"
|
||||||
|
],
|
||||||
|
"packOptions": {
|
||||||
|
"textureName": "../res_built/atlas/atlas0_50",
|
||||||
|
"textureFormat": "png",
|
||||||
|
"removeFileExtension": false,
|
||||||
|
"prependFolderName": true,
|
||||||
|
"scale": 0.5,
|
||||||
|
"scaleMethod": "BICUBIC",
|
||||||
|
"filter": "none",
|
||||||
|
"exporter": "JSON (hash)",
|
||||||
|
"base64Export": false,
|
||||||
|
"tinify": false,
|
||||||
|
"tinifyKey": "",
|
||||||
|
"fileName": "pack-resultxx",
|
||||||
|
"savePath": "",
|
||||||
|
"width": 2048,
|
||||||
|
"height": 2048,
|
||||||
|
"fixedSize": false,
|
||||||
|
"powerOfTwo": false,
|
||||||
|
"padding": 0,
|
||||||
|
"extrude": 2,
|
||||||
|
"allowRotation": false,
|
||||||
|
"allowTrim": true,
|
||||||
|
"trimMode": "trim",
|
||||||
|
"alphaThreshold": 0.5,
|
||||||
|
"detectIdentical": true,
|
||||||
|
"packer": "MaxRectsBin",
|
||||||
|
"packerMethod": "BestShortSideFit"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
res_pipeline/shapez_size_75.ftpp
Normal file
38
res_pipeline/shapez_size_75.ftpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"version": "0.6.5"
|
||||||
|
},
|
||||||
|
"savePath": "",
|
||||||
|
"images": [],
|
||||||
|
"folders": [
|
||||||
|
"C:/Users/tnt/Documents/GitHub/shapez_tnt.io/res_raw/sprites"
|
||||||
|
],
|
||||||
|
"packOptions": {
|
||||||
|
"textureName": "../res_built/atlas/atlas0_75",
|
||||||
|
"textureFormat": "png",
|
||||||
|
"removeFileExtension": false,
|
||||||
|
"prependFolderName": true,
|
||||||
|
"scale": 0.75,
|
||||||
|
"scaleMethod": "BICUBIC",
|
||||||
|
"filter": "none",
|
||||||
|
"exporter": "JSON (hash)",
|
||||||
|
"base64Export": false,
|
||||||
|
"tinify": false,
|
||||||
|
"tinifyKey": "",
|
||||||
|
"fileName": "pack-resultxx",
|
||||||
|
"savePath": "",
|
||||||
|
"width": 2048,
|
||||||
|
"height": 2048,
|
||||||
|
"fixedSize": false,
|
||||||
|
"powerOfTwo": false,
|
||||||
|
"padding": 0,
|
||||||
|
"extrude": 2,
|
||||||
|
"allowRotation": false,
|
||||||
|
"allowTrim": true,
|
||||||
|
"trimMode": "trim",
|
||||||
|
"alphaThreshold": 0.5,
|
||||||
|
"detectIdentical": true,
|
||||||
|
"packer": "MaxRectsBin",
|
||||||
|
"packerMethod": "BestShortSideFit"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user