You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extensions/2.0/Vendor/EXT_textureInfo_constant_lod/README.md
+36-18Lines changed: 36 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,9 @@ Written against the glTF 2.0 spec.
20
20
21
21
## Overview
22
22
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.
24
24
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:
@@ -32,25 +32,43 @@ The `EXT_textureInfo_constant_lod` extension defines properties needed to calcul
32
32
33
33
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.
34
34
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.
50
68
51
69
## Implementation Notes
52
70
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.
54
72
55
73
In the vertex shader, where $worldPosition$ is the vertex position in world coordinates and $eyeSpace$ is the vertex position in camera coordinates:
Copy file name to clipboardExpand all lines: extensions/2.0/Vendor/EXT_textureInfo_constant_lod/schema/textureInfo.EXT_textureInfo_constant_lod.schema.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
"properties": {
10
10
"repetitions": {
11
11
"type": "number",
12
-
"description": "The number of times the texture is repeated.",
12
+
"description": "The number of times the texture is repeated per meter.",
0 commit comments