shader-school的渲染入门系列(一)

来源:互联网 发布:淘宝的卡券包在哪里 编辑:程序博客网 时间:2024/06/04 20:11

shader-school是glsl语言入门基础的好教程,我简单分享一下自己做的答案。

题目是vertex shader的the basics,简单用旋转矩阵就过了。



代码如下:

precision highp float;uniform float theta;attribute vec2 position;void main() {  //TODO: rotate position by theta radians about the origin  float newx=cos(theta)*position.x-sin(theta)*position.y;//新X坐标  float newy=sin(theta)*position.x+cos(theta)*position.y;//新Y坐标  gl_Position = vec4(newx,newy, 0, 1.0);}



阅读全文
0 0
原创粉丝点击