javascript - WebGL fragment shader opacity -
alright, first off, i'm pretty new @ glsl shaders, , i'm trying wrap head around following shader
#ifdef gl_es //precision mediump float; precision highp float; #endif uniform vec2 utimes; varying vec2 texcoord; varying vec2 screencoord; void main(void) { vec3 col; float c; vec2 tmpv = texcoord * vec2(0.8, 1.0) - vec2(0.95, 1.0); c = exp(-pow(length(tmpv) * 1.8, 2.0)); col = mix(vec3(0.02, 0.0, 0.03), vec3(0.96, 0.98, 1.0) * 1.5, c); gl_fragcolor = vec4(col * 0.5, 0); }
so far, know gives me radial gradient (perhaps). i'd know how make transparent. i'm thinking need vec4 that, right?
you need turn on blending.
see http://www.senchalabs.org/philogl/philogl/examples/lessons/8/ , http://learningwebgl.com/blog/?p=859.
without blending, depth , color buffers updated without taking care in buffer, overwrite data. blending on, , depending on type of blending function using, buffers updated data takes previsouly rendered data count.
this part interesting you:
gl.blendfunc(gl.src_alpha, gl.one); gl.enable(gl.blend); gl.disable(gl.depth_test);
hope helps.
Comments
Post a Comment