[Bf-blender-cvs] [c614aa2] opensubdiv-modifier: OpenSubdiv: Simplify code around wireframe mittion
Sergey Sharybin
noreply at git.blender.org
Thu Jul 17 20:11:33 CEST 2014
Commit: c614aa2c19a0180323109c822880458f2c7a7e14
Author: Sergey Sharybin
Date: Thu Jul 17 13:32:29 2014 +0600
https://developer.blender.org/rBc614aa2c19a0180323109c822880458f2c7a7e14
OpenSubdiv: Simplify code around wireframe mittion
===================================================================
M intern/opensubdiv/gpu_shader_opensubd_display.glsl
===================================================================
diff --git a/intern/opensubdiv/gpu_shader_opensubd_display.glsl b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
index d1cb670..1741b01 100644
--- a/intern/opensubdiv/gpu_shader_opensubd_display.glsl
+++ b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
@@ -107,6 +107,15 @@ void emit(int index, vec3 normal)
gl_Position = projectionMatrix * inpt[index].v.position;
EmitVertex();
}
+
+# ifdef WIREFRAME
+void emit_edge(int v0, int v1, vec3 normal)
+{
+ emit(v0, normal);
+ emit(v1, normal);
+}
+# endif
+
#else
void emit(int index)
{
@@ -122,6 +131,15 @@ void emit(int index)
gl_Position = projectionMatrix * inpt[index].v.position;
EmitVertex();
}
+
+# ifdef WIREFRAME
+void emit_edge(int v0, int v1)
+{
+ emit(v0);
+ emit(v1);
+}
+# endif
+
#endif
void main()
@@ -131,21 +149,17 @@ void main()
#ifdef FLAT_SHADING
vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz;
vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz;
- vec3 n0 = normalize(cross(B, A));
+ vec3 flat_normal = normalize(cross(B, A));
# ifndef WIREFRAME
- emit(0, n0);
- emit(1, n0);
- emit(3, n0);
- emit(2, n0);
+ emit(0, flat_normal);
+ emit(1, flat_normal);
+ emit(3, flat_normal);
+ emit(2, flat_normal);
# else
- emit(0, n0);
- emit(1, n0);
- emit(1, n0);
- emit(2, n0);
- emit(2, n0);
- emit(3, n0);
- emit(3, n0);
- emit(0, n0);
+ emit_edge(0, 1, flat_normal);
+ emit_edge(1, 2, flat_normal);
+ emit_edge(2, 3, flat_normal);
+ emit_edge(3, 0, flat_normal);
# endif
#else
# ifndef WIREFRAME
@@ -154,14 +168,10 @@ void main()
emit(3);
emit(2);
# else
- emit(0);
- emit(1);
- emit(1);
- emit(2);
- emit(2);
- emit(3);
- emit(3);
- emit(0);
+ emit_edge(0, 1);
+ emit_edge(1, 2);
+ emit_edge(2, 3);
+ emit_edge(3, 0);
# endif
#endif
More information about the Bf-blender-cvs
mailing list