Refract
Jump to navigation
Jump to search

A refracting func_brush.
The Refract
shaders distorts objects behind it. It is similar to Water
, but does not reflect and so is not restricted to flat surfaces. Can be used to create distorting glass windows 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.



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|$normalmap]]
[[$dudvmap|$dudvmap]]
$normalmap2
$refracttint
$refracttinttexture
- Tints the colour of the refraction either uniformly or per-texel.
$refractamount
- Controls the strength of the refraction by multiplying the normal map intensity.
$bluramount
- Adds a blur effect. Valid values are 0, 1 and 2 (0 and 1 for DX8-).
$forcerefract
- Forces the shader to be used for cards with poor fill rate.
[[$envmap|$envmap]]
- Adds a cubemap reflection to the refraction.
$envmaptint
- Controls the intensity of the reflection's red, green and blue color channels. Any positive number can be used. Default is
"[1 1 1]"
, which means 100% intensity. Note:You must use quotemarks, as there are space characters within the value.
$envmapcontrast
- Controls the contrast of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).
$envmapsaturation
- Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.
$fresnelreflection
Bug:Broken - Not implemented despite the parameter existing. [todo tested in ?]
$vertexcolormodulate
- Todo: See $vertexcolor.
$basetexture
- Uses a texture instead of rendering the view for the source of the distorted pixels.
$masked
- Todo: mask using dest alpha
$forcealphawrite
- Todo: Force the material to write alpha to the dest buffer
$nowritez
- Todo: 0 == write z, 1 = no write z
$fadeoutonsilhouette
- Fades out the effect around edges.
$localrefract
- Uses alpha channel of base texture to create a parallax effect.
$localrefractdepth
- Depth of the parallax effect in units.
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 normalmap with an alpha channel, and define that as the first $normalmap. Using another normal of your choice you can then define a normalmap 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 normalmap can provide the alpha, and the second normalmap 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. Consider making the refractive part a separate model to remedy the issue.