3DModels:AssimpWorkflow: Difference between revisions

From Spring
Jump to navigationJump to search
Maddox (talk | contribs)
Maddox (talk | contribs)
Added 'Other File Format' section, linked to main text
Line 8: Line 8:
II. In Photoshop:
II. In Photoshop:


# Install the DDS export/import plugin. If you have an older Photoshop, you can use nVidia's older 32-bit release. If you use a newer Photoshop (tested on CC.2017) make sure you download this amazing open source plugin [http://fnordware.blogspot.com.br/2014/09/dds-plug-in-for-after-effects-and.html here]
# Install the DDS export/import plugin ([[3DModels:AssimpWorkflow#Other File Formats|Other image file formats]]). If you have an older Photoshop, you can use nVidia's older 32-bit release. If you use a newer Photoshop (tested on CC.2017) make sure you download this amazing open source plugin [http://fnordware.blogspot.com.br/2014/09/dds-plug-in-for-after-effects-and.html here]
# With the main (diffuse) texture opened, select the areas of the UV you want to have team color on. Select > Save Selection, click ok. A new 'Alpha 1' channel will be created and accessible from Photoshop's 'Channels' panel, usually docked as a tab next to 'Layers'.
# With the main (diffuse) texture opened, select the areas of the UV you want to have team color on. Select > Save Selection, click ok. A new 'Alpha 1' channel will be created and accessible from Photoshop's 'Channels' panel, usually docked as a tab next to 'Layers'.
# Use 'Levels' (Ctrl+L) to make sure you have no pure black or white in the Alpha Channel. First select the Alpha Channel from the Channels tab of the Layer panel. In the 'Output Levels' box (at the bottom) set the left field to 5 and the right field to 250.
# Use 'Levels' (Ctrl+L) to make sure you have no pure black or white in the Alpha Channel. First select the Alpha Channel from the Channels tab of the Layer panel. In the 'Output Levels' box (at the bottom) set the left field to 5 and the right field to 250.
Line 23: Line 23:
  <nowiki>
  <nowiki>
model = {
model = {
      radius = 25.0,
      height = 40,
      tex1 = "3dmeshname_tex.dds",
      tex1 = "3dmeshname_tex.dds",
      --tex2 = "3dmeshname_tex2.dds",
      --tex2 = "3dmeshname_tex2.dds",
Line 31: Line 33:


Done. Go test your new unit model and texture in-game.
Done. Go test your new unit model and texture in-game.
== Other File Formats ==
DDS is a native nVidia format, it holds all mipmaps and has many great image compression algorithms. Bear in mind that the image packed inside DDS can't be altered (like "flipped vertically") through commands in the model configuration .lua file.
If you don't want to use DDS for any reason, like not having support in your image app, make sure to use TARGA (.TGA) 32-bits. That's because, although ASSIMP also supports JPG, PNG, and BMP, the first has no support for alpha channels and the other two, for optmization reasons, may embed the alpha channel in a non-standard way. In Photoshop, until version CS6, PNG and BMP saved their alpha channels separately, after that version and up to the latest (CC.2017 at the time of this writing) it stores it as a "saved alpha channel". TARGA format always saves the alpha channel separately, as expected by ASSIMP.

Revision as of 17:22, 20 September 2017

Standard Assimp Workflow

This Workflow is provided for a standard 3D Modeling package using the Z = forward, Y = upwards convention, like Maya, Modo or Lightwave. You can also use Blender for ASSIMP, but it won't be covered here.

I. In the 3D Modeling Package:

  • Create your models as usual and export to DAE, after making sure all separate pieces share a single UV set. There shouldn't be more than one UV set in the file. All packages have a way to merge multiple UV sets as needed, bear in mind that in some of them you need to combine all objects first.

II. In Photoshop:

  1. Install the DDS export/import plugin (Other image file formats). If you have an older Photoshop, you can use nVidia's older 32-bit release. If you use a newer Photoshop (tested on CC.2017) make sure you download this amazing open source plugin here
  2. With the main (diffuse) texture opened, select the areas of the UV you want to have team color on. Select > Save Selection, click ok. A new 'Alpha 1' channel will be created and accessible from Photoshop's 'Channels' panel, usually docked as a tab next to 'Layers'.
  3. Use 'Levels' (Ctrl+L) to make sure you have no pure black or white in the Alpha Channel. First select the Alpha Channel from the Channels tab of the Layer panel. In the 'Output Levels' box (at the bottom) set the left field to 5 and the right field to 250.
  4. Click 'Save As', select DDS file format. Make sure to keep 'Alpha Channels' selected
  5. In the 'DDS Options' panel, select Format 'DXT5' (for main/team texture), keep 'Mipmap' and the Alpha Channel enabled (usually 'Alpha 1'). No need to mess with anything else, defaults are fine.

III. In Spring:

  1. Place your spanking new DDS texture in the '\unittextures' folder of your game/mod
  2. In your unit's .lua file (the UnitDef one), set object = "3dmeshname.dae", replacing the filename with your own model name of course. You need to add the .dae extension for Spring to load this file instead of searching for an .s3o file
  3. Place your .dae file in the objects3d folder
  4. Add a new .lua file to the objects3d folder, in our case "3dmeshname.dae.lua"
  5. Add the following code to it, editing the field values a needed. `tex2` is commented out, but your 2nd unit texture (for reflectivity/glow/clipping) may also be defined here.
	model = {
	      radius = 25.0,
	      height = 40,
	      tex1 = "3dmeshname_tex.dds",
	      --tex2 = "3dmeshname_tex2.dds",
	      midpos = {0,0,0},
	}
	return model

Done. Go test your new unit model and texture in-game.

Other File Formats

DDS is a native nVidia format, it holds all mipmaps and has many great image compression algorithms. Bear in mind that the image packed inside DDS can't be altered (like "flipped vertically") through commands in the model configuration .lua file. If you don't want to use DDS for any reason, like not having support in your image app, make sure to use TARGA (.TGA) 32-bits. That's because, although ASSIMP also supports JPG, PNG, and BMP, the first has no support for alpha channels and the other two, for optmization reasons, may embed the alpha channel in a non-standard way. In Photoshop, until version CS6, PNG and BMP saved their alpha channels separately, after that version and up to the latest (CC.2017 at the time of this writing) it stores it as a "saved alpha channel". TARGA format always saves the alpha channel separately, as expected by ASSIMP.