无法设法从shaderfrom在three.js上运行着色器

时间:2018-09-14 10:35:33

标签: javascript three.js shader

我想在我的项目中导入该着色器: https://shaderfrog.com/app/view/2447

这是我的片段着色器:

<script id="fragmentShader" type="x-shader/x-fragment">
    #ifdef GL_ES
        precision highp float;
        precision highp int;
    #endif

    uniform vec2 u_resolution;
    uniform vec2 u_mouse;
    uniform float u_time;
    uniform sampler2D texture1;

    // Example varyings passed from the vertex shader
    varying vec3 vPosition;
    varying vec3 vNormal;
    varying vec2 vUv;

    void main() {
        vec3 color = vec3(texture2D(texture1, vUv));
        vec3 outcolor=color;
        float v = u_time + (vUv.x*0.5 + vUv.y*0.5);
        vec2 Uv2 = vec2(color.r+color.b+v,color.g+color.b+v);
        outcolor = vec3(texture2D(texture1, Uv2));
        gl_FragColor = vec4( outcolor, 1.0 );

    }
</script>

这是我的顶点着色器:

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

    varying vec3 vPosition;
    varying vec3 vNormal;
    varying vec2 vUv;

    void main() {

        vNormal = normal;
        vUv = uv;
        vPosition = position;

        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

    }

</script>

我的着色器正在编译,但是结果不一样,我只有一个高度冻结的对比度图像。另外,我确实在requestAnimationFrame函数上增加了统一的u_time值。

我看不到我在做什么错?

0 个答案:

没有答案