Compare commits
4 commits
561541b10f
...
29c45e43e8
Author | SHA1 | Date | |
---|---|---|---|
29c45e43e8 | |||
7832cb21ac | |||
0afa923678 | |||
385a06f531 |
3 changed files with 23 additions and 14 deletions
|
@ -26,18 +26,15 @@ mat4 model(bool is_moon, float time)
|
||||||
// Based on:
|
// Based on:
|
||||||
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#cumulating-transformations
|
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#cumulating-transformations
|
||||||
|
|
||||||
mat4 scale_matrix = uniform_scale(0.30);
|
|
||||||
|
|
||||||
float r = 2.0;
|
float r = 2.0;
|
||||||
mat4 translation_matrix = translate(vec3(r, 0, 0));
|
float full_rotation = 2 * M_PI;
|
||||||
|
|
||||||
// TODO Why is PI not defined?
|
|
||||||
float full_rotation = 2 * 3.14159;
|
|
||||||
float theta = full_rotation * time / 4.0;
|
float theta = full_rotation * time / 4.0;
|
||||||
mat4 rotation_matrix = rotate_about_y(theta);
|
// Invert rotation
|
||||||
|
theta = -theta;
|
||||||
|
|
||||||
// Small hack to make the moon rotate around the origin
|
float x = r * cos(theta);
|
||||||
// Usually you would rotate first, then translate
|
float z = r * sin(theta);
|
||||||
return rotation_matrix * translation_matrix * scale_matrix;
|
|
||||||
|
return translate(vec3(x, 0, z)) * rotate_about_y(theta) * uniform_scale(0.30);
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,14 @@ void main()
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Replace with your code:
|
// Replace with your code:
|
||||||
pos_es_in[gl_InvocationID] = pos_cs_in[gl_InvocationID];
|
// Hard-code each tessellation level to 5
|
||||||
|
gl_TessLevelOuter[0] = 5;
|
||||||
|
gl_TessLevelOuter[1] = 5;
|
||||||
|
gl_TessLevelOuter[2] = 5;
|
||||||
|
gl_TessLevelInner[0] = 5;
|
||||||
|
|
||||||
|
// Pass through the input vertices
|
||||||
|
pos_es_in[gl_InvocationID] = pos_cs_in[gl_InvocationID];
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,15 @@ void main()
|
||||||
// (so before model, view, proj are applied)
|
// (so before model, view, proj are applied)
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Replace with your code
|
// Replace with your code
|
||||||
|
// Based on:
|
||||||
|
// https://learnopengl.com/Guest-Articles/2021/Tessellation/Tessellation
|
||||||
|
sphere_fs_in = normalize(interp_pos.xyz);
|
||||||
|
view_pos_fs_in = view * model(is_moon, animation_seconds) * vec4(sphere_fs_in, 1.0);
|
||||||
|
normal_fs_in = normalize(mat3(view * model(is_moon, animation_seconds)) * sphere_fs_in);
|
||||||
|
pos_fs_in = proj * view_pos_fs_in;
|
||||||
|
|
||||||
|
gl_Position = pos_fs_in;
|
||||||
gl_Position = interp_pos;
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue