Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/shader_canvas/core/webgl_programs/shaders.ts>VertexShader

A rendering engine where you can write WebGL 2.0 shaders using custom tags.
Latest
class VertexShader
extends ShaderCode
import { VertexShader } from "https://deno.land/x/shader_canvas@v1.1.1/core/webgl_programs/shaders.ts";

This class implements the "load" function for the vertex shader. All other functionality is done by extending the ShaderCode class.

Methods

load(gl: WebGL2RenderingContext)

Simple wrapper for the ShaderCode.loadShader() method. Sets the shader type as a VERTEX_SHADER

Static Properties

tag: string

<vertex-shader> {#VertexShader}

This tag holds the vertex shader code of a WebGL program. The code must be valid WebGL 2 GLSL. It is parsed and the variables analyzed and retrieved to allow Shader Canvas to be able to easily reference them and keep track of their locations at compilation/linking time.

The allowed children for the <vertex-shader>:

  • <code> Plain HTML <code> tag that holds the vertex code. Code tag is useful because it allows preformatted text as content.

Example

<shader-canvas>
 <webgl-canvas>
   <webgl-programs>
     <some-program>
       <vertex-shader>
         <code>
           #version 300 es
           in vec4 a_position;
           void main() {
             gl_Position = a_position;
           }
         </code>
       </vertex-shader>
       <fragment-shader>
         <code>
           <!--
             Write the fragment shader code for
             "some-program" here.
           -->
         </code>
       </fragment-shader>
     </some-program>
   </webgl-programs>
 </webgl-canvas>
</shader-canvas>

For a usable example check the 1st example - simple triangle

The <vertex-shader> tag is meant to be used as a child of the <{{program-name}}> custom named tag.