display slice and wireframe simultaneously

This commit is contained in:
2020-01-30 18:40:15 -05:00
parent 109ac9da10
commit e953f0e13d
12 changed files with 203 additions and 105 deletions

View File

@@ -0,0 +1,38 @@
#version 430
#define SUBS 20
layout(lines) in;
layout(line_strip, max_vertices = SUBS) out;
layout(std430, binding=1) buffer Positions {
vec4 verts[];
};
layout(std140, binding=1) uniform Matrices {
mat4 proj;
mat4 view;
};
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
in vec4 gpos[];
out vec4 vpos;
vec4 stereo(vec4 v) {
return vec4(v.xyz, 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

@@ -5,9 +5,22 @@
layout(lines) in;
layout(line_strip, max_vertices = SUBS) out;
layout(location=0) uniform mat4 proj;
layout(std430, binding=1) buffer Positions {
vec4 verts[];
};
layout(std140, binding=1) uniform Matrices {
mat4 proj;
mat4 view;
};
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
in vec4 gpos[];
out vec4 vpos;
vec4 stereo(vec4 v) {

View File

@@ -0,0 +1,24 @@
#version 430
layout(std430, binding=1) buffer Positions {
vec4 verts[];
};
layout(std140, binding=1) uniform Matrices {
mat4 proj;
mat4 view;
};
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
out vec4 vpos;
void main() {
vec4 pos = verts[gl_VertexID];
vpos = view * pos;
gl_Position = proj * vec4(vpos.xyz / (1), 1);
gl_PointSize = 5;
}

View File

@@ -0,0 +1,24 @@
#version 430
layout(std430, binding=1) buffer Positions {
vec4 verts[];
};
layout(std140, binding=1) uniform Matrices {
mat4 proj;
mat4 view;
};
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
};
out vec4 vpos;
void main() {
vec4 pos = verts[gl_VertexID];
vpos = view * pos;
gl_Position = proj * vec4(vpos.xyz / (1 - vpos.w), 1);
gl_PointSize = 5;
}

View File

@@ -1,17 +0,0 @@
#version 430
out gl_PerVertex {
vec4 gl_Position;
};
layout(location=0) uniform mat4 proj;
layout(location=1) uniform mat4 view;
layout(location=0) in vec4 pos;
out vec4 vpos;
void main() {
vpos = view * pos;
gl_Position = proj * vec4(vpos.xyz / (1), 1);
}

View File

@@ -1,14 +0,0 @@
#version 430
layout(location=0) uniform mat4 proj;
layout(location=1) uniform mat4 view;
layout(location=0) in vec4 pos;
out vec4 vpos;
void main() {
vpos = view * pos;
gl_Position = proj * vec4(vpos.xyz / (1), 1);
gl_PointSize = 5;
}

View File

@@ -1,15 +0,0 @@
#version 430
layout(location=0) uniform mat4 proj;
layout(location=1) uniform mat4 view;
layout(location=0) in vec4 pos;
out vec4 vpos;
void main() {
int i = gl_VertexID;
vpos = view * pos;
gl_Position = proj * vec4(vpos.xyz / (1 - vpos.w), 1);
gl_PointSize = 5 * smoothstep(-2, 2, gl_Position.z);
}

View File

@@ -1,11 +0,0 @@
#version 430
in vec4 vpos;
out vec4 color;
void main() {
float d = smoothstep(-2, 2, vpos.z);
vec3 off = 1.04 * vec3(0, 2, 4) + 2 * vec3(vpos.w);
color = vec4(d * cos(off), 1);
}