Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
ResourceImporterSVG
继承: ResourceImporter < RefCounted < Object
将 SVG 文件作为自动缩放纹理导入,用于 UI 元素和 2D 渲染。
描述
该导入器导入 DPITexture 资源。另见 ResourceImporterTexture 和 ResourceImporterImage。
属性
|
||
|
||
|
||
|
||
|
||
|
属性说明
纹理缩放。1.0 是原始 SVG 大小。值越大得到的图像越大。
Dictionary color_map = {} 🔗
设置后,会根据 Color-Color 映射对纹理中的颜色进行重映射。
如果为 true,则对 SVG 源码使用无损压缩。
bool fix_alpha_border = false 🔗
如果设为 true,它会在从透明到不透明的过渡区域,填充周围相同颜色的像素。对于使用双线性过滤(bilinear filtering)显示的纹理,这有助于减少从图像编辑器导出图片时产生的边缘轮廓效应。
除了使用 fix_alpha_border 来修复发黑的边缘,另一种替代方案是使用预乘 Alpha(premultiplied alpha)。启用此选项后,纹理会被自动转换成这种格式。不过,预乘 Alpha 纹理需要配合特定的材质才能正确显示:
在 2D 中:需要创建一个 CanvasItemMaterial,并在使用了该纹理的 CanvasItem 上,将其混合模式配置为 CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA。如果你使用的是自定义的
canvas_item着色器,则需要在代码中加入render_mode blend_premul_alpha;。在 3D 中:需要创建一个 BaseMaterial3D,并在使用了该纹理的材质上,将其混合模式配置为 BaseMaterial3D.BLEND_MODE_PREMULT_ALPHA。如果你使用的是自定义的
spatial着色器,则需要在代码中加入render_mode blend_premul_alpha;。
覆盖纹理饱和度。