提交 8e6fce73 编写于 作者: C Charles Nicholson 提交者: TensorFlower Gardener

Enable alpha testing at top-level WebGlRenderer (calls

glEnable(GL_ALPHA_TEST)). Disable premultiplied alpha for now, we don't have
any translucent texture reads yet. Replace dynamic branching + discard in
sprite fragment shader's analytical circle rendering, do a simple lerp instead. Simplify picking fragment shader as well, return the opacity in the alpha channel instead of discarding.
Change: 137707296
上级 5eead25a
......@@ -11,7 +11,7 @@ Construct and execute TensorFlow graphs in Go.
## Requirements
- Go version 1.7+
- [bazel](https://www.bazel.io/versions/master/docs/install.html)
- [bazel](https://www.bazel.build/versions/master/docs/install.html)
- Environment to build TensorFlow from source code
([Linux](https://www.tensorflow.org/versions/master/get_started/os_setup.html#prepare-environment-for-linux)
or [Mac OS
......
......@@ -156,7 +156,8 @@ export class ScatterPlot {
this.zScale = d3.scale.linear();
this.scene = new THREE.Scene();
this.renderer = new THREE.WebGLRenderer();
this.renderer =
new THREE.WebGLRenderer({alpha: true, premultipliedAlpha: false});
this.renderer.setClearColor(BACKGROUND_COLOR, 1);
this.containerNode.appendChild(this.renderer.domElement);
this.light = new THREE.PointLight(0xFFECBF, 1, 0);
......
......@@ -86,21 +86,13 @@ const FRAGMENT_SHADER = `
if (isImage) {
// Coordinates of the vertex within the entire sprite image.
vec2 coords = (gl_PointCoord + xyIndex) / vec2(imageWidth, imageHeight);
// Determine the color of the spritesheet at the calculate spot.
vec4 fromTexture = texture2D(texture, coords);
// Finally, set the fragment color.
gl_FragColor = vec4(vColor, 1.0) * fromTexture;
gl_FragColor = vec4(vColor, 1.0) * texture2D(texture, coords);
} else {
// Discard pixels outside the radius so points are rendered as circles.
vec2 uv = gl_PointCoord.xy - 0.5;
float uvLenSquared = dot(uv, uv);
if (uvLenSquared > (0.5 * 0.5)) {
discard;
}
// If the point is not an image, just color it.
gl_FragColor = vec4(vColor, 1.0);
float a = float(dot(uv, uv) < (0.5 * 0.5));
vec3 c = mix(vec3(1, 1, 1), vColor, a);
gl_FragColor = vec4(c, 1);
}
${THREE.ShaderChunk['fog_fragment']}
}`;
......@@ -108,7 +100,6 @@ const FRAGMENT_SHADER = `
const FRAGMENT_SHADER_PICKING = `
varying vec2 xyIndex;
varying vec3 vColor;
uniform bool isImage;
void main() {
......@@ -116,12 +107,9 @@ const FRAGMENT_SHADER_PICKING = `
if (isImage) {
gl_FragColor = vec4(vColor, 1);
} else {
vec2 pointCenterToHere = gl_PointCoord.xy - vec2(0.5, 0.5);
float lenSquared = dot(pointCenterToHere, pointCenterToHere);
if (lenSquared > (0.5 * 0.5)) {
discard;
}
gl_FragColor = vec4(vColor, 1);
vec2 uv = gl_PointCoord.xy - 0.5;
float a = float(dot(uv, uv) < (0.5 * 0.5));
gl_FragColor = vec4(vColor, a);
}
}`;
......@@ -197,7 +185,7 @@ export class ScatterPlotVisualizerSprites implements ScatterPlotVisualizer {
depthTest: true,
depthWrite: true,
fog: false,
blending: (this.image ? THREE.NormalBlending : THREE.MultiplyBlending),
blending: THREE.NormalBlending,
});
this.points = new THREE.Points(this.geometry, this.renderMaterial);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册