OpenGL ES 3.0 Vertex coloring tool (2), opengles

Source: Internet
Author: User

OpenGL ES 3.0 Vertex coloring tool (2), opengles

# Version 300 esuniform mat4 u_mvpMatrix; in vec4 a_position; in vec4 a_color;
Out vec4 v_color;
Void main () {v_color = a_color; gl_Position = u_mvpMatrix * a_position ;}

The above is a piece of vertex coloring code.

# Version 300 es

The first line in the vertex coloring file indicates that the color language version is 3.0 (shading language 3.0)

Uniform mat4 u_mvpMatrix;

Create an uniform variable u_mvpMatrix for storing the projection matrix of the composite model view.

In vec4 a_position; in vec4 a_color;

Input to the vertex shader as the attribute of the vertex shader.

A_position is the position attribute of the input vertex, and a_color is the color attribute of the input vertex.

Out vec4 v_color;

Output vertex color

Gl_position is a built-in automatic declaration variable, and the colorant must write the transformed position and pass it to it.

Void main is the entry point of a vertex or fragment shader.

V_color = a_color;

We read the vertex attribute input a_color and write its vertex color output v_color.

Gl_Position = u_mvpMatrix * a_position;

Use gl_Position to change the vertex position.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.