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

Zh/Refract: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(chatgpt translation)
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{LanguageBar}}
[[File:Refract.jpg|thumb|250px|一个具有折射效果的{{L|func_brush}}。]]
[[File:Refract.jpg|thumb|250px|一个具有折射效果的{{L|func_brush}}。]]


Line 23: Line 23:
  }
  }


{{MatParam|$normalmap|texture}}
{{MatParamDef|$normalmap|texture}}
{{MatParam|$dudvmap|texture|折射的模式由法线贴图(DX9+)或DUDV贴图(DX8-)定义。可以是动画的。|dx8=1}}
{{MatParamDef|$dudvmap|texture|折射的模式由法线贴图(DX9+)或DUDV贴图(DX8-)定义。可以是动画的。|dx8=1}}
{{MatParam|$normalmap2|texture|如果指定了第二个法线贴图,它将与第一个法线贴图混合。|since={{src07}}|dx9=1}}
{{MatParamDef|$normalmap2|texture|如果指定了第二个法线贴图,它将与第一个法线贴图混合。|since={{src07}}|dx9=1}}
{{MatParam|$bumpframe|and=$bumpframe2|int|动画凸凹贴图的起始帧。}}
{{MatParamDef|$bumpframe|and=$bumpframe2|int|动画凸凹贴图的起始帧。}}
{{MatParam|$bumptransform|and=$bumptransform2|vector3|变换凸凹贴图纹理。
{{MatParamDef|$bumptransform|and=$bumptransform2|vector3|变换凸凹贴图纹理。
{{VMT UVtransform}}}}
{{VMT UVtransform}}}}
{{MatParam|$refracttint|RGB matrix}}
{{MatParamDef|$refracttint|RGB matrix}}
{{MatParam|$refracttinttexture|texture|为折射着色,既可以均匀着色也可以逐像素着色。可以与'''$refracttint'''结合使用。}}
{{MatParamDef|$refracttinttexture|texture|为折射着色,既可以均匀着色也可以逐像素着色。可以与'''$refracttint'''结合使用。}}
{{MatParam|$refracttinttextureframe|int|动画<code>$refracttinttexture</code>的起始帧。}}
{{MatParamDef|$refracttinttextureframe|int|动画<code>$refracttinttexture</code>的起始帧。}}
{{MatParam|$refractamount|float|{{Bug|{{portal2}} 与'''$localrefract'''不兼容。}}通过乘以法线贴图强度控制折射的强度。}}
{{MatParamDef|$refractamount|float|{{Bug|{{portal2}} 与'''$localrefract'''不兼容。}}通过乘以法线贴图强度控制折射的强度。}}
{{MatParam|$bluramount|int|{{Bug|{{portal2}} 与'''$localrefract'''不兼容。}}添加模糊效果。有效值为0、1和2(DX8-仅支持0和1)。|}}
{{MatParamDef|$bluramount|int|{{Bug|{{portal2}} 与'''$localrefract'''不兼容。}}添加模糊效果。有效值为0、1和2(DX8-仅支持0和1)。|}}
{{MatParam|$forcerefract|bool|强制在填充率较低的显卡上使用此着色器。|dx8=1}}
{{MatParamDef|$forcerefract|bool|强制在填充率较低的显卡上使用此着色器。|dx8=1}}
{{MatParam|$envmap|texture|在折射效果上添加一个反射贴图。}}
{{MatParamDef|$envmap|texture|在折射效果上添加一个反射贴图。}}
{{MatParam|$envmaptint|RGB matrix|控制反射的红、绿和蓝通道的强度。可以使用任何正数。默认值为<code>"[1 1 1]"</code>,表示100%的强度。
{{MatParamDef|$envmaptint|RGB matrix|控制反射的红、绿和蓝通道的强度。可以使用任何正数。默认值为<code>"[1 1 1]"</code>,表示100%的强度。
: {{Note|由于值中包含空格字符,必须使用引号。}}}}
: {{Note|由于值中包含空格字符,必须使用引号。}}}}
{{MatParam|$envmapcontrast|normal|控制反射的{{L|Wikipedia:Contrast (vision)|对比度}}。0为自然对比度,1为颜色完全平方(即color*color)。}}
{{MatParamDef|$envmapcontrast|normal|控制反射的{{L|Wikipedia:Contrast (vision)|对比度}}。0为自然对比度,1为颜色完全平方(即color*color)。}}
{{MatParam|$envmapsaturation|normal|控制反射的颜色饱和度。0为灰度,1为自然饱和度。}}
{{MatParamDef|$envmapsaturation|normal|控制反射的颜色饱和度。0为灰度,1为自然饱和度。}}
{{MatParam|$fresnelreflection|float|{{Bug|'''已损坏''' - 尽管存在此参数,但未为此着色器实现。}}|since={{src06}}}}
{{MatParamDef|$fresnelreflection|float|{{Bug|'''已损坏''' - 尽管存在此参数,但未为此着色器实现。}}|since={{src06}}}}
{{MatParam|$fadeoutonsilhouette|bool|在边缘淡化折射效果。}}
{{MatParamDef|$fadeoutonsilhouette|bool|在边缘淡化折射效果。}}
{{MatParam|$vertexcolormodulate||{{todo|使用顶点颜色影响折射颜色。Alpha值会调整折射量。参见{{ent|$vertexcolor}}。}}|since={{src07}}|dx9=1}}
{{MatParamDef|$vertexcolormodulate||{{todo|使用顶点颜色影响折射颜色。Alpha值会调整折射量。参见{{ent|$vertexcolor}}。}}|since={{src07}}|dx9=1}}
{{MatParam|$basetexture|texture|使用纹理而不是渲染视图作为扭曲像素的来源。|dx9=1}}
{{MatParamDef|$basetexture|texture|使用纹理而不是渲染视图作为扭曲像素的来源。|dx9=1}}
{{MatParam|$masked|bool|{{todo|''使用目标alpha进行遮罩''}}}}
{{MatParamDef|$masked|bool|{{todo|''使用目标alpha进行遮罩''}}}}
{{MatParam|$forcealphawrite|bool|{{todo|''强制材质将alpha写入目标缓冲区''}}|dx9=1|since={{src13}}}}
{{MatParamDef|$forcealphawrite|bool|{{todo|''强制材质将alpha写入目标缓冲区''}}|dx9=1|since={{src13}}}}
{{MatParam|$nowritez|int|{{todo|''0 {{=}}{{=}} 写入z,1 {{=}} 不写入z''}}}}
{{MatParamDef|$nowritez|int|{{todo|''0 {{=}}{{=}} 写入z,1 {{=}} 不写入z''}}}}
{{MatParam|$noviewportfixup|int|不为当前视口调整UV。|since={{as}}}}
{{MatParamDef|$noviewportfixup|int|不为当前视口调整UV。|since={{as}}}}
{{MatParam|$mirroraboutviewportedges|int|不要在视口外采样。|since={{as}}}}
{{MatParamDef|$mirroraboutviewportedges|int|不要在视口外采样。|since={{as}}}}
{{MatParam|$magnifyenable|bool|启用在<code>$magnifycenter</code>屏幕位置周围放大折射图像,放大比例为<code>$magnifyscale</code>。|since={{as}}}}
{{MatParamDef|$magnifyenable|bool|启用在<code>$magnifycenter</code>屏幕位置周围放大折射图像,放大比例为<code>$magnifyscale</code>。|since={{as}}}}
{{MatParam|$magnifycenter|vector2|放大此屏幕位置周围的折射图像。|since={{as}}}}
{{MatParamDef|$magnifycenter|vector2|放大此屏幕位置周围的折射图像。|since={{as}}}}
{{MatParam|$magnifyscale|float|放大折射图像的比例因子。|since={{as}}}}
{{MatParamDef|$magnifyscale|float|放大折射图像的比例因子。|since={{as}}}}
{{MatParam|$localrefract|bool|对基底纹理应用简单的视差效果。|since={{portal2}}}}
{{MatParamDef|$localrefract|bool|对基底纹理应用简单的视差效果。|since={{portal2}}}}
{{MatParam|$localrefractdepth|float|视差效果的深度(单位)。|since={{portal2}}}}
{{MatParamDef|$localrefractdepth|float|视差效果的深度(单位)。|since={{portal2}}}}
{{MatParam|$spitternoisetexture|texture|类似于[[$flow_noise_texture]]但也会使材质呈现绿色。在"Particle/warp_pool_01.vmt"中可见。|only={{L|L4D2}}?}}
{{MatParamDef|$spitternoisetexture|texture|类似于[[$flow_noise_texture]]但也会使材质呈现绿色。在"Particle/warp_pool_01.vmt"中可见。|only={{L|L4D2}}?}}


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

