atlas resolution independent scale

This commit is contained in:
jrkb 2023-06-03 17:16:02 +02:00
parent 3016879e22
commit 1ab9d7b2cc
4 changed files with 5 additions and 0 deletions

View file

@ -14,6 +14,7 @@ void MsdfAtlasLayerCombo::setup(const ComboIdentifier & layerIdentifier,
atlasSettings.minimumScale = this->settings.minimumScale;
atlasSettings.characters = "";
atlasSettings.maxInterpolationStepSize = this->settings.maxInterpolationStepSize;
scaleFactor = 64.0 / this->settings.scale;
atlas = make_shared <ofxMsdfgen::Atlas>();
@ -43,6 +44,7 @@ void MsdfAtlasLayerCombo::careForChild(shared_ptr <Layer> layer){
msdfLayer->setDirtyDirty(true);
msdfLayer->setAtlas(this->atlas);
msdfLayer->setShader(msdfShader);
msdfLayer->scaleFactor = scaleFactor;
auto & as = atlas->settings;
for(const char c : layer->getProps().text){
if(as.characters.find(c) == std::string::npos){

View file

@ -33,5 +33,6 @@ class MsdfAtlasLayerCombo : public AtlasLayerCombo {
VFlipState vFlip;
ComboIdentifier identifier;
bool isDirty = false;
float scaleFactor = 1.0;
};
}

View file

@ -168,6 +168,7 @@ void MsdfLayer::drawCharacter(const char character,
const ofImage & atlasImage = atlas->getAtlasImage();
ofDisableAlphaBlending();
ofEnableDepthTest();
scale *= scaleFactor;
float pixelRange = 2;
int atlas_w = atlasImage.getWidth();
int atlas_h = atlasImage.getHeight();

View file

@ -52,6 +52,7 @@ class MsdfLayer : public Layer {
/// \brief hashed id, or just counting up
string id = "";
VFlipState vFlip = V_FLIP_UNKNOWN;
float scaleFactor = 1.0;
private:
Props lastProps;