-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintaining marker size with various pixelRatio values #20
Conversation
marker-vert.glsl
Outdated
@@ -38,7 +38,7 @@ void main() { | |||
float size = size * maxSize / 255.; | |||
float borderSize = borderSize * maxSize / 255.; | |||
|
|||
gl_PointSize = 2. * size * pixelRatio; | |||
gl_PointSize = 2. * size * 2.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fixing pixel ratio from uniforms side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dy for looking at this.
It seems to be used in one other place in the shader:
regl-scatter2d/marker-vert.glsl
Line 42 in 6a8f357
fragPointSize = size * pixelRatio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But fragPointSize is different from gl_PointSize. Can you possibly add a test-case for the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fixing pixel ratio from uniforms side?
pixelRatio
could be set as a constant of 2 here:
Line 84 in 091a1a7
pixelRatio: regl.context('pixelRatio'), |
pixelRatio
values are possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be done as a separate option if you want to make some default value. Here https://github.com/gl-vis/regl-scatter2d/blob/master/scatter.js#L199
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. Why not avoiding passing plotGlPixelRatio
as pixelRatio
at all?
The cases mentioned in the codepen make sure the point size is consisted in devices with various pixelRatio
. If you want to pass "fake" pixelRatio - the point size will be increased, that's what expected. Am I getting it wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Plotly.js plotGlPixelRatio
is the same as pixelRatio
. Here is another codepen example comparing scatter
, scattergl
& scatter3d
with different pixelRatio values lines and markers. The only module which treat pixelRatio differently seems to be this module. When passing different pixelRatio values we don't expect a change in point sizes but slightly higher render quality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered that on the devices with another default pixelRatio? The point size is likely smaller there, other gl- components don’t consider that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codepens on different devices appear to be rendered OK with this fix.
@etpinard what's your thoughts here.
Should we consider another fix something like this? https://github.com/plotly/plotly.js/compare/markersize-second-approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your hard work @archmoj - your patch appears to make scattergl
consistent with how markers are drawn in scatter3d
so 👌
As this repo remains in @dy 's hands, we could perhaps make this new/consistent pixelRatio
behaviour an opt-in e.g. by adding a boolean flag to regl-scatter2d
that we would turn on upon instantiating in plotly.js
marker-vert.glsl
Outdated
@@ -38,7 +38,7 @@ void main() { | |||
float size = size * maxSize / 255.; | |||
float borderSize = borderSize * maxSize / 255.; | |||
|
|||
gl_PointSize = 2. * size * pixelRatio; | |||
gl_PointSize = 2. * size * 2.; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But fragPointSize is different from gl_PointSize. Can you possibly add a test-case for the issue?
@dy Possibly any updates on this? |
@archmoj I did not mean to delay, sorry. Yes, I think that now |
@dy Thank you very much for the follow ups. |
Yep, the problem is on the regl-line2d side. It just doesn't account for |
revert sizes in tests
Great idea @etpinard. @dy this should be good to go as tested on plotly side as well as here without any changes to the tests. |
Gentlemen, I can't understand - why passing plotly's |
@etpinard that's great option, but no need to pass it to regl-scatter, pass // fix pixel ratio to accommodate other gl-components api
opts.marker.pixelRatio = 2. |
Added new option
constPointSize
to help maintain marker sizes with differentpixelRatio
values.Fix for issue plotly/plotly.js#3246.
Kindly visit PR plotly/plotly.js#3637 for more information.
@dy
cc: @etpinard