Zh/Animated Particles: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(Created page with "{{subst:#if: Translation of 'Animated Particles' to '中文' via Template:LanguageBar buttons * * * * * * * * * * * * * * * * * * * * * * * * * * * *...")
 
(deepseek translation)
 
Line 1: Line 1:
{{subst:#if:|||{{LAuto/t}}
{{translate}}
 
--- DON'T JUST BLINDLY DELETE THIS PART. DO REPLACE THE LINKS AND CATEGORIES. THE PICTURE SHOWS HOW TO USE IT ! ---
 
SEARCH FOR:
\[\[(?!#|File(?:[ _]talk)?:|Image(?:[ _]talk)?:|Media:|Template(?:[ _]talk)?:|MediaWiki(?:[ _]talk)?:|Talk:|Category[ _]talk:|Project[ _]talk:|Valve[ _]Developer[ _]Community[ _]talk:|Help[ _]talk:|User(?:[ _]talk)?:|c:|commons:|Dictionary:|Google:|GoogleGroups:|IMDB:|M:|Meta:|Metawikipedia:|MW:|SdkBug:|SourceForge:|Steampowered:|W:|Wiki:|WikiBooks:|Wikipedia:|Wikiquote:|Wiktionary:|WP:)(:?(?:Category|Category|Help|Project|Valve[ _]Developer[ _]Community|Special|)(?:[^\|\]]+))(\|?.*?)\]\]
 
REPLACE WITH:
{{subst:LAuto|$1$2}}
 
}}{{wip}}{{translate}}
{{LanguageBar}}
{{LanguageBar}}


Particles use textures that are compiled into a {{ent|SpriteCard}} texture. These sprite card textures are merely a collection of multiple textures at once.<br>
粒子使用的纹理会被编译为{{ent|SpriteCard}}纹理。这些精灵卡纹理本质上是多个纹理的集合。<br>
The individual textures on these sprite cards can either be frames that are meant to be one animated particle, or entirely unrelated to each other.
精灵卡上的单个纹理可以是组成动画粒子的一帧帧图像,也可以是彼此无关的独立纹理。
sprite cards are created using '''mksheet.exe''', which is located in the bin folder, along with a MKS text file that defines which textures to use, and whether the sprite card is an animated item, or separate unrelated frames.
精灵卡通过位于bin文件夹中的'''mksheet.exe'''工具创建,同时需要一个MKS文本文件来定义使用的纹理,并指定该精灵卡是动画序列还是独立帧集合。


== The MKS File ==
== MKS文件 ==


The .mks file defines how the sheet is interpreted when the particle is rendered. You can organize materials in to ''sequences'' for playback, define the number of frames and their playback rate, and whether a sequence should loop continuously.
.mks文件定义了粒子渲染时如何解析精灵卡。您可以将材质组织为可播放的''序列'',定义帧数和播放速率,以及是否循环播放序列。


Here's an example mks file, listing various possible setups.
以下是一个示例mks文件,展示了多种可能的配置:


<source>
<source>
// First sequence. Simple looping two frame animation.
// 第一个序列:简单的两帧循环动画
sequence 0  
sequence 0  
loop
loop
Line 29: Line 19:
frame mymaterial2.tga 1
frame mymaterial2.tga 1


// Second sequence. One single texture. Not animated.
// 第二个序列:单张静态纹理
sequence 1
sequence 1
frame mymaterial3.tga 1
frame mymaterial3.tga 1


// Third sequence. Two images per frame, for multi-texturing.
// 第三个序列:每帧使用两张纹理进行多重贴图
sequence 2
sequence 2
frame fire_base0.tga fire_additive0.tga 1
frame fire_base0.tga fire_additive0.tga 1
frame fire_base1.tga fire_additive1.tga 1
frame fire_base1.tga fire_additive1.tga 1


// Fourth sequence. Combines the alpha channels of two frames at a time into the alpha and green channels of a frame for a special shader.
// 第四个序列:将两帧的alpha通道分别存入输出帧的alpha和绿色通道,用于特殊着色器
sequence 3
sequence 3
frame frame0.tga{g=a},frame1.tga{a=a} 1
frame frame0.tga{g=a},frame1.tga{a=a} 1
Line 45: Line 35:


;sequence
;sequence
:Lets Mksheet.exe know the next frames, until the next sequence, all belong together as an animated particle.
: 告知Mksheet.exe后续的frame条目属于同一个动画粒子序列,直到遇到下一个sequence指令
;frame
;frame
:The name of the texture tga files to be used, followed by the playback rate. A value of ''1'' tells the renderer to playback this frame for the normal time duration. A value of ''0.5'' would play the frame for half as long as was specified in the particle definition, and a value of ''2'' would make the frame render for twice as long.
: 指定使用的.tga纹理文件名,后跟播放速率。''1''表示正常时长播放,''0.5''表示播放时间减半,''2''表示双倍时长
;loop
;loop
:Whether the frames in a sequence should be looped. Not setting this, will cause the particle to play its frames and end on the last frame it has.
: 设置序列循环播放。若未设置,粒子播放完所有帧后将停留在最后一帧


Additionally, frames can be packed separately in RGB from Alpha. This takes the alphas from a set of input frames and stores them in the alpha of the output sheet. It takes the RGBs and stores them in the RGB. The interesting thing about this is that each get their own sequences. They also have their frame sizes entirely decoupled, so the RGB's can have 200x200 images while the alpha has 150x150, for example. See Below :
此外,帧的RGB和Alpha通道可以分别打包。此功能将输入帧的Alpha存入输出精灵卡的Alpha通道,RGB存入RGB通道。值得注意的是,RGB和Alpha可以拥有独立的序列和帧尺寸。例如RGB可以是200x200,而Alpha是150x150。示例如下:
<source>
<source>
// Sequence that stores separate frame data in the RGB from the alpha
// 该序列将RGB帧数据与Alpha帧数据分离
// for dual sequencing combining one set of RGBs and another set of alphas
// 实现RGB序列与Alpha序列的组合播放


// Packmode sets mksheet to separate the RGB frames from the Alpha ones.
// packmode设置mksheet分离RGB和Alpha帧
packmode rgb+a
packmode rgb+a


// First Sequence - Looping Alpha Frames
// 第一个序列 - 循环Alpha帧
sequence-a 0
sequence-a 0
LOOP
LOOP
Line 65: Line 55:
frame reframedSmokeSprites170_0035.tga 1
frame reframedSmokeSprites170_0035.tga 1


// Second Sequence - Looping RGB Frames
// 第二个序列 - 循环RGB帧
sequence-rgb 1
sequence-rgb 1
LOOP
LOOP
Line 71: Line 61:
frame smokeTex0002_341.tga 1
frame smokeTex0002_341.tga 1
</source>
</source>
The output from this .mks file can be seen below. The RGB and alpha channels are shown. Note that the individual frame sizes are all non-power-of-two and that they are different between the RGB and Alpha frames.
.mks文件的输出效果如下。注意RGB和Alpha帧的尺寸均为非2的幂且互不相同。
   
   
[[File:Vista_smoke_rgb.jpg|300px|Example output - RGB]] [[File:Vista_smoke_alpha.jpg|300px|Example output - Alpha]]
[[File:Vista_smoke_rgb.jpg|300px|示例输出 - RGB]] [[File:Vista_smoke_alpha.jpg|300px|示例输出 - Alpha]]


== Notes ==
== 注意事项 ==


* You can use the same image file in multiple sequences (or multiple times within the same sequence) without it being duplicated in the output sheet. Examples where you would want to do this are sequences with different timing, particle sequences, looped and non-looped versions of a sequence, etc.
* 同一图像文件可以在多个序列(或同一序列多次)重复使用,而不会在输出精灵卡中重复存储。典型应用场景包括:不同播放速度的序列、粒子序列、循环与非循环版本等
* To the extent practical, you should combine as many sprite textures into one sheet as possible, and use different sequences for the different particle systems.
* 应尽可能将多个精灵纹理合并到一张精灵卡中,通过不同序列服务于不同的粒子系统


== Step by Step Tutorial ==
== 逐步教程 ==
The following guide has been written, and proven to work for {{l4d2|4}}. According to some users, this does not work in {{as|4}}, but does work in {{css|4}}
本教程已验证适用于{{l4d2|4}}。据用户反馈,此方法在{{as|4}}中不可用,但在{{css|4}}中有效


# Create a folder somewhere in MaterialSrc, in which you place the individual tga textures, which will be compiled into a SpriteCard. Something like "MaterialSrc/Particles/Particle_name/"{{note|The location for these doesn't matter for Mksheet.exe. However, Vtex.exe does require your .sht and compiled .tga files to be somewhere inside the game's "Materialsrc" folder.<br> So you might aswell just use a subfolder of MaterialSrc for your source files (Blender save file, model, textures, individual renders, ect.)}}
# 在MaterialSrc目录下创建文件夹(例如"MaterialSrc/Particles/Particle_name/"),存放要编译的.tga纹理{{note|虽然mksheet.exe不关心文件位置,但Vtex.exe要求.sht和编译后的.tga必须位于"Materialsrc"文件夹内<br>建议直接将源文件(Blender文件、模型、纹理等)存放在MaterialSrc的子目录中}}
# Inside this folder, create a text file that ends in .mks, instead of .txt. The name of this mks file will be then be re-used for its output .sht and .tga files.
# 在此文件夹内创建以.mks为扩展名的文本文件(非.txt)。该文件名称将作为输出.sht和.tga的文件名
# Set up the .mks the way you want it, as explained previously on the page. Here's an example of a mks which only has static sprites that do not animate:<source>
# 按前文说明配置.mks文件。以下是不带动画的静态精灵示例:<source>
sequence 0
sequence 0
frame 9mm_0001.tga 1
frame 9mm_0001.tga 1
Line 94: Line 84:
sequence 3
sequence 3
frame 9mm_0004.tga 1</source>
frame 9mm_0004.tga 1</source>
# Drag and drop the .mks file onto mksheet.exe. This will give you a .sht and a .tga file with the same name as the .mks.{{Tip| If you do not want to keep opening the bin folder to get to mksheet.exe (and later vtex.exe), you can make shortcuts on your desktop and drag your files onto those instead.}}{{Warning|You should "dilate" the particle texture to prevent the black background texture to bleed through. How to do that is explained further down the page.}}
# .mks文件拖放到mksheet.exe上,生成同名.sht和.tga文件{{Tip| 可为mksheet.exe和vtex.exe创建桌面快捷方式,避免反复打开bin文件夹}}{{Warning|需对粒子纹理进行"膨胀"处理以防止黑色背景渗色,具体方法见下文}}
# Drag the .sht or compiled (and dilated) tga file onto vtex.exe, or its shortcut. This will take a while to create up to two vtf files.<br>The second vtf having a "pwl" extension, which can be deleted. Alternatively, you can check the vtex log and quit after the first "SUCCESS: Vtf file created" message appears.<br>Vtex will see the folder setup inside "materialsrc" and re-create the same folder path inside of "materials" and place your finished vtf files inside of it. If the .sht/tga were in "MaterialSrc/Particles/Particle_name/", vtex.exe saves the vtf in "Materials/Particles/Particle_name/".
# .sht或处理后的.tga拖放到vtex.exe(或其快捷方式)上,生成最多两个.vtf文件<br>可删除带"pwl"扩展名的辅助文件,或在vtex日志出现"SUCCESS: Vtf file created"后提前终止进程<br>Vtex会根据Materialsrc中的路径结构,在materials目录下创建相同路径存放.vtf文件
# Now you're done, and can create a vmt file for this particle. Here's a basic one for you to copy: <br><source>spritecard
# 创建粒子材质文件.vmt,基本结构如下:<br><source>spritecard
{
{
$basetexture ".../.../..."
$basetexture ".../.../..."
Line 103: Line 93:
}</source>
}</source>


== Dilating the particle TGA ==
== 粒子TGA膨胀处理 ==
As explained in the previous warning, not having dilation causes the black background to bleed through on the particle. This may not be an issue if you used <code>packmode rgb+a</code> in the mks.
若未进行膨胀处理,黑色背景会渗入半透明粒子(如火、烟)。使用<code>packmode rgb+a</code>时可能无需此步骤


[[File:Particle Dilation.png|300px|right]]
[[File:Particle Dilation.png|300px|right]]
# Open the tga which mksheet.exe made in an image editing software.
# 在图像软件中打开mksheet生成的.tga
# Copy the tga's alpha channel and use it as a layer mask for the actual texture. Which will get rid of the black background.
# 复制Alpha通道作为图层蒙版,去除黑色背景
# Make a copy of the particle sprite layer and add gaussian blur. Maybe duplicate the blurred version a few times, just to make the blur dilation around the actual particle bigger.
# 复制粒子图层并添加高斯模糊,可多次复制以增强边缘膨胀效果
# Put the blurred version beneath the default particle texture, and then add a new solid background color.
# 将模糊层置于原始纹理下方,添加纯色背景


If you follow these steps, you got a nicely dilated texture that surely won't bleed any background color. Which is very important for half-translucent particles, like fire or smoke.
通过上述步骤可获得无背景渗色的优质膨胀纹理


== Compiling the Sheet ==
== 精灵卡编译(旧方法) ==
{{Note|None of this is required, at least not in {{l4d2|4}}. Use "Step by Step Tutorial" instead. But since some game's mksheet.exe may be different, we are keeping this info here, just in case.}}
{{Note|以下方法在{{l4d2|4}}中非必需,请优先使用"逐步教程"。保留此信息仅作兼容性参考}}
Once the materials are created, move all of your .tga and .mks files to the "Steamapps/common/SourceSDK/bin/orangebox/bin" folder. Inside this directory, create a .bat file, and inside it, write:
.tga和.mks文件放入"Steamapps/common/SourceSDK/bin/orangebox/bin"。创建包含以下内容的.bat文件:


  mksheet <sheetname>.mks <sheetname>.sht <sheetname>.tga
  mksheet <sheetname>.mks <sheetname>.sht <sheetname>.tga


The tool takes one main parameter and two optional ones. The first is the ''.mks'' sheet which will define how the ''.sht'' and ''.tga'' files are created. The second, optional parameter is the ''.sht'' file. Finally, the third optional parameter is the ''.tga'' file to create, consisting of all the tga files previously specified. The second and third parameters must bear the name of the final material you wish to create.
参数说明:第一个为必填的.mks文件,后两个分别为可选的.sht和.tga输出文件。例如编译smoke1.vmt:
For example, the build call for the ''smoke1.vmt'' material would be:


  mksheet smoke1.mks smoke1.sht smoke1.tga
  mksheet smoke1.mks smoke1.sht smoke1.tga


From this, you will get a/some compiled tga files, a ''.sht'' file and maybe a blank <sheetname>''.file'' file. feel free to delete the ''.file'' file.
生成的.file文件可安全删除


== Automation in 3ds Max ==
== 3ds Max自动化 ==


You can now export rendered sequences directly into Source with Wall Worm. The system allows you to export IFL (Image File List) bitmaps made of TGA bitmaps. Based on the bitmap parameters, the MKS is generated automatically, then sent to mkshheet with the .SHT file and TGA files. See complete documentation at http://dev.wallworm.com/document/187/exporting_animated_particle_textures.html  
通过Wall Worm插件可直接导出渲染序列到Source引擎。该系统支持导出基于TGA的IFL(图像文件列表)位图,根据位图参数自动生成MKS文件并调用mksheet生成.SHT和.TGA。完整文档参见:http://dev.wallworm.com/document/187/exporting_animated_particle_textures.html  


[[Category:Particle System]]
{{ACategory|粒子系统}}
[[Category:Material System]]
{{ACategory|材质系统}}

Latest revision as of 07:20, 17 February 2025

Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)
English (en)中文 (zh)Translate (Translate)

粒子使用的纹理会被编译为SpriteCard纹理。这些精灵卡纹理本质上是多个纹理的集合。
精灵卡上的单个纹理可以是组成动画粒子的一帧帧图像,也可以是彼此无关的独立纹理。 精灵卡通过位于bin文件夹中的mksheet.exe工具创建,同时需要一个MKS文本文件来定义使用的纹理,并指定该精灵卡是动画序列还是独立帧集合。

MKS文件

.mks文件定义了粒子渲染时如何解析精灵卡。您可以将材质组织为可播放的序列,定义帧数和播放速率,以及是否循环播放序列。

以下是一个示例mks文件,展示了多种可能的配置:

// 第一个序列:简单的两帧循环动画
sequence 0 
loop		
frame mymaterial1.tga 1
frame mymaterial2.tga 1

// 第二个序列:单张静态纹理
sequence 1
frame mymaterial3.tga 1

// 第三个序列:每帧使用两张纹理进行多重贴图
sequence 2
frame fire_base0.tga fire_additive0.tga 1
frame fire_base1.tga fire_additive1.tga 1

// 第四个序列:将两帧的alpha通道分别存入输出帧的alpha和绿色通道,用于特殊着色器
sequence 3
frame frame0.tga{g=a},frame1.tga{a=a} 1
frame frame2.tga{g=a},frame3.tga{a=a} 1
sequence
告知Mksheet.exe后续的frame条目属于同一个动画粒子序列,直到遇到下一个sequence指令
frame
指定使用的.tga纹理文件名,后跟播放速率。1表示正常时长播放,0.5表示播放时间减半,2表示双倍时长
loop
设置序列循环播放。若未设置,粒子播放完所有帧后将停留在最后一帧

此外,帧的RGB和Alpha通道可以分别打包。此功能将输入帧的Alpha存入输出精灵卡的Alpha通道,RGB存入RGB通道。值得注意的是,RGB和Alpha可以拥有独立的序列和帧尺寸。例如RGB可以是200x200,而Alpha是150x150。示例如下:

// 该序列将RGB帧数据与Alpha帧数据分离
// 实现RGB序列与Alpha序列的组合播放

// packmode设置mksheet分离RGB和Alpha帧
packmode rgb+a

// 第一个序列 - 循环Alpha帧
sequence-a 0
LOOP
frame reframedSmokeSprites170_0033.tga 1
frame reframedSmokeSprites170_0035.tga 1

// 第二个序列 - 循环RGB帧
sequence-rgb 1
LOOP
frame smokeTex0001_341.tga 1
frame smokeTex0002_341.tga 1

该.mks文件的输出效果如下。注意RGB和Alpha帧的尺寸均为非2的幂且互不相同。

示例输出 - RGB 示例输出 - Alpha

注意事项

  • 同一图像文件可以在多个序列(或同一序列多次)重复使用,而不会在输出精灵卡中重复存储。典型应用场景包括:不同播放速度的序列、粒子序列、循环与非循环版本等
  • 应尽可能将多个精灵纹理合并到一张精灵卡中,通过不同序列服务于不同的粒子系统

逐步教程

本教程已验证适用于求生之路2 求生之路2。据用户反馈,此方法在异形丛生 异形丛生中不可用,但在反恐精英:起源 反恐精英:起源中有效

  1. 在MaterialSrc目录下创建文件夹(例如"MaterialSrc/Particles/Particle_name/"),存放要编译的.tga纹理
    Note.png注意:虽然mksheet.exe不关心文件位置,但Vtex.exe要求.sht和编译后的.tga必须位于"Materialsrc"文件夹内
    建议直接将源文件(Blender文件、模型、纹理等)存放在MaterialSrc的子目录中
  2. 在此文件夹内创建以.mks为扩展名的文本文件(非.txt)。该文件名称将作为输出.sht和.tga的文件名
  3. 按前文说明配置.mks文件。以下是不带动画的静态精灵示例:
    sequence 0
    frame 9mm_0001.tga 1
    sequence 1
    frame 9mm_0002.tga 1
    sequence 2
    frame 9mm_0003.tga 1
    sequence 3
    frame 9mm_0004.tga 1
  4. 将.mks文件拖放到mksheet.exe上,生成同名.sht和.tga文件
    Tip.png提示: 可为mksheet.exe和vtex.exe创建桌面快捷方式,避免反复打开bin文件夹
    Warning.png警告:需对粒子纹理进行"膨胀"处理以防止黑色背景渗色,具体方法见下文
  5. 将.sht或处理后的.tga拖放到vtex.exe(或其快捷方式)上,生成最多两个.vtf文件
    可删除带"pwl"扩展名的辅助文件,或在vtex日志出现"SUCCESS: Vtf file created"后提前终止进程
    Vtex会根据Materialsrc中的路径结构,在materials目录下创建相同路径存放.vtf文件
  6. 创建粒子材质文件.vmt,基本结构如下:
    spritecard
    {
    $basetexture ".../.../..."
    $depthblend 0
    $blendframes 0
    }

粒子TGA膨胀处理

若未进行膨胀处理,黑色背景会渗入半透明粒子(如火、烟)。使用packmode rgb+a时可能无需此步骤

Particle Dilation.png
  1. 在图像软件中打开mksheet生成的.tga
  2. 复制Alpha通道作为图层蒙版,去除黑色背景
  3. 复制粒子图层并添加高斯模糊,可多次复制以增强边缘膨胀效果
  4. 将模糊层置于原始纹理下方,添加纯色背景

通过上述步骤可获得无背景渗色的优质膨胀纹理

精灵卡编译(旧方法)

Note.png注意:以下方法在求生之路2 求生之路2中非必需,请优先使用"逐步教程"。保留此信息仅作兼容性参考

将.tga和.mks文件放入"Steamapps/common/SourceSDK/bin/orangebox/bin"。创建包含以下内容的.bat文件:

mksheet <sheetname>.mks <sheetname>.sht <sheetname>.tga

参数说明:第一个为必填的.mks文件,后两个分别为可选的.sht和.tga输出文件。例如编译smoke1.vmt:

mksheet smoke1.mks smoke1.sht smoke1.tga

生成的.file文件可安全删除

3ds Max自动化

通过Wall Worm插件可直接导出渲染序列到Source引擎。该系统支持导出基于TGA的IFL(图像文件列表)位图,根据位图参数自动生成MKS文件并调用mksheet生成.SHT和.TGA。完整文档参见:http://dev.wallworm.com/document/187/exporting_animated_particle_textures.html