mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
slices working; broken orientation
This commit is contained in:
73
vis/shaders/4d/4d.gm.glsl
Normal file
73
vis/shaders/4d/4d.gm.glsl
Normal file
@@ -0,0 +1,73 @@
|
||||
#version 440 core
|
||||
|
||||
layout(points) in;
|
||||
layout(triangle_strip, max_vertices=4) out;
|
||||
|
||||
layout(std430, binding=1) buffer Positions {
|
||||
vec4 verts[];
|
||||
};
|
||||
|
||||
layout(std140, binding=1) uniform Matrices {
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
};
|
||||
|
||||
in ivec4 vInds[];
|
||||
|
||||
out vec4 pos;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
float unmix(float u, float v) {
|
||||
return (u) / (u - v);
|
||||
}
|
||||
|
||||
void emit(vec4 v) {
|
||||
pos = v;
|
||||
gl_Position = proj * vec4(v.xyz, 1);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
void main() {
|
||||
// vec4 pos4[4];
|
||||
// for (int i = 0; i < 4; ++i) pos4[i] = view * verts[vInds[0][i]];
|
||||
//
|
||||
// for (int i = 0; i < 4; ++i) emit(pos4[i]);
|
||||
// EndPrimitive();
|
||||
// return;
|
||||
|
||||
vec4 pos4[4];
|
||||
for (int i = 0; i < 4; ++i) pos4[i] = view * verts[vInds[0][i]];
|
||||
|
||||
int lo[4], L = 0;
|
||||
int hi[4], H = 0;
|
||||
|
||||
float x = 0.7;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (pos4[i].w+x < 0) {
|
||||
lo[L++] = i;
|
||||
} else {
|
||||
hi[H++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 sect[4]; int S = 0;
|
||||
for (int l = 0; l < L; ++l)
|
||||
for (int h = H-1; h >=0; --h) {
|
||||
vec4 a = pos4[lo[l]];
|
||||
vec4 b = pos4[hi[h]];
|
||||
|
||||
float t = unmix(a.w+x, b.w+x);
|
||||
sect[S++] = mix(a, b, t);
|
||||
// sect[S++] = (0.0 - a.w) / (b.w - a.w) * (b - a) + a;
|
||||
}
|
||||
|
||||
for (int s = 0; s < S; ++s) {
|
||||
emit(sect[s]);
|
||||
}
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
27
vis/shaders/4d/4d.vs.glsl
Normal file
27
vis/shaders/4d/4d.vs.glsl
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 440 core
|
||||
|
||||
layout(std430, binding=1) buffer Positions {
|
||||
vec4 verts[];
|
||||
};
|
||||
|
||||
layout(std140, binding=1) uniform Matrices {
|
||||
mat4 proj;
|
||||
mat4 view;
|
||||
};
|
||||
|
||||
layout(location=0) in ivec4 inds;
|
||||
|
||||
out ivec4 vInds;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
float gl_PointSize;
|
||||
};
|
||||
|
||||
void main() {
|
||||
vInds = inds;
|
||||
|
||||
vec4 pos = view * verts[vInds.x];
|
||||
gl_Position = proj * vec4(pos.xyz, 1);
|
||||
gl_PointSize = 5;
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
layout(location=2) uniform vec3 c;
|
||||
|
||||
in vec4 vpos;
|
||||
in vec4 pos;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
float d = smoothstep(-2, 2, vpos.z);
|
||||
float d = smoothstep(-2, 2, pos.z);
|
||||
color = vec4(c * d, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user