Skip to content

Commit

Permalink
fix project_pixel_to_clipspace usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Mar 28, 2019
1 parent 1ba08b3 commit 5ac1e3b
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/core/src/shaderlib/project/viewport-uniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function calculateViewportUniforms({
// Distance at which screen pixels are projected
project_uFocalDistance: viewport.focalDistance || 1,
project_uCommonUnitsPerMeter: distanceScales.pixelsPerMeter,
project_uCommonUnitsPerWorldUnit: distanceScales.pixelsPerMeter,
project_uCommonUnitsPerWorldUnit: distanceScales.pixelsPerDegree,
project_uCommonUnitsPerWorldUnit2: DEFAULT_PIXELS_PER_UNIT2,
project_uScale: viewport.scale, // This is the mercator scale (2 ** zoom)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
vec2 offset_clipspace = project_pixel_size_to_clipspace(offset_screenspace);
return offset_clipspace;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/arc-layer/arc-layer-vertex-64.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
vec2 offset_clipspace = project_pixel_size_to_clipspace(offset_screenspace);
return offset_clipspace;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/arc-layer/arc-layer-vertex.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
vec2 offset_clipspace = project_pixel_size_to_clipspace(offset_screenspace);
return offset_clipspace;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/icon-layer/icon-layer-vertex.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main(void) {
pixelOffset.y *= -1.0;
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64xyLow, vec3(0.0));
gl_Position += project_pixel_to_clipspace(pixelOffset);
gl_Position.xy += project_pixel_size_to_clipspace(pixelOffset);
vTextureCoords = mix(
instanceIconFrames.xy,
Expand Down
2 changes: 1 addition & 1 deletion modules/layers/src/line-layer/line-layer-vertex.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
vec2 offset_clipspace = project_pixel_size_to_clipspace(offset_screenspace);
return offset_clipspace;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void main(void) {
// Find the center of the point and add the current vertex
vec4 position_commonspace;
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64xyLow, vec3(0.), position_commonspace);
gl_Position += project_pixel_to_clipspace(positions.xy * radiusPixels);
gl_Position.xy += project_pixel_size_to_clipspace(positions.xy * radiusPixels);
// Apply lighting
vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, position_commonspace.xyz, project_normal(instanceNormals));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void main(void) {
pixelOffset.y *= -1.0;
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64xyLow, vec3(0.0));
gl_Position += project_pixel_to_clipspace(pixelOffset);
gl_Position.xy += project_pixel_size_to_clipspace(pixelOffset);
vTextureCoords = mix(
instanceIconFrames.xy,
Expand Down
4 changes: 2 additions & 2 deletions test/modules/core/shaderlib/project/project-glsl.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ const TEST_CASES = [
]
},
{
title: 'LNGLAT_EXPERIMENTAL mode - auto offset',
title: 'LNGLAT mode - auto offset',
params: {
viewport: TEST_VIEWPORT_HIGH_ZOOM,
coordinateSystem: COORDINATE_SYSTEM.LNGLAT_EXPERIMENTAL
coordinateSystem: COORDINATE_SYSTEM.LNGLAT
},
tests: [
{
Expand Down

0 comments on commit 5ac1e3b

Please sign in to comment.