Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
WebGL How to pass big numbers to shaders

I am making app by using javascript and webgl. I need to pass big numbers (for example 1647843999744) to shader but when I get this value with this code gl.getUniform(this.shaderProgram, this.maxTimeLoc) , I see different value. 1647843999744 is changing to 1647844041000.

This is my code

    createShaderProgram: function () {
        const { gl } = this
        var VertexShaderCode = `
                precision lowp float;
                attribute vec4 vertexPos;
                uniform mat4 modelViewMatrix;
                uniform mat4 projectionMatrix;
                uniform vec3 transPos;
                uniform float maxPointSize;
                uniform float minPointSize;
                uniform float maxTime;
                uniform float minTime;
                varying float scale;
                void main(void) {
                   scale = (vertexPos.w - minTime) / (maxTime - minTime);
                   gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPos.xyz - transPos.xyz, 1.0);
                   gl_PointSize = minPointSize + ((maxPointSize - minPointSize)*scale);
                }
    `

        var vertexShader = gl.createShader(gl.VERTEX_SHADER)
        gl.shaderSource(vertexShader, VertexShaderCode)
        gl.compileShader(vertexShader)

        var FragmentShaderCode = `
                    precision lowp float;
                    varying float scale;
                    uniform vec3 startColor;
                    uniform vec3 endColor;
                    uniform bool applyOpacity;
                void main() {
                  float r = 0.0;
                  vec2 cxy = 2.0 * gl_PointCoord - 1.0;
                  r = dot(cxy, cxy);
                  if(r > 1.0 ){ discard;}
                  vec3 factor = (endColor - startColor) * r;
                  if(applyOpacity==true){
                     gl_FragColor = vec4(startColor + factor, scale * (1.0-r));
                  }else{
                     gl_FragColor = vec4(startColor + factor, 1.0 - r);
                  }
                }`

        var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER)
        gl.shaderSource(fragmentShader, FragmentShaderCode)
        gl.compileShader(fragmentShader)

        this.shaderProgram = gl.createProgram()
        gl.attachShader(this.shaderProgram, vertexShader)
        gl.attachShader(this.shaderProgram, fragmentShader)
        gl.linkProgram(this.shaderProgram)
    }

Any ideas?What should I do?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda