Added support for only enabling SignedDistanceField shader path when font resolution is greater than 16.
This commit is contained in:
parent
fb0a995d7b
commit
78811462f1
@ -278,8 +278,6 @@ protected:
|
||||
|
||||
virtual osg::StateSet* createStateSet();
|
||||
|
||||
void assignStateSet();
|
||||
|
||||
Font* getActiveFont();
|
||||
const Font* getActiveFont() const;
|
||||
|
||||
|
@ -117,6 +117,18 @@ osg::StateSet* Text::createStateSet()
|
||||
|
||||
defineList["SHADOW"] = osg::StateSet::DefinePair(ss.str(), osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
if (_fontSize.second>16)
|
||||
{
|
||||
OSG_NOTICE<<"Requesting SDF support _fontSize.second="<<_fontSize.second<<std::endl;
|
||||
defineList["SIGNED_DISTNACE_FIELD"] = osg::StateSet::DefinePair("1", osg::StateAttribute::ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"Disabling SDF support _fontSize.second="<<_fontSize.second<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -205,11 +217,6 @@ osg::StateSet* Text::createStateSet()
|
||||
return stateset.release();
|
||||
}
|
||||
|
||||
void Text::assignStateSet()
|
||||
{
|
||||
setStateSet(createStateSet());
|
||||
}
|
||||
|
||||
Font* Text::getActiveFont()
|
||||
{
|
||||
return _font.valid() ? _font.get() : Font::getDefaultFont().get();
|
||||
|
@ -213,6 +213,9 @@ void TextBase::setFontResolution(unsigned int width, unsigned int height)
|
||||
if (_fontSize==size) return;
|
||||
|
||||
_fontSize = size;
|
||||
|
||||
assignStateSet();
|
||||
|
||||
computeGlyphRepresentation();
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,23 @@
|
||||
char text_sdf_frag[] = "$OSG_GLSL_VERSION\n"
|
||||
"\n"
|
||||
"#pragma import_defines( BACKDROP_COLOR, OUTLINE )\n"
|
||||
"#pragma import_defines( BACKDROP_COLOR, OUTLINE, SIGNED_DISTNACE_FIELD )\n"
|
||||
"\n"
|
||||
"#if !defined(GL_ES)\n"
|
||||
" #if __VERSION__>=400\n"
|
||||
" #define osg_TextureQueryLOD textureQueryLod\n"
|
||||
" #define USE_SIGNED_DISTNACE_FIELD\n"
|
||||
" #else\n"
|
||||
" #extension GL_ARB_texture_query_lod : enable\n"
|
||||
" #ifdef GL_ARB_texture_query_lod\n"
|
||||
" #define osg_TextureQueryLOD textureQueryLOD\n"
|
||||
" #define USE_SIGNED_DISTNACE_FIELD\n"
|
||||
"#ifdef SIGNED_DISTNACE_FIELD\n"
|
||||
"\n"
|
||||
" #if !defined(GL_ES)\n"
|
||||
" #if __VERSION__>=400\n"
|
||||
" #define osg_TextureQueryLOD textureQueryLod\n"
|
||||
" #define SIGNED_DISTNACE_FIELD_SUPPORTED\n"
|
||||
" #else\n"
|
||||
" #extension GL_ARB_texture_query_lod : enable\n"
|
||||
" #ifdef GL_ARB_texture_query_lod\n"
|
||||
" #define osg_TextureQueryLOD textureQueryLOD\n"
|
||||
" #define USE_SIGNED_DISTNACE_FIELD_SUPPORTED\n"
|
||||
" #endif\n"
|
||||
" #endif\n"
|
||||
" #endif\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"$OSG_PRECISION_FLOAT\n"
|
||||
"\n"
|
||||
@ -63,7 +66,7 @@ char text_sdf_frag[] = "$OSG_GLSL_VERSION\n"
|
||||
" #endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"#ifdef USE_SIGNED_DISTNACE_FIELD\n"
|
||||
"#ifdef USE_SIGNED_DISTNACE_FIELD_SUPPORTED\n"
|
||||
"vec4 distanceFieldColor()\n"
|
||||
"{\n"
|
||||
" float center_alpha = TEXTURE(glyphTexture, texCoord).r;\n"
|
||||
@ -115,7 +118,7 @@ char text_sdf_frag[] = "$OSG_GLSL_VERSION\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
"\n"
|
||||
"#ifdef USE_SIGNED_DISTNACE_FIELD\n"
|
||||
"#ifdef USE_SIGNED_DISTNACE_FIELD_SUPPORTED\n"
|
||||
"\n"
|
||||
" float mml = osg_TextureQueryLOD(glyphTexture, texCoord).x;\n"
|
||||
"\n"
|
||||
|
Loading…
Reference in New Issue
Block a user