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