当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ShaderBuilder.addVarying方法代码示例

本文整理汇总了TypeScript中neuroglancer/webgl/shader.ShaderBuilder.addVarying方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ShaderBuilder.addVarying方法的具体用法?TypeScript ShaderBuilder.addVarying怎么用?TypeScript ShaderBuilder.addVarying使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neuroglancer/webgl/shader.ShaderBuilder的用法示例。


在下文中一共展示了ShaderBuilder.addVarying方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
`);
  }
开发者ID:google,项目名称:neuroglancer,代码行数:20,代码来源:type_handler.ts

示例4: 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


注:本文中的neuroglancer/webgl/shader.ShaderBuilder.addVarying方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。