-
Notifications
You must be signed in to change notification settings - Fork 0
3D ship model generation
Spaceship generator resources:
https://www.artstation.com/artwork/8l69aE
https://www.youtube.com/watch?v=Gbn8XJOE2C8
https://www.youtube.com/watch?v=Crm6wKdDwtI
https://www.youtube.com/watch?v=AXPsZYpeKOA
--
Blender 2.8+
With PixeledAsteroid's procedural spaceship generator, adjust options to modify the ship behavior and/or add geometry to the group and it will be incorporated into the generated shape based on the existing parameters.
- Delete all but one of the ships you want to work on.
- Delete the sun light source.
- In Properties, Object Properties (framed orange square) tab, set location to 0,0,0 and scale to 30,30,30 (at least).
- In Properties, Modifier Properties (wrench) tab:
- Adjust modifiers and/or add geometry to reshape the ship.
- Disable the Mirror modifier on an axis for asymmetric ships.
- Add a Decimate modifier to reduce face count.
- In 3D Viewport:
- In Object Mode, in the Object top menu, Convert To -> Mesh in order to apply all modifiers quickly.
- In Edit Mode, select all (A) and open the UV menu (U). Select Unwrap. Then open the UV menu again and select Smart UV Project.
- In Object Mode, select the ship you're working on.
- In Shader Editor:
- In the top menu, Add -> Texture -> Image Texture without connecting it to a node. Click New to create a new image; name it anything. This is the bake destination image.
- Modify nodes to adjust texture properties. The HSL node near the top center of the graph allows you to adjust the diffuse texture's colors.
- Consider disconnecting the Metallic input from the Principled BSDF node, as it adds noise to the diffuse texture that doesn't pay off at <4k texture sizes.
- In Image Editor, select the bake destination image and resize it to the desired square texture size (ie. 2048x2048, 1024x1024)
- In Properties, Render Properties (white DSLR? icon):
- Set Render Engine to Cycles.
- Set Feature Set to Experimental. (optional)
- Under Bake, select Diffuse, set Influence to Color only. Then click "Bake". This takes a while; to experiment, resize the bake destination image to 256x256 for faster bakes.
- When it's done, in Image Editor, select the bake destination image. In the top menu, Image* -> Save As... and save the texture as the diffuse texture/
setTexture()
/base colors. Potentially post-process (lighten, add decals) in an editor. - Repeat "In Properties, Render Properties (white DSLR? icon):" for...
- ... Set Bake to Glossy, Influence to Direct only. Then click "Bake". When it's done, save the image in Image Editor as the specular texture/
setSpecular()
/shininess. Potentially post-process (grayscale, raise/lower lightness, reduce contrast) in an editor. - ... Set Bake to Emit. Then click "Bake". When it's done, save the image in Image Editor as the illumination texture/
setIllumination()
/emission. Potentially post-process (colors, brightness) in an editor.
- ... Set Bake to Glossy, Influence to Direct only. Then click "Bake". When it's done, save the image in Image Editor as the specular texture/
- Export the model: File -> Export -> OBJ
- Under Include, check only "Objects as OBJ Objects"
- Under Transform: 1.0 scale, auto path mode, -Z Forward forward, Y Up up (defaults)
- Under Geometry, check only "Apply Modifiers", "Write Normals", "Include UVs"; optionally check "Triangulate Faces"; this will increase file size/face/vertex count but reduce quads used by the generator.
You can put the exported OBJ and textures in the resources
directory of your EE install. These might load very slowly, in a blocking manner during gameplay. Alternatively, you can create a directory in the packs
directory, put the OBJ and textures in it (along with any other OBJs and textures), and run pack_gen.py
in the packs
directory with Python 2 (3 won't work yet). This creates a compressed .pack
file containing the model and textures.
In scripts/model_data.lua
, add the new model.
model = ModelData()
model:setName("medium-ship-1")
model:setMesh("medium-ship-1.model") -- if in a pack, or medium-ship-1.obj if in the resources directory
model:setTexture("medium-ship-1-diffuse.png")
model:setSpecular("medium-ship-1-specular.png")
model:setIllumination("medium-ship-1-emission.png")
model:setRadius(100) -- trial and error?
Wherever the object is defined (ie. shipTemplates_
... .lua
), set the new model:
:setModel("medium-ship-1")
Assuming this directory tree:
EmptyEpsilon
└── packs
└── medium-ship-1
├── medium-ship-1-illumination.png
├── medium-ship-1-specular.png
├── medium-ship-1-texture.png
└── medium-ship-1.obj
Then do:
cd EmptyEpsilon/packs
# Must have a Python 2.x installed
python2.7 pack_gen.py
This generates two files:
EmptyEpsilon/packs/medium-ship-1.pack
EmptyEpsilon/packs/medium-ship-1.packlist
And also outputs the packlist:
144 medium-ship-1-specular.png
455662 medium-ship-1-texture.png
6984900 medium-ship-1-illumination.png
12515419 medium-ship-1.model
Note that the .obj
file is now a .model
file.
Leave the .pack
file in the packs
directory. EmptyEpsilon will check this directory; you don't have to include subdirectories when referencing the mesh or textures in model_data.lua
or elsewhere.