Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common material spec: handling of specular exponent #510

Merged
merged 2 commits into from
Jan 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions extensions/Khronos/KHR_materials_common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ Table 1. Common Material Shared Properties
| `shininess` | `FLOAT` | Defines the specularity or roughness of the specular reflection lobe of the object. | 0.0 | `BLINN`, `PHONG` |
| `transparency` | `FLOAT` | Declares the amount of transparency as an opacity value between 0.0 and 1.0. | 1.0 | `BLINN`, `PHONG`, `LAMBERT`, `CONSTANT` |
| `transparent` | `boolean` | Declares whether the visual should be rendered using alpha blending. Corresponds to enabling the `BLEND` render state, setting the `depthMask` property to `false`, and defining blend equations and blend functions as described in the implementation note. | `false` | |

> **Implementation Note**: An implementation should render alpha-blended visuals in depth-sorted order. An implementation should define blend equations and blend functions that result in properly blended RGB and alpha values, such as in the following example:

```
functions: {
blendEquationSeparate: [
WebGLConstants.FUNC_ADD,
WebGLConstants.FUNC_ADD
],
blendFuncSeparate: [
WebGLConstants.ONE,
WebGLConstants.ONE_MINUS_SRC_ALPHA,
WebGLConstants.ONE,
WebGLConstants.ONE_MINUS_SRC_ALPHA
]
}
```

> **Implementation Note**: An implementation should render alpha-blended visuals in depth-sorted order. An implementation should define blend equations and blend functions that result in properly blended RGB and alpha values, such as in the following example:
```
functions: {
blendEquationSeparate: [
WebGLConstants.FUNC_ADD,
WebGLConstants.FUNC_ADD
],
blendFuncSeparate: [
WebGLConstants.ONE,
WebGLConstants.ONE_MINUS_SRC_ALPHA,
WebGLConstants.ONE,
WebGLConstants.ONE_MINUS_SRC_ALPHA
]
}
```

#### Blinn

Expand All @@ -100,15 +100,13 @@ When the value of `technique` is `BLINN`, this defines a material shaded accordi
This equation is complex and detailed via the ACM, so it is not detailed here. Refer to “Models of Light
Reflection for Computer Synthesized Pictures,” SIGGRAPH 77, pp 192-198 [http://portal.acm.org/citation.cfm?id=563893](http://portal.acm.org/citation.cfm?id=563893).

To maximize application compatibility, it is suggested that developers use the Blinn-Torrance-Sparrow model for
`shininess` values in the range of 0 to 1. For `shininess` values greater than 1.0, it is recommended to instead use the Blinn-Phong approximation:
The following code illustrates the basic computation:

```
color = <emission> + <ambient> * al + <diffuse> * max(N * L, 0) + <specular> * max(H * N, 0)^<shininess>
```


where:
where

* `al` – A constant amount of ambient light contribution coming from the scene, i.e. the sum of all ambient light values.
* `N` – Normal vector
Expand All @@ -117,6 +115,7 @@ where:
* `H` – Half-angle vector,calculated as halfway between the unit Eye and Light vectors, using the
equation H= normalize(I+L)

> **Implementation Note**: Writers should be aware about the range of the specular exponent (`shininess`), which is _not_ a normalized range. Concretely speaking, given the above equation, a `shininess` value of 1 corresponds to a very low shininess. For orientation: using the traditional OpenGL fixed function pipeline, the specular exponent was expected to be within [0, 128]. However, using glTF, larger `shininess` values are clearly possible.

Blinn shading uses all of the common material properties defined in Table 1. The following example defines a Blinn shaded material with a diffuse texture, moderate shininess and red specular highlights.

Expand Down Expand Up @@ -158,6 +157,8 @@ where:
* `I` – Eye vector
* `R` – Perfect reflection vector (reflect (L around N))

> **Implementation Note**: For the interpretation of the specular exponent parameter (`shininess`), see the section about the [Blinn](#blinn) lighting model.

Phong lighting uses all of the common material properties defined in Table 1. The following example defines a Phong lit material with a yellow diffuse color.

```javascript
Expand Down Expand Up @@ -315,9 +316,9 @@ Lights are glTF scene objects: they have position and orientation, which can be
}
}
}
```

For light types that have a direction (directional and spot lights), the light's direction is defined as the vector (0, 0, -1) and the rotation of the node orients the light accordingly.
```
For light types that have a direction (directional and spot lights), the light's direction is defined as the vector (0, 0, -1) and the rotation of the node orients the light accordingly.


### Light Types
Expand Down