Coder Social home page Coder Social logo

Comments (4)

bryik avatar bryik commented on September 21, 2024

According to MDN, "Using highp precision in fragment shaders will prevent your content from working on some older mobile hardware. You can use mediump instead, but be aware that this often results in corrupted rendering due to lack of precision on most mobile devices, and the corruption is not going to be visible on a typical desktop computer".

MDN also says that there is a function "getShaderPrecisionFormat()" that can check if highp precision is supported.

So I guess you'd need to fork the component and add some code that tests if highp precision is supported. You could also try using mediump instead of highp (although this may result in degraded quality or corruption).

from aframe-bmfont-text-component.

frabaglia avatar frabaglia commented on September 21, 2024

Hi!

I made this test on early stage on my app to, in case of, redirect the user to a limited experience version:

function pixelShader() {
  var support = true;
  try {
    var canvas = document.getElementsByTagName('canvas')[0]
    var gl = canvas.getContext("webgl")
    var shaderType = [gl.VERTEX_SHADER,gl.FRAGMENT_SHADER]
    var precisionType = [gl.LOW_FLOAT, gl.MEDIUM_FLOAT, gl.HIGH_FLOAT, gl.LOW_INT, gl.MEDIUM_INT, gl.HIGH_INT]
    shaderType.forEach(function(shader){
      precisionType.forEach(function(precision){
        gl.getShaderPrecisionFormat(shader,precision)
      })
    })
  } catch (error) {
    if (error)
      {
        support = false;
      }
  }
  return support;
}

Where do you think i could integrate this in your component? Let me try and if it looks fine i'll send you a PR.

from aframe-bmfont-text-component.

bryik avatar bryik commented on September 21, 2024

Changing the precision used by the fragment shader can be done by adding a parameter here. Try testing with precision: "mediump".

var material = new THREE.RawShaderMaterial(SDFShader({
    precision: "mediump",
    map: texture,
    side: THREE.DoubleSide,
    transparent: true,
    color: data.color,
    opacity: data.opacity
}));

If that fixes the problem on mobile let me know and I'll try to help with integrating the test.

P.S.
I've just discovered that Three.js' WebGL renderer has a "capabilities" property that contains a method getMaxPrecision(). Might be useful.

from aframe-bmfont-text-component.

bryik avatar bryik commented on September 21, 2024

Closing as this issue has been open for quite some time and I'm about to archive this project.

from aframe-bmfont-text-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.