本文整理匯總了TypeScript中neuroglancer/webgl/shader.ShaderBuilder.addInitializer方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ShaderBuilder.addInitializer方法的具體用法?TypeScript ShaderBuilder.addInitializer怎麽用?TypeScript ShaderBuilder.addInitializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neuroglancer/webgl/shader.ShaderBuilder
的用法示例。
在下文中一共展示了ShaderBuilder.addInitializer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ShaderBuilder
`elementWiseTextureShader:${numTextures}:${getObjectId(shaderModule)}`, () => {
let builder = new ShaderBuilder(gl);
builder.addVarying('vec2', 'vTexCoord');
builder.addUniform('sampler2D', 'uSampler', numTextures);
builder.addInitializer(shader => {
let textureIndices: number[] = [];
for (let i = 0; i < numTextures; ++i) {
textureIndices[i] = i;
}
gl.uniform1iv(shader.uniform('uSampler'), textureIndices);
});
for (let i = 0; i < numTextures; ++i) {
builder.addFragmentCode(`
vec4 getValue${i}() {
return texture2D(uSampler[${i}], vTexCoord);
}
`);
}
builder.addUniform('mat4', 'uProjectionMatrix');
builder.require(shaderModule);
builder.addAttribute('vec4', 'aVertexPosition');
builder.addAttribute('vec2', 'aTexCoord');
builder.setVertexMain(
'vTexCoord = aTexCoord; gl_Position = uProjectionMatrix * aVertexPosition;');
return builder.build();
});