Skip to content

Commit

Permalink
fix pixel to clipspace projection (visgl#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored May 29, 2018
1 parent 9ef477a commit 80dbf55
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/core/src/shaderlib/project/project.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ vec4 project_to_clipspace(vec4 position) {
// Returns a clip space offset that corresponds to a given number of **non-device** pixels
vec4 project_pixel_to_clipspace(vec2 pixels) {
vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio;
vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;
return vec4(offset * project_uFocalDistance, 0.0, 0.0);
}
`;
Binary file modified test/render/golden-images/text-layer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions test/render/test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const TEST_CASES = [
],
coordinateSystem: COORDINATE_SYSTEM.IDENTITY,
getColor: d => [255, 255, 0, 128],
strokeWidth: 10
strokeWidth: 5
})
],
referenceImageUrl: './test/render/golden-images/bezier-curve-2d.png'
Expand Down Expand Up @@ -141,7 +141,7 @@ export const TEST_CASES = [
getPosition: d => d.position,
getNormal: d => [0, 0.5, 0.2],
getColor: d => [255, 255, 0, 128],
radiusPixels: 100
radiusPixels: 50
})
],
referenceImageUrl: './test/render/golden-images/pointcloud-identity.png'
Expand Down Expand Up @@ -317,6 +317,7 @@ export const TEST_CASES = [
new ArcLayer({
id: 'arc-lnglat',
data: dataSamples.routes,
strokeWidth: 0.5,
getSourcePosition: d => d.START,
getTargetPosition: d => d.END,
getSourceColor: d => [64, 255, 0],
Expand All @@ -339,6 +340,7 @@ export const TEST_CASES = [
new ArcLayer({
id: 'arc-lnglat-64',
data: dataSamples.routes,
strokeWidth: 0.5,
fp64: true,
getSourcePosition: d => d.START,
getTargetPosition: d => d.END,
Expand All @@ -362,6 +364,7 @@ export const TEST_CASES = [
new LineLayer({
id: 'line-lnglat',
data: dataSamples.routes,
strokeWidth: 0.5,
getSourcePosition: d => d.START,
getTargetPosition: d => d.END,
getColor: d => (d.SERVICE === 'WEEKDAY' ? [255, 64, 0] : [255, 200, 0]),
Expand All @@ -383,6 +386,7 @@ export const TEST_CASES = [
new LineLayer({
id: 'line-lnglat-64',
data: dataSamples.routes,
strokeWidth: 0.5,
fp64: true,
getSourcePosition: d => d.START,
getTargetPosition: d => d.END,
Expand All @@ -409,7 +413,7 @@ export const TEST_CASES = [
data: dataSamples.points,
iconAtlas: ICON_ATLAS,
iconMapping: dataSamples.iconAtlas,
sizeScale: 24,
sizeScale: 12,
getPosition: d => d.COORDINATES,
getColor: d => [64, 64, 72],
getIcon: d => (d.PLACEMENT === 'SW' ? 'marker' : 'marker-warning'),
Expand Down Expand Up @@ -437,7 +441,7 @@ export const TEST_CASES = [
data: dataSamples.points,
iconAtlas: ICON_ATLAS,
iconMapping: dataSamples.iconAtlas,
sizeScale: 24,
sizeScale: 12,
fp64: true,
getPosition: d => d.COORDINATES,
getColor: d => [64, 64, 72],
Expand Down Expand Up @@ -703,7 +707,7 @@ export const TEST_CASES = [
getNormal: d => d.normal,
getColor: d => d.color,
opacity: 1,
radiusPixels: 4,
radiusPixels: 2,
pickable: true,
lightSettings: LIGHT_SETTINGS
})
Expand Down Expand Up @@ -734,7 +738,7 @@ export const TEST_CASES = [
getNormal: d => d.normal,
getColor: d => d.color,
opacity: 1,
radiusPixels: 4,
radiusPixels: 2,
pickable: true,
lightSettings: LIGHT_SETTINGS
})
Expand All @@ -760,7 +764,7 @@ export const TEST_CASES = [
getNormal: d => d.normal,
getColor: d => d.color,
opacity: 1,
radiusPixels: 4,
radiusPixels: 2,
pickable: true,
lightSettings: LIGHT_SETTINGS
})
Expand Down Expand Up @@ -949,7 +953,7 @@ export const TEST_CASES = [
getText: x => `${x.PLACEMENT}-${x.YR_INSTALLED}`,
getPosition: x => x.COORDINATES,
getColor: x => [153, 0, 0],
getSize: x => 32,
getSize: x => 16,
getAngle: x => 0,
sizeScale: 1,
getTextAnchor: x => 'start',
Expand Down Expand Up @@ -998,7 +1002,7 @@ export const TEST_CASES = [
getText: x => `${x.PLACEMENT}-${x.YR_INSTALLED}`,
getPosition: x => x.COORDINATES,
getColor: x => [153, 0, 0],
getSize: x => 32,
getSize: x => 16,
getAngle: x => 0,
sizeScale: 1,
getTextAnchor: x => 'start',
Expand Down

0 comments on commit 80dbf55

Please sign in to comment.