Skip to content

Commit

Permalink
Loosen the camera angle bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Dec 31, 2022
1 parent 18b4b0b commit 34a67c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions BlueMapCommon/webapp/src/js/MapViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion BlueMapCommon/webapp/src/js/controls/map/MapControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct TileMap {
vec2 pos;
};
uniform float distance;
uniform float sunlightStrength;
uniform float ambientLight;
uniform TileMap hiresTileMap;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions BlueMapCommon/webapp/src/js/map/lowres/LowresVertexShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,7 +59,7 @@ void main() {
vec4 viewPos = viewMatrix * worldPos;
vWorldPosition = worldPos.xyz;
vDistance = -viewPos.z;
//vDistance = -viewPos.z;
gl_Position = projectionMatrix * viewPos;
Expand Down

0 comments on commit 34a67c7

Please sign in to comment.