shader tweaks

This commit is contained in:
2020-03-10 18:45:12 -04:00
parent 63692ced17
commit fd51590a8c
4 changed files with 23 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ void main() {
for (int i = 0; i < SUBS; i++) { for (int i = 0; i < SUBS; i++) {
vpos = mix(gpos[0], gpos[1], i * 1.0f / (SUBS - 1)); vpos = mix(gpos[0], gpos[1], i * 1.0f / (SUBS - 1));
vpos = normalize(vpos); vpos = normalize(vpos);
gl_Position = proj * stereo(vpos); gl_Position = proj * stereo(vpos);
EmitVertex(); EmitVertex();
} }

View File

@@ -1,9 +1,14 @@
#version 430 #version 430
in vec4 col; layout(location=1) in vec4 col;
layout(location=2) in vec3 normal;
out vec4 color; out vec4 color;
void main() { void main() {
float bright = dot(normal, normalize(vec3(-0.6, 1, 2)));
bright = .6 + .3 * bright;
color = col; color = col;
color.xyz *= bright;
} }

View File

@@ -15,8 +15,9 @@ layout(std140, binding=1) uniform Matrices {
in ivec4 vInds[]; in ivec4 vInds[];
in vec4 vCol[]; in vec4 vCol[];
out vec4 pos; layout(location=0) out vec4 pos;
out vec4 col; layout(location=1) out vec4 col;
layout(location=2) out vec3 normal;
out gl_PerVertex { out gl_PerVertex {
vec4 gl_Position; vec4 gl_Position;
@@ -60,6 +61,17 @@ void main() {
sect[S++] = mix(a, b, t); 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) { for (int s = 0; s < S; ++s) {
emit(sect[s]); emit(sect[s]);
} }

View File

@@ -7,6 +7,8 @@ in vec4 pos;
out vec4 color; out vec4 color;
void main() { void main() {
if (pos.w > 0.8) discard;
float d = smoothstep(-2, 2, pos.z); float d = smoothstep(-2, 2, pos.z);
color = vec4(c * d, 1); color = vec4(c * d, 1);
} }