working intersection - rotating simplex
This commit is contained in:
@@ -11,7 +11,9 @@ vec3 hsv2rgb(vec3 c) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 hsv = vec3(pos.w/3 + .6, 1, 1);
|
||||
float h = pos.w / 3 + .6;
|
||||
float s = 1;
|
||||
float v = smoothstep(1, -1, pos.z);
|
||||
|
||||
fcolor = vec4(hsv2rgb(hsv), 1);
|
||||
fcolor = vec4(hsv2rgb(vec3(h, s, v)), 1);
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
#version 440 core
|
||||
|
||||
layout(location=0) in vec4 pos4;
|
||||
layout(location=0) in ivec4 vInds;
|
||||
|
||||
layout(std140, binding=1) uniform Matrices {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
};
|
||||
|
||||
out vec4 pos;
|
||||
out ivec4 inds;
|
||||
|
||||
void main() {
|
||||
pos = model * pos4;
|
||||
gl_Position = proj * view * vec4(pos.xyz, -pos.w + 2);
|
||||
inds = vInds;
|
||||
|
||||
gl_Position = vec4(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
56
simplex/shaders/sect.geom
Normal file
56
simplex/shaders/sect.geom
Normal file
@@ -0,0 +1,56 @@
|
||||
#version 440 core
|
||||
|
||||
layout(points) in;
|
||||
layout(triangle_strip, max_vertices=48) out;
|
||||
|
||||
layout(std430, binding=1) buffer Positions {
|
||||
vec4 verts[];
|
||||
};
|
||||
|
||||
layout(std140, binding=1) uniform Matrices {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
};
|
||||
|
||||
in ivec4 inds[];
|
||||
|
||||
out vec4 pos;
|
||||
|
||||
void emit(vec4 v) {
|
||||
pos = v;
|
||||
gl_Position = proj * view * vec4(v.xyz, -v.w + 2);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 pos4[4];
|
||||
for(int i = 0; i < 4; ++i) pos4[i] = model * verts[inds[0][i]];
|
||||
|
||||
int lo[4], L = 0;
|
||||
int hi[4], H = 0;
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
if (pos4[i].w < 0) {
|
||||
lo[L++] = i;
|
||||
} else {
|
||||
hi[H++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
vec4 sect[4]; int S = 0;
|
||||
for (int l = 0; l < L; ++l) {
|
||||
for (int h = 0; h < H; ++h) {
|
||||
vec4 a = pos4[lo[l]];
|
||||
vec4 b = pos4[hi[h]];
|
||||
|
||||
sect[S++] = (0 - a.w) / (b.w - a.w) * (b-a) + a;
|
||||
}
|
||||
}
|
||||
|
||||
for(int s = 0; s < S; ++s) {
|
||||
emit(sect[s]);
|
||||
}
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
37
simplex/shaders/wire.geom
Normal file
37
simplex/shaders/wire.geom
Normal file
@@ -0,0 +1,37 @@
|
||||
#version 440 core
|
||||
|
||||
layout(points) in;
|
||||
layout(line_strip, max_vertices=48) out;
|
||||
|
||||
layout(std430, binding=1) buffer Positions {
|
||||
vec4 verts[];
|
||||
};
|
||||
|
||||
layout(std140, binding=1) uniform Matrices {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
};
|
||||
|
||||
in ivec4 inds[];
|
||||
|
||||
out vec4 pos;
|
||||
|
||||
void emit(vec4 v) {
|
||||
pos = v;
|
||||
gl_Position = proj * view * vec4(v.xyz, -v.w + 2);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 pos4[4];
|
||||
for(int i = 0; i < 4; ++i) pos4[i] = model * verts[inds[0][i]];
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
for(int j = i + 1; j < 4; ++j) {
|
||||
emit(pos4[i]);
|
||||
emit(pos4[j]);
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user