@adatechnology/game-terrain-three 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +18 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.global.js
CHANGED
|
@@ -144,8 +144,18 @@ float tsNoise(vec2 p) {
|
|
|
144
144
|
return mix(mix(tsHash(i), tsHash(i + vec2(1.0, 0.0)), f.x), mix(tsHash(i + vec2(0.0, 1.0)), tsHash(i + vec2(1.0, 1.0)), f.x), f.y);
|
|
145
145
|
}
|
|
146
146
|
float tsFbm(vec2 p) { return tsNoise(p) * 0.55 + tsNoise(p * 2.3 + 7.1) * 0.3 + tsNoise(p * 5.1 + 3.3) * 0.15; }
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
// a pixel wider than FAR_PIXEL_TO metres shows only the average of the pattern, PATTERN_MEAN of the base colour
|
|
148
|
+
const float FAR_PIXEL_FROM = 0.03;
|
|
149
|
+
const float FAR_PIXEL_TO = 0.12;
|
|
150
|
+
const float PATTERN_MEAN = 0.92;
|
|
151
|
+
// metres one pixel covers on the ground here: a line or a grain finer than that cannot be drawn, only its average can
|
|
152
|
+
float tsPixel = 0.0;
|
|
153
|
+
float tsLine(float value, float period, float width) {
|
|
154
|
+
float drawn = max(width, tsPixel);
|
|
155
|
+
float d = abs(fract(value / period + 0.5) - 0.5) * period;
|
|
156
|
+
return (1.0 - smoothstep(drawn * 0.6, drawn, d)) * (width / drawn);
|
|
157
|
+
}
|
|
158
|
+
vec3 terrainPattern(vec3 base, vec2 xz, float kind) {
|
|
149
159
|
float k = floor(kind + 0.5);
|
|
150
160
|
if (k < 0.5) return base * (0.86 + 0.28 * tsFbm(xz * 9.0));
|
|
151
161
|
if (k < 1.5) {
|
|
@@ -225,6 +235,12 @@ vec3 terrainSurface(vec3 base, vec2 xz, float kind) {
|
|
|
225
235
|
float grain = tsNoise(xz * 95.0);
|
|
226
236
|
return base * (0.62 + 0.75 * blotch) * (0.88 + 0.24 * grain) * (1.0 - 0.6 * joint);
|
|
227
237
|
}
|
|
238
|
+
/** The pattern where a pixel can hold it; far off, where a pixel covers more ground than the finest grain, its average, so that the grain does not sparkle as dots. */
|
|
239
|
+
vec3 terrainSurface(vec3 base, vec2 xz, float kind) {
|
|
240
|
+
tsPixel = max(length(dFdx(xz)), length(dFdy(xz)));
|
|
241
|
+
vec3 near = terrainPattern(base, xz, kind);
|
|
242
|
+
return mix(near, base * PATTERN_MEAN, smoothstep(FAR_PIXEL_FROM, FAR_PIXEL_TO, tsPixel));
|
|
243
|
+
}
|
|
228
244
|
`
|
|
229
245
|
);
|
|
230
246
|
function createSurfaceMaterial(THREE) {
|