0
votes

Is it possible to somehow modify this fragment shader so that it doesn't use the oes_texture_float extension? Because I get an error on the machine which is supposed to run a webgl animation.

I set up my scene using three.js webglrenderer and a cube with a shadermaterial applied to it. On My macbook pro, everything works fine, but on some windows machine I get the error "float textures not supported" (I've searched and found that this probably has to do with oes_texture_float extension)

So I'm guessing I need to change my fragment shader? Or am I missing the point completely?

<script type="x-shader/x-vertex" id="vertexshader">

    // switch on high precision floats
    #ifdef GL_ES
    precision highp float;
    #endif

    void main() {
        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
    }
</script>

<script type="x-shader/x-fragment" id="fragmentshader">

    #ifdef GL_ES
    precision mediump float;
    #endif

    #define PI 3.14159265

    uniform float time;
    uniform vec2 resolution;

    float f(float x) {
        return (sin(x * 1.50 * PI ) + 19.0);
    }

    float q(vec2 p) {
        float s = (f(p.x + 0.85)) / 2.0; 

        float c = smoothstep(0.9, 1.20, 1.0 - abs(p.y - s));  
        return c; 
    }

    vec3 aurora(vec2 p, float time) {
        vec3 c1 = q( vec2(p.x, p.y / 0.051) + vec2(time / 3.0, -0.3)) * vec3(2.90, 0.50, 0.10);     
        vec3 c2 = q( vec2(p.x, p.y / 0.051) + vec2(time, -0.2)) * vec3(1.3, .6, 0.3);   
        vec3 c3 = q( vec2(p.x, p.y / 0.051) + vec2(time / 5.0, -0.5)) * vec3(1.7, 0.4, 0.20); 

        return c1+c2+c3; 
    }

    void main( void ) {
        vec2 p = ( gl_FragCoord.xy / resolution.xy );       
        vec3 c = aurora(p, time); 
        gl_FragColor = vec4(1.0-c, c);  
    }

</script>

EDIT: this has nothing to do with the floating point texture, but rather with something in my fragment shader. Three.js gives me the error: "Can't initialise shader, VALIDATE_STATUS"

2

2 Answers

1
votes

"Or am I missing the point completely?" - Indeed you are. The shaders don't care about the underlying texture format (you don't even use any textures in those shaders you posted!), so they don't have anything to do with your problem.

It's the application code that uses a float texture somewhere and needs to be changed accordingly. But from the fact that your shader doesn't use any textures at all (and I guess you haven't explicitly created a float texture elsewhere), it's probably three.js' internals that need a float texture somewhere, maybe as render target. So you need to search for ways to disable this requirement if possible.

0
votes

Unless it's a three.js ism you haven't defined projectionMatrix, modelViewMatrix, and position in your vertex shader.

Try adding

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
attribute vec4 position;

To the top of the first shader?