这篇条目有关 Source引擎。如需详情,点击这里。

Zh/$lightwarptexture: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(Undo revision 394839 by Thunder4ik (talk))
Tag: Undo
(deepseek translation)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{langsp}}
{{LanguageBar}}
{{Source topicon}}


[[File:Lightwarp snow.jpg|thumb|200px|这项技术首次应用于 {{dods|2}}'的雪地地图之中, 比如Kalt的雪景。]]
[[File:Lightwarp snow.jpg|thumb|200px|该技术首次应用于{{dods|2}}的雪地地图,例如Kalt。]]
[[File:Lightwarp heavy.png|thumb|150px|<code>$lightwarptexture</code> 在 {{tf2|2}}中渲染人物的图解]]
[[File:Lightwarp heavy.png|thumb|150px|{{code|$lightwarptexture}}是{{tf2|2}}卡通风格角色渲染的核心要素。]]
[[File:Lightwarp BW.png|thumb|150px|可以实现色调分离,但照明必须严格控制。]]
[[File:Lightwarp BW.png|thumb|150px|可实现分阶色彩效果,但需严格控制光照。]]


{{Shaderparam|$lightwarptexture|dx9=1|since=Source 2006|shader1=VertexLitGeneric|shader2=LightmappedGeneric|shader3=WorldVertexTransition|shader4=EyeRefract}}它的色调[[texel]]取决于它们的亮度。它可以被认为是局部的[[color correction|彩色修正]]
{{this is a|shader parameter|name=$lightwarptexture|shader=VertexLitGeneric|since=Source 2006|notitlechange=1|nocat=1|dx=dx95}} 该参数根据[[texel]]的亮度进行染色,可视为局部化的[[color correction|色彩校正]]


== 警告 ==
{{Note|也可用于{{L|LightmappedGeneric}}{{L|WorldVertexTransition}}{{L|EyeRefract}}}}
{{Important|<code>$lightwarptexture</code> 必须指定后所有其他纹理,否则它将覆盖它们。}}
{{Important|<code>$lightwarptexture</code> 在{{Ent|VertexLitGeneric}} 之后需要一个 {{Ent|$bumpmap}}. 如果未指定,则使用默认值! '''就好像是 {{Ent|$bumpmap}} 在VMT!'''}}
{{Warning| 这意味着所有不能工作的参数 {{Ent|$bumpmap}} 同样也不会与 <code>$lightwarptexture</code>合作.}}
:* [[$detail#Parameters and Effects|$detailblendmode]] 5-9 won't work - 5 & 6 will work when {{Ent|$phong}} is used.
:* {{Ent|$envmapmask}} won't work except in {{mapbase|4}}. {{Ent|$selfillum_envmapmask_alpha}} Doesn't work in any branch.
{{Note|Does not work without {{Ent|$phong}} on {{Ent|VertexLitGeneric}} in {{css|2}} '''and''' {{csgobranch|4}}.}}
{{Note|<code>$lightwarptexture</code> does not seem to exist at all for {{Ent|LightmappedGeneric}} in {{csgobranch|4}}.}}


{{Bug|Does not work when using {{Ent|$detail}} '''or''' {{Ent|$bumpmap2}} on both {{Ent|LightmappedGeneric}} and {{Ent|WorldVertexTransition}}.}}
== 注意事项 ==
{{Bug|Does not work when using [[Glowing_Textures#.24selfillum|$selfillumfresnel]] without also using {{Ent|$phong}}.}}
{{Important|{{code|$lightwarptexture}}必须在所有其他纹理之后指定,否则会覆盖其他纹理。}}
{{Bug|Does not work when using {{Ent|$seamless_scale}}.}}
{{Important|确保纹理在VTF中启用钳位模式,否则渲染会异常。需使用'''Clamp S'''和'''Clamp T'''{{L|Texture flags|图像标志}}。}}
 
{{Important|{{Ent|VertexLitGeneric}}的{{code|$lightwarptexture}}需要{{Ent|$bumpmap}}。若未指定,将自动使用默认法线贴图!'''效果等同于在VMT中声明了{{Ent|$bumpmap}}!'''
{{Warning| 这意味着所有与{{Ent|$bumpmap}}冲突的参数也会与此参数冲突:
* {{L|$detail#Parameters and Effects|$detailblendmode}} 5-9失效 - 使用{{Ent|$phong}}时5和6仍有效
* {{Ent|$envmapmask}}仅在{{mapbase|2}}中有效
* {{Ent|$selfillum_envmapmask_alpha}}在所有分支中均无效
}} }}
{{Note|在{{src13|2}}和{{csgobranch|2}}中,{{Ent|VertexLitGeneric}}必须启用{{Ent|$phong}}才能使用本参数。}}
{{Note|{{csgobranch|2}}的{{Ent|LightmappedGeneric}}似乎完全未实现{{code|$lightwarptexture}}。}}


== Lightwarp textures ==
{{Bug|在{{Ent|LightmappedGeneric}}和{{Ent|WorldVertexTransition}}上同时使用{{Ent|$detail}}或{{Ent|$bumpmap2}}会导致失效。}}
A lightwarp texture is a one-dimensional strip of pixels. Dark texels will be tinted with the colour on the left-hand side, and bright texels with the colour on the right. 50% gray means no tint.
{{Bug|未启用{{Ent|$phong}}时,{{L|Glowing_Textures#.24selfillum|$selfillumfresnel}}会导致失效。}}
{{Bug|使用{{Ent|$seamless_scale}}时失效。}}


=== Examples ===
== 光扭曲纹理 ==
; <code>snow_warp</code>:[[File:Warptexture.jpg|border|dod\materials\ground\snow_warp]]
光扭曲纹理是一维像素条。暗部区域将应用左侧颜色染色,亮部则应用右侧颜色。50%灰度表示无染色。
: This is the lightwarp texture used in the {{dods|2}} screen to the right. It is designed to add a subtle bluish tint to darker snow without affecting brighter regions.
{{note|光照贴图笔刷/位移面与顶点光照模型的光扭曲效果略有差异。完全50%灰度的{{code|$lightwarptexture}}在笔刷/位移面上会呈现无光扭曲效果,而相同纹理在未启用{{L|$phong}}的模型上会导致均匀光照(类似GoldSrc的平面着色模式)。}}
; <code>pyro_lightwarp</code>:[[File:Pyro lightwarp.png|border|tf\materials\models\player\pyro\pyro_lightwarp]]
: This is applied to all {{tf2|2}} characters, not just the Pyro. It creates the high-contrast shadows with red-tinged terminators typical of the illustrative art the game apes.
; Posterized: [[File:Warp bw.png|border|Custom texture]]
: This custom warp texture creates a posterized "line art" style. Enabling lightwarp alone isn't enough however: ambient lighting must be at 0 to make unlit areas black, and world lighting must become viewer-dependent to ensure that shadows are always cast.
; <code>Cel Shading</code>:[[File:Cel_lightwarp.png|border|Custom texture]]
:Cel shading can make objects look more cartoony by replacing the smooth lighting gradient with sharp steps.


Other possible uses of <code>$lightwarptexture</code> include contrast enhancement, tweaking vertex lighting shadow transitions, highlight softening, and more.
=== VTF参数 ===
光扭曲纹理应使用未压缩的BGR888格式以避免光照渐变中的色阶断层{{ref|1}},并启用UV钳位。


使用{{vtex|4}}时,建议编译参数:
<pre>
nocompress 1 // 禁用纹理压缩,防止色阶断层
nomip 1      // 禁用mipmap(低分辨率纹理无需生成)
nolod 1      // 始终使用完整分辨率版本
clamps 1    // 防止极端光照值混合
clampt 1    // 可选?
stripalphachannel 1 // 移除冗余的Alpha通道(如有)
</pre>


::[[File:Celshadingpreview.png|thumb|320px|left|Cel shading in action.]]
=== 示例 ===
; {{file|ground/snow_warp|vtf}} ({{dods}}):[[File:Warptexture.jpg|border|dod\materials\ground\snow_warp]]
: 这是上文{{dods|2}}截图中使用的光扭曲纹理,用于为暗部雪景添加微妙蓝调而不影响高光区域。
; {{file|models/player/pyro/pyro_lightwarp|vtf}} ({{tf2}}):[[File:Pyro lightwarp.png|border|tf\materials\models\player\pyro\pyro_lightwarp]]
: 该纹理应用于所有{{tf2|2}}角色(不仅限Pyro),创造出红调阴影边界的高对比度卡通效果。
; 分阶处理(自定义): [[File:Warp bw.png|border|自定义纹理]]
: 此自定义纹理实现"线稿"风格。需将环境光设为0使未照明区域变黑,并控制视角相关阴影投射。
; 卡通着色(自定义):[[File:Cel_lightwarp.png|border|自定义纹理]]
: 通过锐利的光照阶梯替代平滑渐变,增强卡通质感。
 
{{code|$lightwarptexture}}还可用于增强对比度、调整顶点光照阴影过渡、柔化高光等。
 
::[[File:Celshadingpreview.png|thumb|320px|left|卡通着色效果演示]]
{{clr}}
 
== 参考资料 ==
<ol>
<li>[https://gamebanana.com/mods/466641 Lightwarp Fixes <nowiki>[Team Fortress 2] [Mods]</nowiki> on GameBanana]
</ol>
 
{{ACategory|Shader parameters}}

Latest revision as of 04:29, 10 March 2025

English (en)中文 (zh)Translate (Translate)

该技术首次应用于胜利之日:起源 胜利之日:起源的雪地地图,例如Kalt。
$lightwarptexture军团要塞2 军团要塞2卡通风格角色渲染的核心要素。
可实现分阶色彩效果,但需严格控制光照。

$lightwarptexture(DX9+ SM3)是一个用于着色器 VertexLitGeneric材质(en)着色器(en)参数,可在所有的 起源 起源 游戏,自从 起源2006 起源2006 以来中使用。 该参数根据texel的亮度进行染色,可视为局部化的色彩校正

Note.png注意:也可用于LightmappedGeneric(en)WorldVertexTransition(en)EyeRefract(en)

注意事项

Icon-Important.png重要:$lightwarptexture必须在所有其他纹理之后指定,否则会覆盖其他纹理。
Icon-Important.png重要:确保纹理在VTF中启用钳位模式,否则渲染会异常。需使用Clamp SClamp T图像标志(en)
Icon-Important.png重要:VertexLitGeneric$lightwarptexture需要$bumpmap。若未指定,将自动使用默认法线贴图!效果等同于在VMT中声明了$bumpmap
Warning.png警告: 这意味着所有与$bumpmap冲突的参数也会与此参数冲突:
Note.png注意:起源2013 起源2013CS:GO 引擎分支 CS:GO 引擎分支中,VertexLitGeneric必须启用$phong才能使用本参数。
Note.png注意:CS:GO 引擎分支 CS:GO 引擎分支LightmappedGeneric似乎完全未实现$lightwarptexture
Icon-Bug.png错误:LightmappedGenericWorldVertexTransition上同时使用$detail$bumpmap2会导致失效。  [todo tested in ?]
Icon-Bug.png错误:未启用$phong时,$selfillumfresnel(en)会导致失效。  [todo tested in ?]
Icon-Bug.png错误:使用$seamless_scale时失效。  [todo tested in ?]

光扭曲纹理

光扭曲纹理是一维像素条。暗部区域将应用左侧颜色染色,亮部则应用右侧颜色。50%灰度表示无染色。

Note.png注意:光照贴图笔刷/位移面与顶点光照模型的光扭曲效果略有差异。完全50%灰度的$lightwarptexture在笔刷/位移面上会呈现无光扭曲效果,而相同纹理在未启用$phong(en)的模型上会导致均匀光照(类似GoldSrc的平面着色模式)。

VTF参数

光扭曲纹理应使用未压缩的BGR888格式以避免光照渐变中的色阶断层[1],并启用UV钳位。

使用VTEX VTEX时,建议编译参数:

nocompress 1 // 禁用纹理压缩,防止色阶断层
nomip 1      // 禁用mipmap(低分辨率纹理无需生成)
nolod 1      // 始终使用完整分辨率版本
clamps 1     // 防止极端光照值混合
clampt 1     // 可选?
stripalphachannel 1 // 移除冗余的Alpha通道(如有)

示例

🖿ground/snow_warp.vtf (胜利之日:起源)
dod\materials\ground\snow_warp
这是上文胜利之日:起源 胜利之日:起源截图中使用的光扭曲纹理,用于为暗部雪景添加微妙蓝调而不影响高光区域。
🖿models/player/pyro/pyro_lightwarp.vtf (军团要塞2)
tf\materials\models\player\pyro\pyro_lightwarp
该纹理应用于所有军团要塞2 军团要塞2角色(不仅限Pyro),创造出红调阴影边界的高对比度卡通效果。
分阶处理(自定义)
自定义纹理
此自定义纹理实现"线稿"风格。需将环境光设为0使未照明区域变黑,并控制视角相关阴影投射。
卡通着色(自定义)
自定义纹理
通过锐利的光照阶梯替代平滑渐变,增强卡通质感。

$lightwarptexture还可用于增强对比度、调整顶点光照阴影过渡、柔化高光等。

卡通着色效果演示

参考资料

  1. Lightwarp Fixes [Team Fortress 2] [Mods] on GameBanana