Skip to content
Snippets Groups Projects
Commit cf2a4926 authored by Alexander Rose's avatar Alexander Rose
Browse files

fixes, tweaks

parent a31837f6
No related branches found
No related tags found
No related merge requests found
......@@ -257,17 +257,21 @@ namespace Canvas3D {
const yp = Math.round(y * pickScale)
objectPickTarget.bind()
await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
// TODO slow in Chrome, ok in FF; doesn't play well with gpu surface calc
// await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
webgl.readPixels(xp, yp, 1, 1, buffer)
const objectId = decodeIdRGB(buffer[0], buffer[1], buffer[2])
if (objectId === -1) return
instancePickTarget.bind()
await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
// await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
webgl.readPixels(xp, yp, 1, 1, buffer)
const instanceId = decodeIdRGB(buffer[0], buffer[1], buffer[2])
if (instanceId === -1) return
groupPickTarget.bind()
await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
// await webgl.readPixelsAsync(xp, yp, 1, 1, buffer)
webgl.readPixels(xp, yp, 1, 1, buffer)
const groupId = decodeIdRGB(buffer[0], buffer[1], buffer[2])
if (groupId === -1) return
......
......@@ -35,6 +35,8 @@ export const DirectVolumeSchema = {
elements: ElementsSpec('uint32'),
uAlpha: UniformSpec('f'),
uHighlightColor: UniformSpec('v3'),
uSelectColor: UniformSpec('v3'),
dUseFog: DefineSpec('boolean'),
uIsoValue: UniformSpec('f'),
......
......@@ -11,7 +11,6 @@ varying vec3 unitCoord;
varying vec3 origPos;
varying float instance;
uniform float uAlpha;
uniform mat4 uInvView;
uniform float uIsoValue;
uniform vec3 uGridDim;
......@@ -26,6 +25,10 @@ uniform vec3 uSelectColor;
uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;
uniform float uAlpha;
uniform float uPickingAlphaThreshold;
uniform int uPickable;
#if defined(dGridTexType_2d)
precision mediump sampler2D;
uniform sampler2D tGridTex;
......@@ -126,7 +129,9 @@ vec4 raymarch(vec3 startLoc, vec3 step, vec3 viewDir) {
#if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
if (uAlpha < uPickingAlphaThreshold)
discard; // ignore so the element below can be picked
#else
if (uPickable == 0)
return vec4(0.0, 0.0, 0.0, 1.0); // set to empty picking id
#endif
#if defined(dColorType_objectPicking)
return vec4(encodeIdRGB(float(uObjectId)), 1.0);
......
......@@ -68,6 +68,9 @@ export function createProgram(ctx: WebGLContext, props: ProgramProps): Program {
vertShaderRef.value.attach(program)
fragShaderRef.value.attach(program)
gl.linkProgram(program)
if (!gl.getProgramParameter(program, gl.LINK_STATUS)){
throw new Error(`Could not compile WebGL program. \n\n${gl.getProgramInfoLog(program)}`);
}
const uniformUpdaters = getUniformUpdaters(ctx, program, schema)
const attributeLocations = getAttributeLocations(ctx, program, schema)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment