Add fractional spacing mode for patch rendering.

This commit is contained in:
Takahito Tejima 2013-06-27 13:34:25 -07:00
parent 59cdf85a5b
commit 184e90f9a1
4 changed files with 43 additions and 7 deletions

View File

@ -184,6 +184,7 @@ enum HudCheckBox { kHUD_CB_DISPLAY_CAGE_EDGES,
kHUD_CB_ANIMATE_VERTICES,
kHUD_CB_DISPLAY_PATCH_COLOR,
kHUD_CB_VIEW_LOD,
kHUD_CB_FRACTIONAL_SPACING,
kHUD_CB_PATCH_CULL,
kHUD_CB_FREEZE };
@ -216,6 +217,7 @@ int g_fullscreen = 0,
int g_displayPatchColor = 1,
g_screenSpaceTess = 0,
g_fractionalSpacing = 0,
g_patchCull = 0;
float g_rotate[2] = {0, 0},
@ -914,15 +916,17 @@ drawCageVertices() {
//------------------------------------------------------------------------------
union Effect {
Effect(int displayStyle_, int screenSpaceTess_, int patchCull_) : value(0) {
Effect(int displayStyle_, int screenSpaceTess_, int fractionalSpacing_, int patchCull_) : value(0) {
displayStyle = displayStyle_;
screenSpaceTess = screenSpaceTess_;
fractionalSpacing = fractionalSpacing_;
patchCull = patchCull_;
}
struct {
int displayStyle:3;
int screenSpaceTess:1;
int fractionalSpacing:1;
int patchCull:1;
};
int value;
@ -994,6 +998,9 @@ EffectDrawRegistry::_CreateDrawSourceConfig(DescType const & desc)
if (effect.screenSpaceTess) {
sconfig->commonShader.AddDefine("OSD_ENABLE_SCREENSPACE_TESSELLATION");
}
if (effect.fractionalSpacing) {
sconfig->commonShader.AddDefine("OSD_FRACTIONAL_ODD_SPACING");
}
if (effect.patchCull) {
sconfig->commonShader.AddDefine("OSD_ENABLE_PATCH_CULL");
}
@ -1082,7 +1089,7 @@ EffectDrawRegistry effectRegistry;
static Effect
GetEffect()
{
return Effect(g_displayStyle, g_screenSpaceTess, g_patchCull);
return Effect(g_displayStyle, g_screenSpaceTess, g_fractionalSpacing, g_patchCull);
}
//------------------------------------------------------------------------------
@ -1602,6 +1609,9 @@ callbackCheckBox(bool checked, int button)
case kHUD_CB_VIEW_LOD:
g_screenSpaceTess = checked;
break;
case kHUD_CB_FRACTIONAL_SPACING:
g_fractionalSpacing = checked;
break;
case kHUD_CB_PATCH_CULL:
g_patchCull = checked;
break;
@ -1654,10 +1664,12 @@ initHUD()
350, 70, callbackCheckBox, kHUD_CB_DISPLAY_PATCH_COLOR, 'p');
g_hud.AddCheckBox("Screen space LOD (V)", g_screenSpaceTess != 0,
350, 90, callbackCheckBox, kHUD_CB_VIEW_LOD, 'v');
g_hud.AddCheckBox("Fractional spacing (V)", g_fractionalSpacing != 0,
350, 110, callbackCheckBox, kHUD_CB_FRACTIONAL_SPACING, 't');
g_hud.AddCheckBox("Frustum Patch Culling (B)", g_patchCull != 0,
350, 110, callbackCheckBox, kHUD_CB_PATCH_CULL, 'b');
350, 130, callbackCheckBox, kHUD_CB_PATCH_CULL, 'b');
g_hud.AddCheckBox("Freeze (spc)", g_freeze != 0,
350, 130, callbackCheckBox, kHUD_CB_FREEZE, ' ');
350, 150, callbackCheckBox, kHUD_CB_FREEZE, ' ');
if (OpenSubdiv::OsdGLDrawContext::SupportsAdaptiveTessellation())
g_hud.AddCheckBox("Adaptive (`)", g_adaptive!=0, 10, 150, callbackAdaptive, 0, '`');

View File

@ -195,6 +195,7 @@ enum HudCheckBox { HUD_CB_ADAPTIVE,
HUD_CB_ANIMATE_VERTICES,
HUD_CB_DISPLAY_PATCH_COLOR,
HUD_CB_VIEW_LOD,
HUD_CB_FRACTIONAL_SPACING,
HUD_CB_PATCH_CULL,
HUD_CB_IBL,
HUD_CB_BLOOM };
@ -224,8 +225,9 @@ bool g_adaptive = false,
g_displayPatchColor = false,
g_patchCull = true,
g_screenSpaceTess = true,
g_fractionalSpacing = false,
g_ibl = false,
g_bloom = true;
g_bloom = false;
GLuint g_transformUB = 0,
g_transformBinding = 0,
@ -694,6 +696,7 @@ union Effect {
int specular:1;
int patchCull:1;
int screenSpaceTess:1;
int fractionalSpacing:1;
int ibl:1;
unsigned int wire:2;
};
@ -729,6 +732,8 @@ EffectDrawRegistry::_CreateDrawSourceConfig(DescType const & desc)
sconfig->commonShader.AddDefine("OSD_ENABLE_PATCH_CULL");
if (effect.screenSpaceTess)
sconfig->commonShader.AddDefine("OSD_ENABLE_SCREENSPACE_TESSELLATION");
if (effect.fractionalSpacing)
sconfig->commonShader.AddDefine("OSD_FRACTIONAL_ODD_SPACING");
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
const char *glslVersion = "#version 400\n";
@ -1463,6 +1468,7 @@ drawModel() {
effect.specular = g_specular;
effect.patchCull = g_patchCull;
effect.screenSpaceTess = g_screenSpaceTess;
effect.fractionalSpacing = g_fractionalSpacing;
effect.ibl = g_ibl;
effect.wire = g_wire;
@ -1820,6 +1826,9 @@ callbackCheckBox(bool checked, int button)
case HUD_CB_VIEW_LOD:
g_screenSpaceTess = checked;
break;
case HUD_CB_FRACTIONAL_SPACING:
g_fractionalSpacing = checked;
break;
case HUD_CB_PATCH_CULL:
g_patchCull = checked;
break;
@ -2193,9 +2202,12 @@ int main(int argc, char ** argv) {
450, 30, callbackCheckBox, HUD_CB_DISPLAY_PATCH_COLOR, 'p');
g_hud.AddCheckBox("Screen space LOD (V)", g_screenSpaceTess,
450, 50, callbackCheckBox, HUD_CB_VIEW_LOD, 'v');
g_hud.AddCheckBox("Fractional spacing (T)", g_fractionalSpacing,
450, 70, callbackCheckBox, HUD_CB_FRACTIONAL_SPACING, 't');
g_hud.AddCheckBox("Frustum Patch Culling (B)", g_patchCull,
450, 70, callbackCheckBox, HUD_CB_PATCH_CULL, 'b');
g_hud.AddCheckBox("Bloom (Y)", g_bloom, 450, 90, callbackCheckBox, HUD_CB_BLOOM, 'y');
450, 90, callbackCheckBox, HUD_CB_PATCH_CULL, 'b');
g_hud.AddCheckBox("Bloom (Y)", g_bloom,
450, 110, callbackCheckBox, HUD_CB_BLOOM, 'y');
if (OpenSubdiv::OsdGLDrawContext::SupportsAdaptiveTessellation())
g_hud.AddCheckBox("Adaptive (`)", g_adaptive, 10, 150, callbackCheckBox, HUD_CB_ADAPTIVE, '`');

View File

@ -220,6 +220,12 @@ void main()
layout(quads) in;
#endif
#ifdef OSD_FRACTIONAL_ODD_SPACING
layout(fractional_odd_spacing) in;
#elif OSD_FRACTIONAL_EVEN_SPACING
layout(fractional_even_spacing) in;
#endif
in block {
ControlVertex v;
} inpt[];

View File

@ -276,6 +276,12 @@ void main()
layout(quads) in;
layout(cw) in;
#ifdef OSD_FRACTIONAL_ODD_SPACING
layout(fractional_odd_spacing) in;
#elif OSD_FRACTIONAL_EVEN_SPACING
layout(fractional_even_spacing) in;
#endif
in block {
GregEvalVertex v;
} inpt[];