Loosen the camera angle bounds

This commit is contained in:
Lukas Rieger (Blue) 2022-12-31 10:35:58 +01:00
parent 18b4b0b220
commit 34a67c7c44
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
4 changed files with 10 additions and 6 deletions

View File

@ -55,6 +55,7 @@ export class MapViewer {
camera: null,
controlsManager: null,
uniforms: {
distance: { value: 0 },
sunlightStrength: { value: 1 },
ambientLight: { value: 0 },
skyColor: { value: new Color(0.5, 0.5, 1) },
@ -303,6 +304,7 @@ export class MapViewer {
this.camera.position.z -= sZ;
// update uniforms
this.data.uniforms.distance.value = this.controlsManager.distance;
this.data.uniforms.hiresTileMap.value.pos.copy(this.map.hiresTileManager.centerTile);
this.data.uniforms.hiresTileMap.value.translate.set(
this.map.data.hires.translate.x - sX,
@ -374,6 +376,7 @@ export class MapViewer {
this.renderer.initTexture(texture);
}
this.data.uniforms.distance.value = this.controlsManager.distance;
this.data.uniforms.skyColor.value = map.data.skyColor;
this.data.uniforms.ambientLight.value = map.data.ambientLight;
this.data.uniforms.hiresTileMap.value.map = map.hiresTileManager.tileMap.texture;

View File

@ -214,7 +214,7 @@ export class MapControls {
}
getMaxPerspectiveAngleForDistance(distance) {
return MathUtils.clamp((1 - Math.pow(Math.max(distance - 5, 0.001) / 500, 0.5)) * HALF_PI,0, HALF_PI)
return MathUtils.clamp((1 - Math.pow(Math.max(distance - 5, 0.001) * 0.0005, 0.5)) * HALF_PI,0, HALF_PI)
}
initializeHammer() {

View File

@ -41,6 +41,7 @@ struct TileMap {
vec2 pos;
};
uniform float distance;
uniform float sunlightStrength;
uniform float ambientLight;
uniform TileMap hiresTileMap;
@ -52,7 +53,7 @@ uniform float lodScale;
varying vec3 vPosition;
varying vec3 vWorldPosition;
varying float vDistance;
//varying float vDistance;
float metaToHeight(vec4 meta) {
float heightUnsigned = meta.g * 65280.0 + meta.b * 255.0;
@ -78,7 +79,7 @@ vec2 posToMetaUV(vec2 pos) {
void main() {
//discard if hires tile is loaded at that position
if (vDistance < 900.0 && texture(hiresTileMap.map, ((vWorldPosition.xz - hiresTileMap.translate) / hiresTileMap.scale - hiresTileMap.pos) / hiresTileMap.size + 0.5).r > 0.75) discard;
if (distance < 1000.0 && texture(hiresTileMap.map, ((vWorldPosition.xz - hiresTileMap.translate) / hiresTileMap.scale - hiresTileMap.pos) / hiresTileMap.size + 0.5).r > 0.75) discard;
vec4 color = texture(textureImage, posToColorUV(vPosition.xz));
color.a = 1.0; // don't use alpha channel
@ -96,7 +97,7 @@ void main() {
float aoStrength = 0.0;
if(lod == 1.0) {
aoStrength = smoothstep(PI - 0.8, PI - 0.2, acos(-clamp(viewMatrix[1][2], 0.0, 1.0)));
aoStrength *= 1.0 - smoothstep(300.0, 500.0, vDistance);
aoStrength *= 1.0 - smoothstep(200.0, 600.0, distance);
if (aoStrength > 0.0) {
const float r = 3.0;

View File

@ -34,7 +34,7 @@ uniform vec2 textureSize;
varying vec3 vPosition;
varying vec3 vWorldPosition;
varying float vDistance;
//varying float vDistance;
float metaToHeight(vec4 meta) {
float heightUnsigned = meta.g * 65280.0 + meta.b * 255.0;
@ -59,7 +59,7 @@ void main() {
vec4 viewPos = viewMatrix * worldPos;
vWorldPosition = worldPos.xyz;
vDistance = -viewPos.z;
//vDistance = -viewPos.z;
gl_Position = projectionMatrix * viewPos;