Complex Shader Processes

From C4 Engine Wiki

Jump to: navigation, search
Diffuse Reflection

Image:sh_diffuse.png

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.

This process is not available in ambient shaders.

Specular Reflection

Image:sh_specular.png

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.

This process is not available in ambient shaders.

Microfacet Reflection

Image:sh_microfacet.png

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.

This process is not available in ambient shaders.

Terrain Diffuse Reflection

Image:sh_terraindiffuse.png

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.

This process is not available in ambient shaders.

Terrain Specular Reflection

Image:sh_terrainspecular.png

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.

This process is not available in ambient shaders.

Combine Normals

Image:sh_combinenormals.png

Inputs: Normal vector N1 (required), Normal vector N2 (required)

Output: 3D vector

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.

Front Normal

Image:sh_frontnormal.png

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.

This process is not available in ambient shaders.

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

Reflect Vector

Image:sh_reflectvector.png

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

Image:sh_smooth.png

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.

Tangent to World Transform

Image:sh_tangenttoworld.png

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

Image:sh_parallax.png

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 Process Info window. 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

Image:sh_horizon.png

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

Output: RGB color

Calculates the horizon map shadowing based on the two input horizon maps sampled at the texture coordinates TEXC and multiplies the input color RGB by the amount of light reaching the surface. The horizon maps are specified in the Process Info window. 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.

This process is not available in ambient shaders.

Kill Fragment

Image:sh_kill.png

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.

Geometry Transition Kill

Image:sh_geometryxkill.png

Inputs: None

Output: None

Kills the current fragment for a real model based on its transition state to an impostor.

This process should appear in both the ambient and light shaders for materials applied to geometry nodes.

Impostor Transition Kill

Image:sh_impostorxkill.png

Inputs: None

Output: None

Kills the current fragment for an impostor based on its transition state from a real model.

This process should appear in both the ambient and light shaders for materials applied to impostor nodes.

Generate Impostor Normal

Image:sh_genimpostornormal.png

Inputs: None

Output: RGB color

Generates the normal vector for the color channels of an impostor normal map. The output of this process should be routed directly to the Lighting Output process.

Generate Impostor Depth

Image:sh_genimpostordepth.png

Inputs: None

Output: Scalar

Generates the depth for the alpha channel of an impostor normal map. The output of this process should be routed directly to the Alpha Output process.


See Also

Personal tools