Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!