Jump to content

weird vTextureCoord on fragment shader


GBear
 Share

Recommended Posts

hi. 

i write following filter shader code 
 

function createShaderShadow(width, height) {    // smoke shader    var uniforms = {};    uniforms.resolution = {        type: '2f',        value: {            x: width,            y: height        }    };    uniforms.time = {type: '1f', value: 0.5};    uniforms.dimensions = {type: '4fv', value:new PIXI.Float32Array([0, 0, 0, 0])};    uniforms.target= {type: '4fv', value:new PIXI.Float32Array([200, 200, 200, 200])};    var fragmentSrc = [        'precision mediump float;',        'uniform sampler2D uSampler;',        'varying vec2 vTextureCoord;',        'uniform vec4 dimensions;',        'uniform vec2 resolution;',        'uniform vec4 target;',        'void main() {',        '    vec2 ratio = vTextureCoord.xy * resolution.xy;',        //'    vec2 ratio = vTextureCoord.xy;',        '    vec2 p = vec2(200, 200);',        '    float dist = distance(ratio, p);',        '    vec4 color = texture2D(uSampler, vTextureCoord);',        '    if(dist < 150.0){',        '        gl_FragColor = color;',        //'        gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);',        '    } else {',        '        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);',        '    }' ,        '   return;',        '}'    ];    var coolFilter = new PIXI.AbstractFilter(fragmentSrc, uniforms);    return coolFilter;};

green part is target to draw texture.

post-10357-0-01630200-1437540192.png

 

but i set texture color into gl_FragColor , i can see weird image like under 

post-10357-0-65669500-1437539520_thumb.p

 

what is wrong there? and what can i do to resolve this?

 

 

this. is normal image 

post-10357-0-78288000-1437539518_thumb.p

 

thx ^^/

Link to comment
Share on other sites

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...