Complex Shader Processes: Difference between revisions

From C4 Engine Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
{{Tablehead|Process|Description}}
{{Tablehead|Process|Description}}
|-
|-
{{Process|Diffuse Reflection|Shader_diffuse.png|Tangent-space normal '''N''' (optional)|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).
{{Process|Diffuse Reflection|Shader_diffuse.png|World-space or tangent-space normal '''N''' (optional)|Scalar|Calculates the Lambertian diffuse reflection factor '''N''' · '''L''', where '''L''' is the direction to light. The result is saturated to the range [0,1] and divided by pi. 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 implicitly uses the world light direction interpolant.
 
If the ambient reflection output depends on this process, then the results are undefined.}}
|-
{{Process|Specular Reflection|Shader_specular.png|World-space or tangent-space normal '''N''' (optional), Specular power ''p'' (required)|Scalar|Calculates the Blinn specular reflection factor sat('''N'''&nbsp;&middot;&nbsp;'''H''')<sup>''p''</sup>, where '''H''' is the 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) in tangent space. The specular power ''p'' controls the sharpness of the specularity.
 
This process implicitly uses the world halfway direction interpolant, which in turn uses the world light direction and world view direction interpolants.
 
If the ambient reflection output depends on this process, then the results are undefined.}}
|-
{{Process|Diffuse Transflection|Shader_transflection.png|World-space or tangent-space normal '''N''' (optional)|Scalar|Calculates the diffuse transflection factor '''N'''&nbsp;&middot;&nbsp;'''L''', where '''L''' is the direction to light. The result is multiplied by the front-facing factor ''f'' and divided by pi, and it is ''not'' saturated. If '''N''' is omitted, then it's as if '''N''' is (0,0,1) in tangent space.
 
This process implicitly uses the world light direction interpolant.


If the ambient reflection output depends on this process, then the results are undefined.}}
If the ambient reflection output depends on this process, then the results are undefined.}}
|-
|-
{{Process|Specular Reflection|Shader_specular.png|Tangent-space normal '''N''' (optional), Specular power ''p'' (required)|Scalar|Calculates the Blinn specular reflection factor ('''N'''&nbsp;&middot;&nbsp;'''H''')<sup>''p''</sup>, 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.
{{Process|Specular Transmission|Shader_transmission.png|Specular power ''p'' (required)|Scalar|Calculates the specular transmission factor sat(&minus;'''L'''&nbsp;&middot;&nbsp;'''V''')<sup>''p''</sup>, where '''L''' and '''V''' are the direction to light and direction to viewer. The specular power ''p'' controls the sharpness of the specularity. This produces a transmission strength when a material is viewed from the back side with respect to the incoming light.


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


If the ambient reflection output depends on this process, then the results are undefined.}}
If the ambient reflection output depends on this process, then the results are undefined.}}
Line 59: Line 71:
|-
|-
{{Process|Composite Buffer|Shader_composite.png|None|RGBA color|Samples from the composite buffer at the current fragment coordinates.}}
{{Process|Composite Buffer|Shader_composite.png|None|RGBA color|Samples from the composite buffer at the current fragment coordinates.}}
|-
{{Process|Generate Impostor Normal / Depth|Shader_genimpostor.png|3D vector '''N''' (optional)|RGBA color|When impostor textures are being generated, this process outputs the impostor normal in the RGB channels, and it outputs the impostor depth in the alpha channel.}}
|}
|}



Latest revision as of 04:14, 6 January 2025

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: World-space or tangent-space normal N (optional)

Output: Scalar

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

This process implicitly uses the world light direction interpolant.

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

Specular Reflection

Inputs: World-space or tangent-space normal N (optional), Specular power p (required)

Output: Scalar

Calculates the Blinn specular reflection factor sat(N · H)p, where H is the 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) in tangent space. The specular power p controls the sharpness of the specularity.

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

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

Diffuse Transflection

Inputs: World-space or tangent-space normal N (optional)

Output: Scalar

Calculates the diffuse transflection factor N · L, where L is the direction to light. The result is multiplied by the front-facing factor f and divided by pi, and it is not saturated. If N is omitted, then it's as if N is (0,0,1) in tangent space.

This process implicitly uses the world light direction interpolant.

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

Specular Transmission

Inputs: Specular power p (required)

Output: Scalar

Calculates the specular transmission factor sat(−L · V)p, where L and V are the direction to light and direction to viewer. The specular power p controls the sharpness of the specularity. This produces a transmission strength when a material is viewed from the back side with respect to the incoming light.

This process implicitly uses the world light direction and view 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 Normal Maps

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 produces an average height, which is not the same as the sum produces when t is omitted.

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.

Render Glyph

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

Output: RGBA color

Renders glyph or vector graphics with Slug. The TEXC input should use the Texcoord 2 interpolant, and the RGBA input would normally use the Vertex Color interpolant.

Composite Buffer

Inputs: None

Output: RGBA color

Samples from the composite buffer at the current fragment coordinates.

Generate Impostor Normal / Depth

Inputs: 3D vector N (optional)

Output: RGBA color

When impostor textures are being generated, this process outputs the impostor normal in the RGB channels, and it outputs the impostor depth in the alpha channel.

See Also