本文整理匯總了TypeScript中neuroglancer/webgl/shader.ShaderBuilder.addVertexCode方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ShaderBuilder.addVertexCode方法的具體用法?TypeScript ShaderBuilder.addVertexCode怎麽用?TypeScript ShaderBuilder.addVertexCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neuroglancer/webgl/shader.ShaderBuilder
的用法示例。
在下文中一共展示了ShaderBuilder.addVertexCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: countingBufferShaderModule
export function countingBufferShaderModule(builder: ShaderBuilder) {
builder.addAttribute('highp uint', 'aIndexRaw');
builder.addVertexCode(glsl_uint32);
builder.addVertexCode(`
uint getPrimitiveIndex() {
return aIndexRaw;
}
`);
}
示例2: setPartIndex
setPartIndex(builder: ShaderBuilder, ...partIndexExpressions: string[]) {
let s = `
void setPartIndex(${partIndexExpressions.map((_, i) => `highp uint partIndex${i}`).join()}) {
highp uint pickID = uPickID;
highp uint pickBaseOffset = getPickBaseOffset();
${
partIndexExpressions
.map((_, i) => `highp uint pickOffset${i} = pickBaseOffset + partIndex${i};`)
.join('\n')}
`;
if (partIndexExpressions.length === 0) {
s += `
highp uint pickOffset0 = pickBaseOffset;
`;
}
s += `
vPickID = pickID + pickOffset0;
highp uint selectedIndex = uSelectedIndex;
if (selectedIndex == pickBaseOffset${
partIndexExpressions.map((_, i) => ` || selectedIndex == pickOffset${i}`).join('')}) {
vColor = uColorSelected;
} else {
vColor = uColor;
}
}
`;
builder.addVertexCode(s);
return `setPartIndex(${partIndexExpressions.join()})`;
}
示例3: defineShader
defineShader(builder: ShaderBuilder) {
builder.addAttribute('highp vec3', 'aSphereVertex');
builder.addVarying('highp float', 'vLightingFactor');
// projectionMatrix = cameraMatrix * modelViewMat
// normalTransformMatrix = (modelViewMat^{-1})^T
// eff modelViewMat = modelViewMat * scalMat(radii)
// normalTransformMatrix = (modelViewMat * scalMat)^{-1}^T
// = (scalMat^{-1} * modelViewMat^{-1})^T
// = modelViewMat^{-1}^T * (scalMat^{-1})^T
builder.addVertexCode(`
void emitSphere(mat4 projectionMatrix, mat4 normalTransformMatrix, vec3 centerPosition, vec3 radii, vec4 lightDirection) {
vec3 vertexPosition = aSphereVertex * radii + centerPosition;
gl_Position = projectionMatrix * vec4(vertexPosition, 1.0);
vec3 normal = normalize((normalTransformMatrix * vec4(aSphereVertex / radii, 0.0)).xyz);
vLightingFactor = abs(dot(normal, uLightDirection.xyz)) + uLightDirection.w;
}
`);
}
示例4: defineShader
defineShader(builder: ShaderBuilder) {
builder.addUniform('highp vec4', 'uColor');
builder.addUniform('highp vec4', 'uColorSelected');
builder.addUniform('highp uint', 'uSelectedIndex');
builder.addVarying('highp vec4', 'vColor');
// Transform from camera to clip coordinates.
builder.addUniform('highp mat4', 'uProjection');
builder.addUniform('highp uint', 'uPickID');
builder.addVarying('highp uint', 'vPickID', 'flat');
builder.addVertexCode(`
highp uint getPickBaseOffset() { return uint(gl_InstanceID) * ${this.pickIdsPerInstance}u; }
`);
builder.addFragmentCode(`
void emitAnnotation(vec4 color) {
emit(color, vPickID);
}
`);
}