mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
add edge drawing, stereographic geometry shader for handling curved projections
This commit is contained in:
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -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
2
vendor/toddcox
vendored
Submodule vendor/toddcox updated: 06c154057f...7ff2e7026b
25
vis/shaders/stereo-proper.gm.glsl
Normal file
25
vis/shaders/stereo-proper.gm.glsl
Normal 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();
|
||||
}
|
||||
12
vis/shaders/stereo-proper.vs.glsl
Normal file
12
vis/shaders/stereo-proper.vs.glsl
Normal 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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user