Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- attribute vec3 aVertexPosition;
- attribute vec4 aVertexColor;
- uniform mat4 uMVMatrix;
- uniform mat4 uPMatrix;
- varying vec4 vColor;
- uniform float f; // this is incremented every frame
- uniform float t; // this is time in milliseconds since epoch
- #define M_PI 3.1415926535897932384626433832795
- mat3 rotateX(float rad) {
- float c = cos(rad);
- float s = sin(rad);
- return mat3(
- 1.0, 0.0, 0.0,
- 0.0, c, s,
- 0.0, -s, c
- );
- }
- mat3 rotateY(float rad) {
- float c = cos(rad);
- float s = sin(rad);
- return mat3(
- c, 0.0, -s,
- 0.0, 1.0, 0.0,
- s, 0.0, c
- );
- }
- mat3 rotateZ(float rad) {
- float c = cos(rad);
- float s = sin(rad);
- return mat3(
- c, s, 0.0,
- -s, c, 0.0,
- 0.0, 0.0, 1.0
- );
- }
- void main(void) {
- gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1);
- vec3 oColor = vec3(1.0,1.0,1.0);
- float min = 0.0;
- vec3 vertexPosition = aVertexPosition.xyz * rotateX(sin(f/30.0)) * rotateY(cos(f/25.0)) * rotateZ(tan(f/100.0)) / 5.0;
- if(vertexPosition.x > min && vertexPosition.y > min && vertexPosition.z > min) {
- oColor = vec3(1.0,0.0,0.0);
- }
- vColor = vec4(oColor,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement