Skip to content

Commit 32d7a8c

Browse files
committed
Improve spec
1 parent 7b0ac09 commit 32d7a8c

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

extensions/2.0/Vendor/EXT_textureInfo_constant_lod/README.md

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Written against the glTF 2.0 spec.
2020

2121
## Overview
2222

23-
Constant level-of-detail ("LOD") is a technique of texture coordinate generation which dynamically calculates coordinates to keep the texture near a certain size on the screen, thus preserving the level of detail no matter what the zoom level. It blends from one size of the texture to another as the view is zoomed in or out so that the change is smooth.
23+
Constant level-of-detail ("LOD") is a technique of texture coordinate generation which dynamically calculates texture coordinates to keep the texture near a certain size on the screen, thus preserving the level of detail no matter the zoom level. It blends from one size of the texture to another as the view is zoomed in or out so that the change is smooth.
2424

25-
The `EXT_textureInfo_constant_lod` extension defines properties needed to calculate these texture coordinates: the number of times the texture is repeated, an offset to shift the texture, the minimum and maximum distance for which to clamp the texture. The minimum and maximum clamp distance control at which point the texture sizes should be blended. These images illustrate the textures blending to create the constant LOD effect:
25+
The `EXT_textureInfo_constant_lod` extension defines properties needed to calculate these dynamic texture coordinates: the number of times the texture is repeated per meter, an offset to shift the texture, and the minimum and maximum distance for which to clamp the texture. The minimum and maximum clamp distance control at which point the texture sizes should be blended. These images illustrate the textures blending to create the constant LOD effect:
2626

2727
![Constant LOD gif](./figures/constantlod.gif "Constant LOD gif")
2828

@@ -32,25 +32,43 @@ The `EXT_textureInfo_constant_lod` extension defines properties needed to calcul
3232

3333
The `EXT_textureInfo_constant_lod` extension is defined on `textureInfo` structures. When that `textureInfo` is used by a material, this extension applies the constant LOD technique to the specified texture.
3434

35-
### Repetitions
36-
37-
The `repetitions` property specifies the number of times the texture is repeated. Increasing this will make the texture pattern appear smaller, decreasing it will make it larger.
38-
39-
### Offset
40-
41-
The `offset` property is used to shift the texture, specified as a pair of numbers in meters in the format [X, Y].
42-
43-
### Minimum Clamp Distance
44-
45-
The `minClampDistance` property specifies the minimum distance in meters from the eye to the surface at which to clamp the texture.
46-
47-
### Maximum Clamp Distance
48-
49-
The `maxClampDistance` property specifies the maximum distance in meters from the eye to the surface at which to clamp the texture.
35+
Constant LOD uses the following properties:
36+
37+
* `repetitions` - specifies the number of times the texture is repeated per meter in both the X and Y dimensions. Increasing this will make the texture pattern appear smaller, decreasing it will make it larger.
38+
* `offset` - used to shift the texture, specified as a pair of numbers in meters in the format [X, Y].
39+
* `minClampDistance` - specifies the minimum distance in meters from the camera to the surface at which to clamp the texture.
40+
* `maxClampDistance` - specifies the maximum distance in meters from the camera to the surface at which to clamp the texture.
41+
42+
For example, the following JSON defines a material with a texture at index 0 that is modified by the `EXT_textureInfo_constant_lod` extension. The extension has a `repetitions` value of 2 causing it to be repeated twice per meter, making its pattern appear half the size. It is shifted by 1 meter in the X direction and 0 meters in the Y direction. It also has a minimum clamp distance of 0.5 meters, meaning the constant LOD effect stops being present when the camera is 0.5m away from the surface or closer. This is a closer distance than the default value of 1m, meaning for this material you would have to zoom in closer for the texture to stop adapting its level of detail and for it to appear magnified. The absence of the `maxClampDistance` property means it has a default value of $2^{32}$, so the constant LOD effect will occur until the camera is $2^{32}$ away from the surface.
43+
44+
```json
45+
"materials": [
46+
{
47+
"pbrMetallicRoughness": {
48+
"baseColorTexture": {
49+
"index": 0,
50+
"texCoord": 0,
51+
"extensions": {
52+
"EXT_textureInfo_constant_lod": {
53+
"repetitions": 2,
54+
"offset": [1, 0],
55+
"minClampDistance": 0.5
56+
}
57+
}
58+
},
59+
"baseColorFactor": [1.0, 1.0, 1.0, 1.0],
60+
"metallicFactor": 0.0,
61+
"roughnessFactor": 1.0
62+
}
63+
}
64+
],
65+
```
66+
67+
Implementations should follow the formula explained in the Implementation Notes section to produce the desired visual effect.
5068

5169
## Implementation Notes
5270

53-
This is a general formula that can be used to calculate the two different texture coordinates and how to blend them.
71+
This section outlines the general formula that should be used to calculate the dynamic texture coordinates for constant LOD.
5472

5573
In the vertex shader, where $worldPosition$ is the vertex position in world coordinates and $eyeSpace$ is the vertex position in camera coordinates:
5674

extensions/2.0/Vendor/EXT_textureInfo_constant_lod/schema/textureInfo.EXT_textureInfo_constant_lod.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"properties": {
1010
"repetitions": {
1111
"type": "number",
12-
"description": "The number of times the texture is repeated.",
12+
"description": "The number of times the texture is repeated per meter.",
1313
"minimum": 1.0,
1414
"default": 1.0
1515
},

0 commit comments

Comments
 (0)