diff --git a/src/util/noise_texture.cpp b/src/util/noise_texture.cpp index 61935f0..3c71fc1 100644 --- a/src/util/noise_texture.cpp +++ b/src/util/noise_texture.cpp @@ -145,6 +145,8 @@ void DrawTiledNoiseRect(ImDrawList* dl, const ImVec2& pMin, const ImVec2& pMax, if (!dl || (tintColor & IM_COL32_A_MASK) == 0) return; ImGuiViewport* vp = ImGui::GetMainViewport(); +#ifdef DRAGONX_USE_DX11 + // DX11 sampler is CLAMP: keep the viewport-sized pre-tiled texture so UVs stay in [0,1]. int vpW = (int)vp->Size.x; int vpH = (int)vp->Size.y; if (vpW <= 0 || vpH <= 0) return; @@ -153,13 +155,24 @@ void DrawTiledNoiseRect(ImDrawList* dl, const ImVec2& pMin, const ImVec2& pMax, ImTextureID tex = GetTiledNoiseTexture(vpW, vpH, &texW, &texH); if (!tex || texW <= 0 || texH <= 0) return; - // Compute UVs: map screen-space rect to texture coordinates. // The tiled texture covers the entire viewport, so UV = screenPos / vpSize. // Subtract viewport origin for multi-viewport support. float u0 = (pMin.x - vp->Pos.x) / (float)texW; float v0 = (pMin.y - vp->Pos.y) / (float)texH; float u1 = (pMax.x - vp->Pos.x) / (float)texW; float v1 = (pMax.y - vp->Pos.y) / (float)texH; +#else + // GL: sample the resident 256x256 GL_REPEAT tile; UV phase anchored at the viewport + // origin, identical to the old pre-tiled texture (same LCG, same origin). + int sz = 0; + ImTextureID tex = GetNoiseTexture(&sz); + if (!tex || sz <= 0) return; + + float u0 = (pMin.x - vp->Pos.x) / (float)sz; + float v0 = (pMin.y - vp->Pos.y) / (float)sz; + float u1 = (pMax.x - vp->Pos.x) / (float)sz; + float v1 = (pMax.y - vp->Pos.y) / (float)sz; +#endif dl->AddImage(tex, pMin, pMax, ImVec2(u0, v0), ImVec2(u1, v1), tintColor); }