---
title: "faceForward / faceforward: WGSL and GLSL function guide"
description: "Face-forward chooses the sign of a normal from the dot product of a reference normal and an incident direction."
url: https://typeshade.dev/reference/functions/faceForward/
language: en
---

# `faceForward`

Function

Face-forward chooses the sign of a normal from the dot product of a reference normal and an incident direction.

**Related names in other languages**

These related operations can differ in arguments, support, and semantics. The foreign names are not accepted TypeShade aliases. Check the target forms and restrictions.

- GLSL: `faceforward`

[Targets](https://typeshade.dev/reference/functions/faceForward/#targets)

## Compare examples

Compare negative, positive, and zero reference dot products. Zero takes the negated-normal branch.

**Model assumptions**`n = nref = vec3(0, 1, 0)`

**Example 1`i = vec3(0, -1, 0)`**

**Result**

`vec3(0, 1, 0)`

**Example 2`i = vec3(0, 1, 0)`**

**Result**

`vec3(0, -1, 0)`

**Example 3`i = vec3(1, 0, 0)`**

**Result**

`vec3(0, -1, 0)`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it to orient a shading normal on a surface visible from either side.

## Inputs and limits

The reference normal makes the decision; the returned vector is the supplied normal or its negation. This call does not normalize either vector.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`dot`](https://typeshade.dev/reference/functions/dot/)
- [`reflect`](https://typeshade.dev/reference/functions/reflect/)
- [`normalize`](https://typeshade.dev/reference/functions/normalize/)

**WGSL**

`faceForward(a, b, c)`

**GLSL ES 3.00**

`faceforward(a, b, c)`

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Returns `n` if `dot(nref, i)` is negative, else `-n`: the normal that faces the incident vector.

## Syntax

```ts
declare function faceForward<V extends vec2 | vec3 | vec4>(a0: V, a1: V, a2: V): V
declare function faceForward<T extends Numeric>(a0: T, a1: T, a2: T): T
```

A signature may name a type the ambient file declares for its own use. These are those declarations.

**`Numeric`**

`type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u`

## Parameters

A parameter named by position (`a0`, `a1`) carries a name the ambient file generates. A call passes its arguments in order and names none of them.

- `a0` `V``T`
- `a1` `V``T`
- `a2` `V``T`

## Return value

`V``T`

## Description

`faceforward` on GLSL.

## Targets

**WGSL**

`faceForward(a, b, c)`

**GLSL ES 3.00**

`faceforward(a, b, c)`

## Examples

- [`gallery/bit-bump/bit-bump.shade.ts`](https://typeshade.dev/guide/examples/bit-bump/)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#geometry)
