Complex Shader Processes

From C4 Engine Wiki
Jump to navigation Jump to search

This is a list of the complex shader processes that are available in the Shader Editor under the Complex tab.

Process

Description

Diffuse Reflection

Inputs: Tangent-space normal N (optional)

Output: Scalar

Calculates the Lambertian diffuse reflection factor N · L, where L is the tangent-space direction to light. The result is saturated to the range [0,1]. If N is omitted, then it's as if N is (0,0,1).

This process implicitly uses the tangent light direction interpolant.

If the ambient reflection output depends on this process, then the results are undefined.

Specular Reflection

Inputs: Tangent-space normal N (optional), Specular power p (required)

Output: Scalar

Calculates the Blinn specular reflection factor (N · H)p, where H is the tangent-space direction halfway between the direction to light and direction to viewer. If N is omitted, then it's as if N is (0,0,1). The specular power p controls the sharpness of the specularity.

This process implicitly uses the tangent halfway direction interpolant, which in turn uses the tangent light direction and tangent view direction interpolants.

If the ambient reflection output depends on this process, then the results are undefined.

Microfacet Reflection

Inputs: Tangent-space normal N (optional)

Output: RGB color

Calculates the Cook-Torrance microfacet reflection color. If N is omitted, then it's as if N is (0,0,1).

This process implicitly uses the tangent light direction, tangent view direction, and tangent halfway direction interpolants.

If the ambient reflection output depends on this process, then the results are undefined.

Terrain Diffuse Reflection

Inputs: Terrain normal N1 (optional), Terrain normal N2 (optional), Terrain normal N3 (optional)

Output: Scalar

Calculates the Lambertian diffuse reflection factor for terrain. If any of the three inputs is missing, then the tangent-space normal vector is assumed to be (0,0,1). If all three inputs are present, then bump-mapped shading is performed. The three inputs should come from the three Terrain Normal processes.

If the ambient reflection output depends on this process, then the results are undefined.

Terrain Specular Reflection

Inputs: Terrain normal N1 (optional), Terrain normal N2 (optional), Terrain normal N3 (optional), Specular power p (required)

Output: Scalar

Calculates the Blinn specular reflection factor for terrain. If any of the three inputs is missing, then the tangent-space normal vector is assumed to be (0,0,1). If all three inputs are present, then bump-mapped shading is performed. The three inputs should come from the three Terrain Normal processes. The specular power p controls the sharpness of the specularity.

If the ambient reflection output depends on this process, then the results are undefined.

Combine Normals

Inputs: Normal vector N1 (required), Normal vector N2 (required), Scalar t (optional)

Output: 3D vector

If t is omitted, calculates a new normal vector corresponding to the normal that would be produced if the two height maps producing the input normals were added together.

If t is not omitted, then it determines how the heights are weighted, with the height corresponding to N1 being weighted most when t is zero and the height corresponding to N2 being weighted most when t is one. A value for t of 0.5 does produces an average height, which is not the same as the sum produces when t is omitted.

Front Normal

Inputs: Normal vector N (required)

Output: 3D vector

Calculates a new normal vector by negating the z component of the input vector if the z component of the tangent-space light direction is negative. Otherwise, the input vector is passed through unchanged. This is useful when rendering two-sided triangles with a normal map because it has the effect of always facing the normal vector to the front with respect to the light direction.

This process implicitly uses the tangent light direction interpolant.

If the ambient reflection output depends on this process, then the results are undefined.

Tip: This process should not be used in impostor shaders.

Reflect Vector

Inputs: 3D vector V (required), 3D vector N (optional)

Output: 3D vector

Calculates the reflection of the vector V across the vector N. If N is omitted, then it's as if N is (0,0,1).

Smooth Parameter

Inputs: Value t (required)

Output: Value of size matching t

Calculates 3t2 − 2t3 componentwise. This has the effect of smoothing an interpolation parameter within the range [0,1] since the derivative at both endpoints is zero.

Steep Parameter

Inputs: Value t (required)

Output: Value of size matching t

Calculates 2t − t2 componentwise. This has the effect of making an interpolation start quickly at a steep slope and finish smoothly.

Linear Ramp

Inputs: Value A (required)

Output: Value of size matching A

Remaps the range [c − ½wc + ½w] to the range [0,1] componentwise, where c is a center value and w is the width of the input range. The values of c and w are specified in the settings for the process.

Delta Depth

Inputs: None

Output: Scalar

Outputs the difference between the depth of the geometry in the structure buffer and the depth of the fragment being shaded, scaled by a factor s and clamped to the range [0,1]. The scale factor s is specified in the settings for the process.

If rendering to the structure buffer is disabled, then the output value is always 1.0.

Tangent to World Transform

Inputs: 3D vector V (required)

Output: 3D vector

Transforms the vector V from tangent space coordinates into world space coordinates.

This process implicitly uses three 3D vector interpolants containing the matrix that transforms from tangent space to world space.

Parallax Offset

Inputs: 2D vector TEXC (required)

Output: 2D vector

Perturbs the input texture coordinates using the parallax information in the normal map and outputs the result. The normal map is specified in the settings for the process. If parallax mapping is disabled, then the input texture coordinates TEXC are simply passed through to the output.

This process implicitly uses the tangent view direction interpolant.

Horizon Shadow

Inputs: 2D vector TEXC (required), RGB color RGB (required)

Output: RGB color

Calculates the horizon map shadowing based on the two input horizon map sampled at the texture coordinates TEXC and multiplies the input color RGB by the amount of light reaching the surface. The horizon map is specified in the settings for the process. Flags for excluding horizon mapping for infinite or points lights can also be set. If horizon mapping is disabled or the shader is used in conjunction with a light type that has been excluded, then the input color RGB is simply passed through to the output.

This process implicitly uses the tangent light direction interpolant.

If the ambient reflection output depends on this process, then the results are undefined.

Kill Fragment

Inputs: Scalar A (required), Scalar B (optional)

Output: None

Kills the current fragment if A < B. If B is omitted, then the fragment is killed if A < 0.

See Also