當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ShaderBuilder.addAttribute方法代碼示例

本文整理匯總了TypeScript中neuroglancer/webgl/shader.ShaderBuilder.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ShaderBuilder.addAttribute方法的具體用法?TypeScript ShaderBuilder.addAttribute怎麽用?TypeScript ShaderBuilder.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在neuroglancer/webgl/shader.ShaderBuilder的用法示例。


在下文中一共展示了ShaderBuilder.addAttribute方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
      });
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:26,代碼來源:trivial_shaders.ts

示例2: ShaderBuilder

 return gl.memoize.get('trivialColorShader', () => {
   let builder = new ShaderBuilder(gl);
   builder.addVarying('vec4', 'vColor');
   builder.setFragmentMain('gl_FragColor = vColor;');
   builder.addAttribute('vec4', 'aVertexPosition');
   builder.addAttribute('vec4', 'aColor');
   builder.addUniform('mat4', 'uProjectionMatrix');
   builder.setVertexMain('vColor = aColor; gl_Position = uProjectionMatrix * aVertexPosition;');
   return builder.build();
 });
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:10,代碼來源:trivial_shaders.ts

示例3: countingBufferShaderModule

export function countingBufferShaderModule(builder: ShaderBuilder) {
  builder.addAttribute('highp uint', 'aIndexRaw');
  builder.addVertexCode(glsl_uint32);
  builder.addVertexCode(`
uint getPrimitiveIndex() {
  return aIndexRaw;
}
`);
}
開發者ID:google,項目名稱:neuroglancer,代碼行數:9,代碼來源:index_emulation.ts

示例4: ShaderBuilder

 return gl.memoize.get('trivialUniformColorShader', () => {
   let builder = new ShaderBuilder(gl);
   builder.addUniform('mat4', 'uProjectionMatrix');
   builder.addAttribute('vec4', 'aVertexPosition');
   builder.addUniform('vec4', 'uColor');
   builder.addOutputBuffer('vec4', 'v4f_fragColor', null);
   builder.setFragmentMain('v4f_fragColor = uColor;');
   builder.setVertexMain('gl_Position = uProjectionMatrix * aVertexPosition;');
   return builder.build();
 });
開發者ID:google,項目名稱:neuroglancer,代碼行數:10,代碼來源:trivial_shaders.ts

示例5: 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;
}
`);
  }
開發者ID:google,項目名稱:neuroglancer,代碼行數:20,代碼來源:spheres.ts

示例6: defineShader

 defineShader(builder: ShaderBuilder) {
   builder.addAttribute('highp uint', this.name);
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:3,代碼來源:index_emulation.ts


注:本文中的neuroglancer/webgl/shader.ShaderBuilder.addAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。