Shadows: Fix broken shadows due to zero-clear added in 9417acc2

This commit is contained in:
ocornut 2021-08-24 18:59:10 +02:00
parent 9758b4b503
commit 820cf24574
2 changed files with 4 additions and 2 deletions

View File

@ -3216,7 +3216,8 @@ struct ImFontAtlasShadowTexConfig
float TexDistanceFieldOffset; // How much to offset the distance field by (allows over/under-shadowing, potentially useful for accommodating rounded corners on the "casting" shape).
bool TexBlur; // Do we want to Gaussian blur the shadow texture?
IMGUI_API ImFontAtlasShadowTexConfig();
inline ImFontAtlasShadowTexConfig() { memset(this, 0, sizeof(*this)); }
IMGUI_API void SetupDefaults();
int GetRectTexPadding() const { return 2; } // Number of pixels of padding to add to the rectangular texture to avoid sampling artifacts at the edges.
int CalcRectTexSize() const { return TexCornerSize + TexEdgeSize + GetRectTexPadding(); } // The size of the texture area required for the actual 2x2 rectangle shadow texture (after the redundant corners have been removed). Padding is required here to avoid sampling artifacts at the edge adjoining the removed corners. int CalcConvexTexWidth() const; // The width of the texture area required for the convex shape shadow texture.
int GetConvexTexPadding() const { return 8; } // Number of pixels of padding to add to the convex shape texture to avoid sampling artifacts at the edges. This also acts as padding for the expanded corner triangles.

View File

@ -372,7 +372,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
// [SECTION] ImFontAtlasShadowTexConfig
//-----------------------------------------------------------------------------
ImFontAtlasShadowTexConfig::ImFontAtlasShadowTexConfig()
void ImFontAtlasShadowTexConfig::SetupDefaults()
{
TexCornerSize = 16;
TexEdgeSize = 1;
@ -3149,6 +3149,7 @@ ImFontAtlas::ImFontAtlas()
TexGlyphPadding = 1;
PackIdMouseCursors = PackIdLines = -1;
ShadowRectIds[0] = ShadowRectIds[1] = -1;
ShadowTexConfig.SetupDefaults();
}
ImFontAtlas::~ImFontAtlas()