opengl es - How to pass arrays of values as uniform and how to create texture in cocos2djs -


i have been these days trying implement shader functionality not find solution. not know @ state shader support not know if going ask possible:

1.- how pass arrays of values shader.

i find there functions wrote web not native. example:

setuniformlocationwith2fv

this may want not defined @ native. there way pass array of floats shader? uniform objetive this: uniform vec2 position[30];

2.- alternatively 1. pass texture personalized values great too.

so question how create texture(1d or if that's not possible 2d or 3d), , pass uniform.

i have seent ogl test creates texture not seem cc.texture2d

    var texture = this.my_texture = gl.createtexture();     gl.bindtexture( gl.texture_2d, texture );      var pixels = new uint8array(4096);     for( var i=0; i<pixels.length; ) {         pixels[i++] = i/4;    // red         pixels[i++] = i/16;    // green         pixels[i++] = i/8;    // blue         pixels[i++] = 255;    // alpha     }     gl.teximage2d(gl.texture_2d, 0, gl.rgba, 32, 32, 0, gl.rgba, gl.unsigned_byte, pixels);      gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.nearest);     gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.nearest);     gl.bindtexture(gl.texture_2d, null); 

3.- want discard pixels of sprite see what's behind, not know if there better way not shaders.

edit: explained badly wanted. want discard pixels in shader through mouse/touch input. e.g: if click center of sprite want circle of discarded pixels appear in center of sprite see what's behind sprite discarded pixels.

thank you!

p.d: using cocos2d-js v.3.3

1.- how pass arrays of values shader.

you seem have discovered right method family already: gluniform<type>v

  1. how create texture(1d or if that's not possible 2d or 3d), , pass uniform

a texture uniform-like in terms of behaviour (i.e. constant entire draw call). why not access data normal texture? large uniform arrays "bad idea".

3.- want discard pixels of sprite see what's behind,

either (1) make transparent parts of sprite texture have 0.0 alpha value, , enable blending. won't want if using depth testing.

... or (2) encode transparency in alpha channel of texture , "discard" transparent fragments in fragment shader if alpha value below threshold.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -