meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
texturepacking [2020/08/10 10:45] – croft | texturepacking [2023/04/03 18:39] (current) – steph.jorgensen | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Texture | + | ======Texture |
During [[expgame|game format exporting]], | During [[expgame|game format exporting]], | ||
Line 5: | Line 5: | ||
The Modeler comes with a number of different texture packers for various engines, depending on which version of the Modeler you are using. You can edit these or even make your own if you need something different. | The Modeler comes with a number of different texture packers for various engines, depending on which version of the Modeler you are using. You can edit these or even make your own if you need something different. | ||
- | {{ ::texture_packing.png? | + | {{texture_packing.png? |
Line 11: | Line 11: | ||
All texture packers are stored on disk in the <apps install>/ | All texture packers are stored on disk in the <apps install>/ | ||
+ | |||
+ | | < | ||
+ | | | ForceTextures - Sets whether a texture is to be written even if it is empty or a solid color. This will make a very tiny texture instead of full-res to save of texture memory. If false, the color will be saved into the mesh, if possible.|| | ||
+ | |||
+ | | < | ||
+ | | | Type - The type of data to write to disk or in the mesh/ | ||
+ | | | MipGenerationFlag - Can be " | ||
+ | | | Skip - Skip this texture entirely. Omitting a Texture tag will also skip it. | | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | The shader file is similar to a [[rendermodes|render mode]] shader, where you are writing a single function called by a bigger shader. However, for texture packing you will implement a TexturePacking() function whose input and output is a little different. The input consists of all of the maps from the material, already with texture/ | ||
+ | |||
+ | |||
+ | struct STexturePackingInput | ||
+ | { | ||
+ | float3 m_vColor; | ||
+ | float m_fOpacity; | ||
+ | float3 m_vNormal; | ||
+ | float m_fGloss; | ||
+ | float3 m_vSpecularColor; | ||
+ | float m_fMetallic; | ||
+ | float3 m_vSubsurfaceColor; | ||
+ | float m_fSubsurfaceAmount; | ||
+ | float m_fAmbientOcclusion; | ||
+ | float m_fHeight; | ||
+ | float3 m_vCustom; | ||
+ | float3 m_vCustom2; | ||
+ | | ||
+ | float m_fNoise; | ||
+ | | ||
+ | bool m_bTwoSided; | ||
+ | bool m_bAtlas; | ||
+ | bool m_bBillboards; | ||
+ | | ||
+ | float2 m_vTexcoord; | ||
+ | }; | ||
+ | |||
+ | |||
+ | The output structure simply contains all of the possible RGBA outputs (up to 16). The packing process tries to be as smart as possible when writing out the textures. If you only write .r, you will get a grayscale/ | ||
+ | |||
+ | struct STexturePackingOutput | ||
+ | { | ||
+ | float4 m_vTexture0; | ||
+ | float4 m_vTexture1; | ||
+ | float4 m_vTexture2; | ||
+ | float4 m_vTexture3; | ||
+ | float4 m_vTexture4; | ||
+ | float4 m_vTexture5; | ||
+ | float4 m_vTexture6; | ||
+ | float4 m_vTexture7; | ||
+ | float4 m_vTexture8; | ||
+ | float4 m_vTexture9; | ||
+ | float4 m_vTexture10; | ||
+ | float4 m_vTexture11; | ||
+ | float4 m_vTexture12; | ||
+ | float4 m_vTexture13; | ||
+ | float4 m_vTexture14; | ||
+ | float4 m_vTexture15; | ||
+ | }; | ||
+ | |||
+ | =====Custom example===== | ||
+ | |||
+ | In this example texture packer, we will write color and opacity into one texture, and normal and gloss into another. Our game requires normal maps with green flipped the other way from the SpeedTree Modeler (which is a common change to make). | ||
+ | |||
+ | The XML file that describes this texture packer should be saved into a file called " | ||
+ | |||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | |||
+ | The shader itself should be saved into a file called " | ||
+ | |||
+ | void TexturePacking(STexturePackingInput sInput, inout STexturePackingOutput sOutput) | ||
+ | { | ||
+ | // color/ | ||
+ | sOutput.m_vTexture0 = float4(LinearTosRgb(sInput.m_vColor), | ||
+ | | ||
+ | // normal/ | ||
+ | sInput.m_vNormal.b = 1.0 - sInput.m_vNormal.b; | ||
+ | sOutput.m_vTexture1 = float4(sInput.m_vNormal, | ||
+ | } | ||
+ | |||
+ | |||
+ | Once these files are saved, the new " | ||
+ | |||
+ | {{texture_packing_gui.png? | ||
- | =====Custom Example===== | ||