Compare commits
3 commits
42a3ed61e9
...
561541b10f
Author | SHA1 | Date | |
---|---|---|---|
561541b10f | |||
0308b634ab | |||
bc480fdcaa |
9 changed files with 244 additions and 14 deletions
116
.gitignore
vendored
116
.gitignore
vendored
|
@ -38,3 +38,119 @@ CMakeSettings.json
|
|||
build/*
|
||||
bin/*
|
||||
*.DS_Store
|
||||
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# ---> C
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# ---> C++
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
|
73
.vscode/tasks.json
vendored
Normal file
73
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "setup",
|
||||
"type": "shell",
|
||||
"command": "cmake -S . -B build -D GLFW_BUILD_WAYLAND=OFF -D GLFW_BUILD_X11=ON"
|
||||
},
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "make -C build",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"dependsOn": [
|
||||
"setup"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Task 0: Check if OpenGL works",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 0",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 1: basic model, view, projection",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 1",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 2: subdivide the mesh",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 2",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 3: make the mesh round",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 3",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 4: light",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 4",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 5: procedural color",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 5",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 6: procedural bump",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 6",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Task 7: get creative",
|
||||
"type": "shell",
|
||||
"command": "./build/shaderpipeline 7",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -10,6 +10,10 @@ void main()
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code:
|
||||
color = vec3(1,1,1);
|
||||
if (is_moon) {
|
||||
color = vec3(0.5,0.45,0.5);
|
||||
} else {
|
||||
color = vec3(0.2,0.3,0.8);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -5,12 +5,8 @@ mat4 identity()
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
return mat4(
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0,
|
||||
0,0,0,0);
|
||||
// Based on:
|
||||
// https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Matrix_constructors
|
||||
return mat4(1.0);
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,25 @@ mat4 model(bool is_moon, float time)
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
return identity();
|
||||
if (!is_moon) {
|
||||
return identity();
|
||||
}
|
||||
|
||||
// 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 theta = full_rotation * time / 4.0;
|
||||
mat4 rotation_matrix = rotate_about_y(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;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ void main()
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
pos_cs_in = vec4(pos_vs_in,1.0);
|
||||
// Object in world
|
||||
vec4 pos_vs = model(is_moon, animation_seconds) * vec4(pos_vs_in, 1.0);
|
||||
// world -> eye -> screen
|
||||
pos_cs_in = proj * view * pos_vs;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -6,7 +6,14 @@ mat4 rotate_about_y(float theta)
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
return identity();
|
||||
// Based on:
|
||||
// https://en.wikipedia.org/wiki/Rotation_matrix#Basic_3D_rotations
|
||||
return mat4(
|
||||
cos(theta), 0, sin(theta), 0,
|
||||
0, 1, 0, 0,
|
||||
-sin(theta), 0, cos(theta), 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,15 @@ mat4 translate(vec3 t)
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
return identity();
|
||||
// Based on:
|
||||
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#translation-matrices
|
||||
// and README
|
||||
return mat4(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
t.x, t.y, t.z, 1
|
||||
);
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@ mat4 uniform_scale(float s)
|
|||
{
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Replace with your code
|
||||
return identity();
|
||||
// Based on:
|
||||
// https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#scaling-matrices
|
||||
// and
|
||||
// https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Matrix_constructors
|
||||
return mat4(mat3(s));
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue