WebGL / Support DPR > 1 in linestring shader
A u_pixelRatio uniform was added to be used in the shaders. this is necessary since we're relying on the builtin gl_FragCoord vector, which will be scaled relative to the u_sizePx uniform in case of a device pixel ratio != 1. Also added tests for computed uniform values, instead of just testing that they were indeed set.
This commit is contained in:
@@ -50,6 +50,7 @@ export const DefaultUniform = {
|
||||
ZOOM: 'u_zoom',
|
||||
RESOLUTION: 'u_resolution',
|
||||
SIZE_PX: 'u_sizePx',
|
||||
PIXEL_RATIO: 'u_pixelRatio',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -666,6 +667,7 @@ class WebGLHelper extends Disposable {
|
||||
applyFrameState(frameState) {
|
||||
const size = frameState.size;
|
||||
const rotation = frameState.viewState.rotation;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
|
||||
const offsetScaleMatrix = resetTransform(this.offsetScaleMatrix_);
|
||||
scaleTransform(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
@@ -693,6 +695,7 @@ class WebGLHelper extends Disposable {
|
||||
DefaultUniform.RESOLUTION,
|
||||
frameState.viewState.resolution
|
||||
);
|
||||
this.setUniformFloatValue(DefaultUniform.PIXEL_RATIO, pixelRatio);
|
||||
this.setUniformFloatVec2(DefaultUniform.SIZE_PX, [size[0], size[1]]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user