-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use getShaderPrecisionFormat to check if highp precision is available in shader #122
Comments
I think in the context of pex-renderer it’s safe to assume such device would not be able to run it anyway. |
PR in progress: #125 |
From Unity docs: Precision, Hardware Support and Performance
That explains no performance gains when i tested "half-float pipeline" (and all
I did run into issues many times that's why i tried to avoid it.
Now that's interesting.
|
In that context this comment from Filament docs makes more sense
|
From Apple's [OpenGL ES Programming Guide] (now deprecated of course):
|
ThreeJS work "towards mediump"
I kind of proves my earlier comment that just supporting |
It probably won't fixes all bugs magically but at least provide support for other precisions which could be a good start before planning anything else. |
I'm not sure about this approach const renderer = createRendererer({
...,
precision: 'highp' // 'lowp' || 'mediump'
}) After reading all the references above it seems that correct way is to have everything as low as possible because without bugs a) save energy on mobile, b) on desktop it doesn't matter (i.e. it's always "highest quality"). Maybe i need to learn more about ThreeJS approach but the "everything is mediump" way implemented in #125 might be hard to manage as individual uniforms might need to be tweaked (e.g. positions hi/med, colors low etc). Investigating... |
BabylonJS does string replacement on all shaders if |
I have never seen any WebGL shader in the wild making use of per variable precision setting (eg. no |
If we are not interested in per-variable precision tweaking why not automate the whole thing in |
Would it still be possible to have per material precision with this approach? |
#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; or precision mediump float;
precision mediump int;
layout(std140) uniform PostProcessUniforms
{
vec2 uvScale;
float time;
float yOffset;
} postProcessUniforms;
uniform mediump sampler2D postProcess_colorBuffer;
in highp vec2 vertex_uv; |
I think we should test it our pex-renderer materials with mediump devices and use GL_FRAGMENT_PRECISION_HIGH for portability. |
Not sure how much is that relevant in 2023 |
API could default to
highp
and be overrided manually, but checkgetShaderPrecisionFormat
in every case:The text was updated successfully, but these errors were encountered: