mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
shader tweaks
This commit is contained in:
@@ -31,6 +31,7 @@ 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();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#version 430
|
||||
|
||||
in vec4 col;
|
||||
layout(location=1) in vec4 col;
|
||||
layout(location=2) in vec3 normal;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
float bright = dot(normal, normalize(vec3(-0.6, 1, 2)));
|
||||
bright = .6 + .3 * bright;
|
||||
|
||||
color = col;
|
||||
color.xyz *= bright;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,9 @@ layout(std140, binding=1) uniform Matrices {
|
||||
in ivec4 vInds[];
|
||||
in vec4 vCol[];
|
||||
|
||||
out vec4 pos;
|
||||
out vec4 col;
|
||||
layout(location=0) out vec4 pos;
|
||||
layout(location=1) out vec4 col;
|
||||
layout(location=2) out vec3 normal;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
@@ -60,6 +61,17 @@ void main() {
|
||||
sect[S++] = mix(a, b, t);
|
||||
}
|
||||
|
||||
normal = cross(sect[1].xyz - sect[0].xyz, sect[2].xyz - sect[0].xyz);
|
||||
normal = normalize(normal);
|
||||
|
||||
float r = dot(normal, sect[0].xyz);
|
||||
|
||||
if (abs(r) < 0.001)
|
||||
r = dot(normal, sect[0].xyz + vec3(0, 0, 1));
|
||||
|
||||
if (r < 0)
|
||||
normal *= -1;
|
||||
|
||||
for (int s = 0; s < S; ++s) {
|
||||
emit(sect[s]);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ in vec4 pos;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
if (pos.w > 0.8) discard;
|
||||
|
||||
float d = smoothstep(-2, 2, pos.z);
|
||||
color = vec4(c * d, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user