@d5techs/3dgs-lib 1.4.50 → 1.4.51
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/3dgs-lib.cjs +15 -17
- package/dist/3dgs-lib.cjs.map +1 -1
- package/dist/3dgs-lib.js +15 -17
- package/dist/3dgs-lib.js.map +1 -1
- package/package.json +1 -1
package/dist/3dgs-lib.cjs
CHANGED
|
@@ -2142,28 +2142,26 @@ fn vs(@builtin(vertex_index) vi: u32) -> VSOut {
|
|
|
2142
2142
|
fn fs(input: VSOut) -> @location(0) vec4<f32> {
|
|
2143
2143
|
let dir = normalize(input.dir);
|
|
2144
2144
|
|
|
2145
|
-
let
|
|
2145
|
+
let camX = u.extra.y;
|
|
2146
2146
|
let camY = u.extra.z;
|
|
2147
|
+
let camZ = u.extra.w;
|
|
2147
2148
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2149
|
+
let doGround = u.extra.x > 0.5 && dir.y < -0.001 && camY > 0.01;
|
|
2150
|
+
let safeDirY = select(dir.y, -0.01, dir.y > -0.001);
|
|
2151
|
+
let t = camY / (-safeDirY);
|
|
2152
|
+
let gx = camX + dir.x * t;
|
|
2153
|
+
let gz = camZ + dir.z * t;
|
|
2154
|
+
let scale = max(camY, 1.0) * 5.0;
|
|
2155
|
+
let groundDir = normalize(vec3<f32>(gx / max(scale, 0.01), -1.0, gz / max(scale, 0.01)));
|
|
2151
2156
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
let gz = camZ + dir.z * t;
|
|
2157
|
+
let skyColor = textureSample(cubeTexture, cubeSampler, dir);
|
|
2158
|
+
let groundColor = textureSample(cubeTexture, cubeSampler, groundDir);
|
|
2155
2159
|
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
let groundColor = textureSample(cubeTexture, cubeSampler, groundDir);
|
|
2159
|
-
let skyColor = textureSample(cubeTexture, cubeSampler, dir);
|
|
2160
|
+
let blend = smoothstep(0.0, -0.12, dir.y);
|
|
2161
|
+
let mixed = mix(skyColor.rgb, groundColor.rgb, blend);
|
|
2160
2162
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
let color = textureSample(cubeTexture, cubeSampler, dir);
|
|
2166
|
-
return vec4<f32>(color.rgb, 1.0);
|
|
2163
|
+
let final_color = select(skyColor.rgb, mixed, doGround);
|
|
2164
|
+
return vec4<f32>(final_color, 1.0);
|
|
2167
2165
|
}
|
|
2168
2166
|
`
|
|
2169
2167
|
);
|