GBear Posted August 9, 2016 Share Posted August 9, 2016 hi.. following link is examplehttp://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? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 9, 2016 Share Posted August 9, 2016 uniforms.mark= [0.5, 0.5]; Quote Link to comment Share on other sites More sharing options...
GBear Posted August 26, 2016 Author Share Posted August 26, 2016 @ivan.popelyshevthx ivan. always.^^/ ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.