a p*_*erd 5 shader opengl-es webgl vertex-shader fragment-shader
所以我有一个三角形:
我有一个顶点着色器:
uniform mat4 uViewProjection;
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoords;
varying vec2 vTextureCoords;
void main(void) {
vTextureCoords = aTextureCoords;
gl_Position = uViewProjection * vec4(aVertexPosition, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
我有一个片段着色器:
precision mediump float;
uniform sampler2D uMyTexture;
varying vec2 vTextureCoords;
void main(void) {
gl_FragColor = texture2D(uMyTexture, vTextureCoords);
}
Run Code Online (Sandbox Code Playgroud)
我提供了三组顶点和UV,交错:
# x, y, z, s, t
0.0, 1.0, 0.0, 0.5, 1.0
-1.0, -1.0, 0.0, 0.0, 0.0
1.0, -1.0, 0.0, 1.0, 0.0
Run Code Online (Sandbox Code Playgroud)
片段着色器如何知道以不同于像素B的方式绘制像素A?有什么变化?
| 归档时间: |
|
| 查看次数: |
909 次 |
| 最近记录: |