Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions examples/glFVarViewer/glFVarViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -539,7 +541,7 @@ union Effect {
static Effect
GetEffect(bool uvDraw = false) {

return Effect(g_displayStyle, uvDraw);
return Effect(g_displayStyle, g_singleCreasePatch, uvDraw);
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -591,6 +593,11 @@ class ShaderCache : public GLShaderCache<EffectDesc> {
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";
Expand Down
19 changes: 19 additions & 0 deletions examples/glFVarViewer/shader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
// --

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down