Latest revision as of 12:10, 23 August 2025

English (en)Deutsch (de)Français (fr)中文 (zh)Translate (Translate)
一个具有折射效果的func_brush(en)

Refract是一个像素着色器(en),可在所有的 起源 起源 游戏中使用。 它会扭曲其后方的物体。与(en)类似,但没有实时反射,因此不局限于平面表面。可用于创建扭曲的玻璃窗、冰等效果。

折射效果通过先渲染不包含折射表面的视图实现,然后使用法线贴图通过沿法线投影将预渲染视图中的像素坐标替换为新的像素坐标,从而扭曲图像。

Note.png注意:在旧引擎中应用于world brush(en)时将无法正常工作。
澄清: 在哪些引擎中有效?
PlacementTip.png解决方案:将具有折射效果的刷子绑定到一个func_brush上。
Note.png注意:Refract着色器应用在同一实体上的多层时,将无法正确渲染。
Tip.png提示:如果在模型上使用了折射着色器,则必须在模型的qc文件中指定$mostlyopaque参数,并为vmt设置$nowritez "1"$model "1"

请注意,排序时折射的渲染开销很高。多层折射会导致严重的重叠绘制。避免使用大量的粒子贴图或彼此重叠渲染的多个折射表面。

语法

Refract
{
	$normalmap ...
	$dudvmap ...
	$refracttint "[1 1 1]"
	$refractamount .2
}
待完善: This material shader parameter has not been described.
$dudvmap(en) <texture(en)> (DX8)
折射的模式由法线贴图(DX9+)或DUDV贴图(DX8-)定义。可以是动画的。
$normalmap2(en) <texture(en)> (DX9 SM2) (存在于自 起源2007 以来)
如果指定了第二个法线贴图,它将与第一个法线贴图混合。
动画凸凹贴图的起始帧。
变换凸凹贴图纹理。
The default position is center .5 .5 scale 1 1 rotate 0 translate 0 0.
  1. center defines the point of rotation. Only useful if rotate is being used.
  2. scale fits the texture into the material the given number of times. 2 1 is a 50% scale in the horizontal X axis while the vertical Y axis is still at original scale.
  3. rotate rotates the texture counter-clockwise in degrees. Accepts any number, including negatives.
  4. translate shifts the texture by the given numbers. .5 will shift it half-way. 1 will shift it once completely over, which is the same as not moving it at all.
