diff --git a/include/boo/graphicsdev/IGraphicsDataFactory.hpp b/include/boo/graphicsdev/IGraphicsDataFactory.hpp index d9bd9c6..71998e8 100644 --- a/include/boo/graphicsdev/IGraphicsDataFactory.hpp +++ b/include/boo/graphicsdev/IGraphicsDataFactory.hpp @@ -71,7 +71,8 @@ enum class TextureClampMode { Repeat, ClampToWhite, - ClampToEdge + ClampToEdge, + ClampToEdgeNearest }; /** Typeless texture */ diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index a87bc70..3cd43be 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -257,6 +257,15 @@ static void SetClampMode(GLenum target, TextureClampMode clampMode) glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); break; } + case TextureClampMode::ClampToEdgeNearest: + { + glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + break; + } } } @@ -274,7 +283,7 @@ class GLTextureS : public GraphicsDataNode glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (mips > 1) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mips-1); } else diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index a110323..06bf029 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -1129,7 +1129,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue IGraphicsContext* m_parent; id m_cmdBuf; id m_enc; - id m_samplers[3]; + id m_samplers[4]; bool m_running = true; int m_fillBuf = 0; @@ -1162,6 +1162,13 @@ struct MetalCommandQueue : IGraphicsCommandQueue sampDesc.sAddressMode = MTLSamplerAddressModeClampToEdge; sampDesc.tAddressMode = MTLSamplerAddressModeClampToEdge; m_samplers[2] = [ctx->m_dev newSamplerStateWithDescriptor:sampDesc]; + + sampDesc.rAddressMode = MTLSamplerAddressModeClampToEdge; + sampDesc.sAddressMode = MTLSamplerAddressModeClampToEdge; + sampDesc.tAddressMode = MTLSamplerAddressModeClampToEdge; + sampDesc.minFilter = MTLSamplerMinMagFilterNearest; + sampDesc.magFilter = MTLSamplerMinMagFilterNearest; + m_samplers[3] = [ctx->m_dev newSamplerStateWithDescriptor:sampDesc]; } } @@ -1192,7 +1199,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue cbind->bind(m_enc, m_fillBuf); m_boundData = cbind; m_currentPrimitive = cbind->m_pipeline.cast()->m_drawPrim; - [m_enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 3)]; + [m_enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 4)]; } } @@ -1493,7 +1500,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue MetalShaderDataBinding* gammaBinding = gfxF->m_gammaBinding.cast(); gammaBinding->m_texs[0].tex = m_needsDisplay.get(); gammaBinding->bind(enc, m_drawBuf); - [enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 3)]; + [enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 4)]; [enc drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; gammaBinding->m_texs[0].tex.reset(); [enc endEncoding];