You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice that if the INativeTexture is already bound, it skips setting the wrap mode. This is incorrect since a single INativeTexture (ie. an atlas) can have textures with different wrap modes in it.
There was already a special case added for TextureWhitePixel in #6350 but that does not fix the issue for other textures.
Here's a test case to reproduce the issue. Note that I had to downscale "sample-texture.png" from 512x512 to 256x256 since the 512x512 size does not allow fitting 2 of them in the 1024x1024 atlas.
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.// See the LICENCE file in the repository root for full licence text.usingosu.Framework.Allocation;usingosu.Framework.Graphics.Primitives;usingosu.Framework.Graphics.Sprites;usingosu.Framework.Graphics.Textures;namespaceosu.Framework.Tests.Visual{publicpartialclassTestSceneSpriteWrap:FrameworkTestScene{[BackgroundDependencyLoader]privatevoidload(TextureStorestore){floaty=0f;SpritemakeSprite(WrapModewrapModeS){varo=newSprite{Width=100,Height=50,Texture=store.Get("sample-texture-256",wrapModeS,WrapMode.None),TextureRectangle=newRectangleF(0f,0f,0.5f,1f),Y=y};y+=50;returno;}// sets Renderer.CurrentWrapMode to ClampToBorder and binds the atlas for sample-texture-256Add(makeSprite(WrapMode.ClampToBorder));// this wrap mode will be ignored and drawn as ClampToBorder insteadAdd(makeSprite(WrapMode.Repeat));Add(newSpriteText{Y=y,Text="Text to cause bind to different texture atlas"});y+=20;// We should expect this to look identical to the second sprite, but it ends up// looking different due to the texture bind order.// This sprite is drawn correctly.Add(makeSprite(WrapMode.Repeat));}}}
This is my recommended fix, though I don't know much about the intricacies of the render code:
diff --git a/osu.Framework/Graphics/Rendering/Renderer.cs b/osu.Framework/Graphics/Rendering/Renderer.cs
index 8066d379e..01a8a1f39 100644
--- a/osu.Framework/Graphics/Rendering/Renderer.cs+++ b/osu.Framework/Graphics/Rendering/Renderer.cs@@ -818,7 +818,10 @@ public bool BindTexture(Texture texture, int unit, WrapMode? wrapModeS, WrapMode
public bool BindTexture(INativeTexture texture, int unit = 0, WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = WrapMode.None)
{
if (lastActiveTextureUnit == unit && lastBoundTexture[unit] == texture)
+ {+ setWrapMode(wrapModeS, wrapModeT);
return true;
+ }
FlushCurrentBatch(FlushBatchSource.BindTexture);
The text was updated successfully, but these errors were encountered:
Found on 2024.523.0, confirmed and tested on 2024.1025.0
When a texture is bound through
Renderer.BindTexture
, the wrap mode is ignored if the texture is a part of the currently bound atlas.The logic for this is in:
osu-framework/osu.Framework/Graphics/Rendering/Renderer.cs
Lines 790 to 839 in 0750044
Notice that if the
INativeTexture
is already bound, it skips setting the wrap mode. This is incorrect since a singleINativeTexture
(ie. an atlas) can have textures with different wrap modes in it.There was already a special case added for
TextureWhitePixel
in #6350 but that does not fix the issue for other textures.Here's a test case to reproduce the issue. Note that I had to downscale "sample-texture.png" from 512x512 to 256x256 since the 512x512 size does not allow fitting 2 of them in the 1024x1024 atlas.
This is my recommended fix, though I don't know much about the intricacies of the render code:
The text was updated successfully, but these errors were encountered: