Jump to content

uniforms are not updated on v4 rc3


GBear
 Share

Recommended Posts

hi..

following link is example
http://jsfiddle.net/gbear/n0kzcjyu/20/

i set mark of uniformsd
it has like following code
 

Quote

    uniforms.mark= {
        type: '2f',
        value: {
            x: 0.5,
            y: 0.5
        }
    };

but it look like not have  any value in fragmentshader. 
 

Quote


    var fragmentSrc = [
        "precision mediump float;",
        "uniform vec4      filterArea;",
        'varying vec2 vTextureCoord;',
        'uniform sampler2D uSampler;',
        "uniform float     time;",
        "uniform vec2      mark;",
        "const float max_dist = 0.2;",
        "void main() {",
        "vec2 start = vTextureCoord.xy;",
        "float dist = distance(start, mark);",        //Wrong  -------------
        "if(dist < max_dist) {",
        "   vec4 color1  =texture2D(uSampler, vTextureCoord);",
        "   vec4 color2 = vec4(1.0, 1.0, 0.0, 1.0);",
        "   gl_FragColor = mix(color1, color2, 0.5);",
        "} else {",
        "    gl_FragColor = vec4(1.0, 0.0,  0.0, 1.0);",
        "   vec4 color1  =texture2D(uSampler, vTextureCoord);",
        "   vec4 color2 = vec4(1.0, 0.0, 0.0, 1.0);",
        "   gl_FragColor = mix(color1, color2, 0.5);",
        "}",
        "}",
    ];
 

if change  'float dist = distance(start, makr)  to following code,  shader is good

Quote

vec2 end = vec(0.5, 0.5);

if float dist = distance(start, end)

 

can you tell me where is wrong?

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...