public ImageId SaveImageHDR(Texture2D texture, EHDRTextureType type, int maxSize = -1, string path = null) { if (_texture2d2ImageID.ContainsKey(texture)) { return _texture2d2ImageID[texture]; } string format = ".png"; string[] pathes; if (path == null) { pathes = GetTextureOutPath(texture, format); } else { pathes = ExporterUtils.GetAssetOutPath(path, format); } var exportPath = pathes[0]; var pathInGlTF = pathes[1]; var newtex = GLTFTextureUtils.HDR2RGBD(texture); if (maxSize > 0 && (newtex.width > maxSize || newtex.height > maxSize)) { TextureScale.Bilinear(newtex, maxSize, maxSize); } byte[] content = newtex.EncodeToPNG(); return GenerateImage(content, exportPath, pathInGlTF); }
public ImageId SaveImage(Texture2D texture, bool hasTransparency, string path = null) { if (_texture2d2ImageID.ContainsKey(texture)) { return _texture2d2ImageID[texture]; } string format = ".png"; if (!hasTransparency && ExporterSettings.NormalTexture.opaqueType == ENormalTextureType.JPG) { format = ".jpg"; } string[] pathes; if (path == null) { pathes = GetTextureOutPath(texture, format); } else { pathes = ExporterUtils.GetAssetOutPath(path, format); } var exportPath = pathes[0]; var pathInGlTF = pathes[1]; var tex = TextureFlipY( texture, null, newtex => { var maxSize = ExporterSettings.NormalTexture.maxSize; if (newtex.width > maxSize || newtex.height > maxSize) { TextureScale.Bilinear(newtex, maxSize, maxSize); } } ); byte[] content = { }; if (format == ".png") { content = tex.EncodeToPNG(); } else { content = tex.EncodeToJPG(ExporterSettings.NormalTexture.jpgQulity); } return GenerateImage(content, exportPath, pathInGlTF); }