@d5techs/3dgs-lib 1.4.59 → 1.4.60

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 CHANGED
@@ -2239,41 +2239,41 @@ fn dirToUv(d: vec3<f32>) -> vec2<f32> {
2239
2239
  @fragment fn fs(i: V) -> @location(0) vec4<f32> {
2240
2240
  let d = normalize(i.dir);
2241
2241
  let camH = u.extra.x;
2242
- let projR = u.extra.y;
2242
+ let R = u.extra.y;
2243
2243
 
2244
- // --- sky UV (always computed for uniform control flow) ---
2244
+ // --- sky ---
2245
2245
  let skyUv = dirToUv(d);
2246
2246
 
2247
- // --- flat ground projection ---
2248
- // Ray from camera at height camH above ground, direction d,
2249
- // hits ground plane at t = -camH / d.y
2247
+ // --- ground: inverted bowl hemisphere at Y=0 ---
2250
2248
  let dyClamped = min(d.y, -0.0001);
2251
2249
  let t = -camH / dyClamped;
2252
2250
  let hitX = t * d.x;
2253
2251
  let hitZ = t * d.z;
2254
2252
  let hitDist = sqrt(hitX * hitX + hitZ * hitZ);
2255
2253
 
2256
- // Re-map to a direction on the HDR sphere from a virtual capture
2257
- // height above ground. Larger = more ground texture visible,
2258
- // smaller = more horizon. 15 matches Three.js GroundProjectedEnv default.
2259
- let captureH = 15.0;
2260
- let groundDir = normalize(vec3(hitX, -captureH, hitZ));
2254
+ // Clamp hit point inside the bowl radius
2255
+ let s = min(1.0, R * 0.999 / max(hitDist, 0.001));
2256
+ let bx = hitX * s;
2257
+ let bz = hitZ * s;
2258
+ // Project onto the lower hemisphere: y = -sqrt( - x² - z²)
2259
+ let bowlY = -sqrt(max(R * R - bx * bx - bz * bz, 0.0));
2260
+ let groundDir = normalize(vec3(bx, bowlY, bz));
2261
2261
  let groundUv = dirToUv(groundDir);
2262
2262
 
2263
- // --- sample both unconditionally (uniform control flow) ---
2264
- let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2263
+ // --- sample both (uniform control flow) ---
2264
+ let skyColor = textureSample(envTexture, envSampler, skyUv).rgb;
2265
2265
  let groundColor = textureSample(envTexture, envSampler, groundUv).rgb;
2266
2266
 
2267
- // Blend: smooth transition near horizon
2268
- let horizonBlend = smoothstep(0.0, -0.12, d.y);
2269
- let aboveGround = step(0.01, camH);
2270
- let edgeFade = 1.0 - smoothstep(projR * 0.6, projR, hitDist);
2271
- let finalBlend = horizonBlend * aboveGround * edgeFade;
2267
+ // Blend near horizon + fade at bowl edge
2268
+ let horizonBlend = smoothstep(0.0, -0.08, d.y);
2269
+ let aboveGround = step(0.01, camH);
2270
+ let edgeFade = 1.0 - smoothstep(R * 0.7, R, hitDist);
2271
+ let finalBlend = horizonBlend * aboveGround * edgeFade;
2272
2272
  let c = mix(skyColor, groundColor, finalBlend);
2273
2273
 
2274
2274
  // Reinhard tone mapping + gamma
2275
2275
  let mapped = c / (c + vec3(1.));
2276
- let gamma = pow(mapped, vec3(1./2.2));
2276
+ let gamma = pow(mapped, vec3(1./2.2));
2277
2277
  return vec4(gamma, 1.);
2278
2278
  }`
2279
2279
  );