Note.png注意:All values must be included!
Icon-Bug.png错误:Scaling the texture may cause odd issues where the Texture Lock tool in Hammer will not actually lock the texture in place.  [todo tested in ?]
Icon-Bug.png错误:Rotating textures applied on brushes will rotate around the map origin (confirm: Orangebox engine only?). A fix for this is to change the center position in the VMT to the brush's origin.  [todo tested in ?]
待完善: This material shader parameter has not been described.
为折射着色,既可以均匀着色也可以逐像素着色。可以与$refracttint结合使用。
动画$refracttinttexture的起始帧。
Icon-Bug.png错误:传送门2$localrefract不兼容。  [todo tested in ?]
通过乘以法线贴图强度控制折射的强度。
Icon-Bug.png错误:传送门2$localrefract不兼容。  [todo tested in ?]
添加模糊效果。有效值为0、1和2(DX8-仅支持0和1)。
强制在填充率较低的显卡上使用此着色器。
在折射效果上添加一个反射贴图。
控制反射的红、绿和蓝通道的强度。可以使用任何正数。默认值为"[1 1 1]",表示100%的强度。
Note.png注意:由于值中包含空格字符,必须使用引号。
控制反射的对比度(en)。0为自然对比度,1为颜色完全平方(即color*color)。
控制反射的颜色饱和度。0为灰度,1为自然饱和度。
$fresnelreflection(en) <浮点型(en)> (存在于自 起源2006 以来)
Icon-Bug.png错误:已损坏 - 尽管存在此参数,但未为此着色器实现。  [todo tested in ?]
在边缘淡化折射效果。
$vertexcolormodulate(en) <void> (DX9 SM2) (存在于自 起源2007 以来)
待完善: 使用顶点颜色影响折射颜色。Alpha值会调整折射量。参见$vertexcolor
$basetexture(en) <texture(en)> (DX9 SM2)
使用纹理而不是渲染视图作为扭曲像素的来源。
待完善: 使用目标alpha进行遮罩
$forcealphawrite(en) <布尔值(en)> (DX9 SM2) (存在于自 起源2013 以来)
待完善: 强制材质将alpha写入目标缓冲区
待完善: 0 == 写入z,1 = 不写入z
$noviewportfixup(en) <整数(en)> (存在于自 异形丛生 以来)
不为当前视口调整UV。
$mirroraboutviewportedges(en) <整数(en)> (存在于自 异形丛生 以来)
不要在视口外采样。
$magnifyenable(en) <布尔值(en)> (存在于自 异形丛生 以来)
启用在$magnifycenter屏幕位置周围放大折射图像,放大比例为$magnifyscale
$magnifycenter(en) <向量2(en)> (存在于自 异形丛生 以来)
放大此屏幕位置周围的折射图像。
$magnifyscale(en) <浮点型(en)> (存在于自 异形丛生 以来)
放大折射图像的比例因子。
$localrefract(en) <布尔值(en)> (存在于自 传送门2 以来)
对基底纹理应用简单的视差效果。
$localrefractdepth(en) <浮点型(en)> (存在于自 传送门2 以来)
视差效果的深度(单位)。
$spitternoisetexture(en) <texture(en)> (存在于 L4D2(en)? 之中)
类似于$flow_noise_texture但也会使材质呈现绿色。在"Particle/warp_pool_01.vmt"中可见。

注意事项

  • 目前无法定义整体alpha遮罩以指示折射效果的衰减位置。这只适用于基于刷子和模型的几何体,而不适用于粒子。为了在基于刷子或模型的几何体上实现alpha效果,可以创建一个带有alpha通道的法线贴图,并将其定义为第一个$normalmap。然后使用另一个法线贴图作为$normalmap2$normalmap2将继承第一个法线贴图的alpha,并相应地起作用。这对于模拟效果(如表面上的滚动水)非常有用,其中第一个法线贴图提供alpha,第二个法线贴图可以沿该alpha移动。
  • 如果在模型的某一部分上使用Refract,则必须在模型的qc文件中指定$mostlyopaque参数,并为vmt设置$nowritez "1"$model "1"
  • 此着色器无法与water(en)的动态反射和sky_camera(en)正常工作。仅适用于刷子,如果刷子是world geometry(en)func_detail(en)。此错误不会出现在次级摄像头(func_reflective_glass(en)func_monitor(en)portals(en))中。

另见