-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add shader precision #60
base: main
Are you sure you want to change the base?
Conversation
Couple of notes:
It seems that the getMaxPrecision(precision) function is coming from ThreeJS where they issue a warning if the max precision doesn't match the requested material precision. Are we sure our aim is to support such devices with no |
@@ -269,6 +270,28 @@ function createContext (opts) { | |||
capabilities.maxColorAttachments = gl.getParameter('MAX_COLOR_ATTACHMENTS') | |||
} | |||
|
|||
function getMaxPrecision(precision = 'highp') { |
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.
getMaxPrecision is one of a kind API. More in the PR comments
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.
I agree we need to handle it somehow just not sure about API yet.
I exposed the
I agree it feels slightly weird because it is one of a kind but I couldn't find a better way to make it accessible to pex-renderer without having to duplicate the gl precision check code. Only other acceptable way I see so far would be to make the function a separate package.
We encountered some mobile devices with only
We can add a warning as well or use a debug feature somehow. |
I feel like we are trying to make things complicated here. In somehow controversial discussions like this one it's useful to think i case of scenarios. From my understanding some older devices might not support I would suggest leaving only There is actually built-in glsl constant #if GL_FRAGMENT_PRECISION_HIGH == 1
// highp is supported
#else
// high is not supported
#endif That means we could potentially have matching capabilities.fragmentPrecisionHigh = true/false |
* 'master' of github.com:pex-gl/pex-context: (25 commits) Update README.md Update README.md Remove glslify and clean up examples Fix security vulnerabilities for examples Update examples deps Documentation: add ctx.capabilities Documentation: unify parameter column names: property, info, type, default? Add Encoding enum to docs + Format markdown enums Clean up Fix linting Fix log namespace for framebuffer Remove standard Use arrowParens always Add lint and format convenience scripts Add eslint standard config Format examples Add prettier and eslint Add assert to FBO status check Remove temp debug context code Update picking example to new renderbuffer API ... # Conflicts: # index.js
We can get rid of 'lowp'.
getMaxPrecision actually checks for both vertex and fragment precision (
So that kind of make useless to have it in pex-context? We could just add a direct replacement if highp is not supported in pex-renderer shaders: #ifndef GL_FRAGMENT_PRECISION_HIGH
#define highp mediump
#endif
varying highp vec3 vPositionWorld;
// would become
varying mediump vec3 vPositionWorld;
You mean no |
https://google.github.io/filament/webgl/suzanne.html No checks in GLSL but it doesn't mean they don't do them in JS. As mentioned in docs they default to #version 300 es
precision mediump float;
precision mediump int;
layout(std140) uniform FrameUniforms
{
highp mat4 viewFromWorldMatrix;
highp mat4 worldFromViewMatrix;
highp mat4 clipFromViewMatrix;
highp mat4 viewFromClipMatrix;
highp mat4 clipFromWorldMatrix;
highp mat4 worldFromClipMatrix;
highp mat4 lightFromWorldMatrix;
highp vec4 resolution;
highp vec3 cameraPosition;
highp float time; |
Yes, only We would then use This flag would be used more for low end device sniffing than overwriting shader precisions as doing it automatically and globally most likely will not work and just cause artifacts to show up. |
ctx.capabilities.maxPrecision
mediump
orlowp
precision
parameter allows override even if a higher precision is availableGround work for: pex-gl/pex-renderer#122