add edge drawing, stereographic geometry shader for handling curved projections

This commit is contained in:
2020-01-12 12:07:35 -05:00
parent 437dae0205
commit 0408ecd5c4
5 changed files with 53 additions and 6 deletions

1
.gitmodules vendored
View File

@@ -7,3 +7,4 @@
[submodule "vendor/toddcox"]
path = vendor/toddcox
url = https://github.com/JCRaymond/toddcox-faster.git
branch = no-delete

2
vendor/toddcox vendored

View File

@@ -0,0 +1,25 @@
#version 430
#define SUBS 20
layout(lines) in;
layout(line_strip, max_vertices = SUBS) out;
layout(location=0) uniform mat4 proj;
in vec4 gpos[];
out vec4 vpos;
vec4 stereo(vec4 v) {
return vec4(v.xyz / (1 - v.w), 1);
}
void main() {
for (int i = 0; i < SUBS; i++) {
vpos = mix(gpos[0], gpos[1], i * 1.0f / (SUBS - 1));
vpos = normalize(vpos);
gl_Position = proj * stereo(vpos);
EmitVertex();
}
EndPrimitive();
}

View File

@@ -0,0 +1,12 @@
#version 430
layout(location=1) uniform mat4 view;
layout(location=0) in vec4 pos;
out vec4 gpos;
void main() {
gpos = view * pos;
gl_PointSize = 5;
}

View File

@@ -69,18 +69,26 @@ int main(int argc, char *argv[]) {
try {
// GLuint vs = utilCompileFiles(GL_VERTEX_SHADER, {"shaders/ortho.vs.glsl"});
GLuint vs = utilCompileFiles(GL_VERTEX_SHADER, {"shaders/stereo.vs.glsl"});
GLuint fs = utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/one-color.fs.glsl"});
// GLuint vs = utilCompileFiles(GL_VERTEX_SHADER, {"shaders/stereo.vs.glsl"});
// GLuint fs = utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/one-color.fs.glsl"});
// GLuint fs = utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/w-axis-hue.fs.glsl"});
pgm = utilLinkProgram({vs, fs});
// pgm = utilLinkProgram({vs, fs});
pgm = utilLinkProgram({
utilCompileFiles(GL_VERTEX_SHADER, {"shaders/stereo-proper.vs.glsl"}),
utilCompileFiles(GL_GEOMETRY_SHADER, {"shaders/stereo-proper.gm.glsl"}),
utilCompileFiles(GL_FRAGMENT_SHADER, {"shaders/one-color.fs.glsl"}),
});
} catch (const gl_error &e) {
std::cerr << e.what() << std::endl;
glfwTerminate();
exit(EXIT_FAILURE);
}
auto group = tc::group::H(4);
auto group = tc::group::F4();
// auto group = tc::group::D(4);
// auto group = tc::group::H(4);
auto res = group.solve();
auto mirrors = mirror(group);
@@ -128,7 +136,8 @@ int main(int argc, char *argv[]) {
auto aspect = (float) width / (float) height;
auto pheight = 1.4f;
auto pwidth = aspect * pheight;
glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -100.0f, 100.0f);
glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -2.0f, 2.0f);
// glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -100.0f, 100.0f);
glUniformMatrix4fv(0, 1, false, glm::value_ptr(proj));
auto t = (float) glfwGetTime() / 10;