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:
|
||||
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#cumulating-transformations
|
||||
|
||||
mat4 scale_matrix = uniform_scale(0.30);
|
||||
|
||||
float r = 2.0;
|
||||
mat4 translation_matrix = translate(vec3(r, 0, 0));
|
||||
|
||||
// TODO Why is PI not defined?
|
||||
float full_rotation = 2 * 3.14159;
|
||||
float full_rotation = 2 * M_PI;
|
||||
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
|
||||
// Usually you would rotate first, then translate
|
||||
return rotation_matrix * translation_matrix * scale_matrix;
|
||||
float x = r * cos(theta);
|
||||
float z = r * sin(theta);
|
||||
|
||||
return translate(vec3(x, 0, z)) * rotate_about_y(theta) * uniform_scale(0.30);
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -14,6 +14,13 @@ void main()
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code:
|
||||
// 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];
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -36,9 +36,14 @@ void main()
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 = interp_pos;
|
||||
gl_Position = pos_fs_in;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue