Refract: Difference between revisions
Deprecated (talk | contribs) (Revamped with MatParam templates, added new parameters) |
m (→Syntax) |
||
Line 30: | Line 30: | ||
{{VMT UVtransform}}}} | {{VMT UVtransform}}}} | ||
{{MatParam|$refracttint|RGB matrix}} | {{MatParam|$refracttint|RGB matrix}} | ||
{{MatParam|$refracttinttexture|texture|Tints the colour of the refraction either uniformly or per-texel.}} | {{MatParam|$refracttinttexture|texture|Tints the colour of the refraction either uniformly or per-texel. Can be used in conjunction with '''$refracttint'''}} | ||
{{MatParam|$refracttinttextureframe|int|Frame to start an animated <code>$refracttinttexture</code> on.}} | {{MatParam|$refracttinttextureframe|int|Frame to start an animated <code>$refracttinttexture</code> on.}} | ||
{{MatParam|$refractamount|float|Controls the strength of the refraction by multiplying the normal map intensity.}} | {{MatParam|$refractamount|float|{{Bug|{{portal2}} Incompatible with '''$localrefract'''.}}Controls the strength of the refraction by multiplying the normal map intensity.}} | ||
{{MatParam|$bluramount|int|Adds a blur effect. Valid values are 0, 1 and 2 (0 and 1 for DX8-).}} | {{MatParam|$bluramount|int|{{Bug|{{portal2}} Incompatible with '''$localrefract'''.}}Adds a blur effect. Valid values are 0, 1 and 2 (0 and 1 for DX8-).|}} | ||
{{MatParam|$forcerefract|bool|Forces the shader to be used for cards with poor fill rate.|dx8=1}} | {{MatParam|$forcerefract|bool|Forces the shader to be used for cards with poor fill rate.|dx8=1}} | ||
{{MatParam|[[$envmap]]|texture|Adds a cubemap reflection on top of the refraction.}} | {{MatParam|[[$envmap]]|texture|Adds a cubemap reflection on top of the refraction.}} | ||
Line 52: | Line 52: | ||
{{MatParam|$magnifycenter|vector2|Magnify the refracted image around this screen position.|since={{as}}}} | {{MatParam|$magnifycenter|vector2|Magnify the refracted image around this screen position.|since={{as}}}} | ||
{{MatParam|$magnifyscale|float|Magnify the refracted image by this factor.|since={{as}}}} | {{MatParam|$magnifyscale|float|Magnify the refracted image by this factor.|since={{as}}}} | ||
{{MatParam|$localrefract|bool| | {{MatParam|$localrefract|bool|Apply a simple parallax effect to the basetexture.|since={{portal2}}}} | ||
{{MatParam|$localrefractdepth|float|Depth of the parallax effect in units.|since={{portal2}}}} | {{MatParam|$localrefractdepth|float|Depth of the parallax effect in units.|since={{portal2}}}} | ||
Revision as of 14:18, 3 February 2022

Refract
It distorts objects behind it. It is similar to Water
, but does not have real-time reflections and so is not restricted to flat surfaces. Can be used to create distorting glass windows, ice, etc.
The refraction effect is achieved by first rendering the view without the refracting surface, and then using the normal map to distort the image by replacing pixel coordinates with new ones from the pre-rendered view by projecting along the normals.


$model "1"
.
Refract
shader will not render when applied on the same entity.Keep in mind that refraction is expensive to render when sorted. Multiple layers of refraction can cause immense overdraw. Avoid having large amounts of particle sheets, or multiple surfaces with refract that render above each other.
Syntax
Refract { $normalmap ... $dudvmap ... $refracttint "[1 1 1]" $refractamount .2 }
$normalmap
$dudvmap
$normalmap2
$bumpframe
$bumptransform
$refracttint
$refracttinttexture
$refracttinttextureframe
$refractamount
$bluramount
$forcerefract
[[$envmap|$envmap]]
$envmaptint
$envmapcontrast
$envmapsaturation
$fresnelreflection
$fadeoutonsilhouette
$vertexcolormodulate
$basetexture
$masked
$forcealphawrite
$nowritez
$noviewportfixup
$mirroraboutviewportedges
$magnifyenable
$magnifycenter
$magnifyscale
$localrefract
$localrefractdepth
Caveats
- Currently it is not possible to define an overall alpha mask to indicate where to fall-off refract. This however only applies to the brush based and model geometry, and not particles. To get alpha on brush or model based geometry you can create a normal map with an alpha channel, and define that as the first
$normalmap
. Using another normal of your choice you can then define a normal map for$normalmap2
.$normalmap2
will inherit the alpha of the first normalmap, and will act accordingly. This is extremely useful for faking effects like scrolling water of a surface. Where the first normal map can provide the alpha, and the second normal map can move along that alpha. - If
Refract
is used on a part of a model, the rest of the model will be rendered invisible when seen through the refractive part due to render sorting. Consider making the refractive part a separate model to remedy the issue.