diff --git a/examples/glFVarViewer/glFVarViewer.cpp b/examples/glFVarViewer/glFVarViewer.cpp index bae93fe8d7..4d5fd8a20b 100644 --- a/examples/glFVarViewer/glFVarViewer.cpp +++ b/examples/glFVarViewer/glFVarViewer.cpp @@ -520,13 +520,15 @@ fitFrame() { union Effect { - Effect(int displayStyle_, int uvDraw_) : value(0) { + Effect(int displayStyle_, int singleCreasePatch_, int uvDraw_) : value(0) { displayStyle = displayStyle_; + singleCreasePatch = singleCreasePatch_; uvDraw = uvDraw_; } struct { unsigned int displayStyle:3; + unsigned int singleCreasePatch:1; unsigned int uvDraw:1; }; int value; @@ -539,7 +541,7 @@ union Effect { static Effect GetEffect(bool uvDraw = false) { - return Effect(g_displayStyle, uvDraw); + return Effect(g_displayStyle, g_singleCreasePatch, uvDraw); } // --------------------------------------------------------------------------- @@ -591,6 +593,11 @@ class ShaderCache : public GLShaderCache { ss << "#define PRIM_TRI\n"; } + if (effectDesc.effect.singleCreasePatch && + type == Far::PatchDescriptor::REGULAR) { + ss << "#define OSD_PATCH_ENABLE_SINGLE_CREASE\n"; + } + if (effectDesc.effect.uvDraw) { ss << "#define GEOMETRY_OUT_FILL\n"; ss << "#define GEOMETRY_UV_VIEW\n"; diff --git a/examples/glFVarViewer/shader.glsl b/examples/glFVarViewer/shader.glsl index dd306dcfc3..73803ea34e 100644 --- a/examples/glFVarViewer/shader.glsl +++ b/examples/glFVarViewer/shader.glsl @@ -106,6 +106,9 @@ OSD_USER_VARYING_ATTRIBUTE_DECLARE out block { OutputVertex v; +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + vec2 vSegments; +#endif OSD_USER_VARYING_DECLARE } outpt; @@ -124,6 +127,9 @@ void main() #if defined OSD_COMPUTE_NORMAL_DERIVATIVES outpt.v.Nu = vec3(0); outpt.v.Nv = vec3(0); +#endif +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + outpt.vSegments = vec2(0); #endif // -- @@ -157,12 +163,18 @@ void main() layout(triangle_strip, max_vertices = EDGE_VERTS) out; in block { OutputVertex v; +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + vec2 vSegments; +#endif OSD_USER_VARYING_DECLARE } inpt[EDGE_VERTS]; out block { OutputVertex v; noperspective out vec4 edgeDistance; +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + vec2 vSegments; +#endif OSD_USER_VARYING_DECLARE } outpt; @@ -211,6 +223,10 @@ void emit(int index, vec3 normal) outpt.v.normal = normal; #endif +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + outpt.vSegments = inpt[index].vSegments; +#endif + #ifdef SHADING_FACEVARYING_UNIFORM_SUBDIVISION // interpolate fvar data at refined tri or quad vertex locations #ifdef PRIM_TRI @@ -342,6 +358,9 @@ void main() in block { OutputVertex v; noperspective in vec4 edgeDistance; +#ifdef OSD_PATCH_ENABLE_SINGLE_CREASE + vec2 vSegments; +#endif OSD_USER_VARYING_DECLARE } inpt;