我想在我的图表行中添加发光效果,例如the Interactive Globe: Small Arms Imports & Exports。
我使用Vivagraph.js库来显示节点和链接,而不是Threejs。
Fragment Shader:
precision mediump float;
varying vec4 color;
void main(void) {
gl_FragColor = color;
}
顶点着色器:
attribute vec2 a_vertexPos;
attribute vec4 a_color;
uniform vec2 u_screenSize;
uniform mat4 u_transform;
varying vec4 color;
void main(void) {
gl_Position = u_transform * vec4(a_vertexPos/u_screenSize, 0.0, 1.0);
color = a_color.abgr;
}
渲染功能:
gl.useProgram(program);
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, storage, gl.DYNAMIC_DRAW);
if (sizeDirty) {
sizeDirty = false;
gl.uniformMatrix4fv(locations.transform, false, transform);
gl.uniform2f(locations.screenSize, width, height);
}
gl.vertexAttribPointer(locations.vertexPos, 2, gl.FLOAT, false, 3 * Float32Array.BYTES_PER_ELEMENT, 0);
gl.vertexAttribPointer(locations.color, 4, gl.UNSIGNED_BYTE, true, 3 * Float32Array.BYTES_PER_ELEMENT, 2 * 4);
gl.drawArrays(gl.LINES, 0, linksCount * 2);
frontLinkId = linksCount - 1;
您是否有任何想法在片段着色器上添加有关发光的信息? THX
答案 0 :(得分:1)
换句话说,您不能通过修改片段着色器为上面的示例添加发光。你需要另一组着色器