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:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user