From e325902bac87273df43c05c0b0eaac1ef7b08c80 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Wed, 19 Jul 2023 13:36:14 +0100 Subject: [PATCH] init commit --- Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp | 8 ++++---- Engine/source/gfx/gfxStateBlock.cpp | 1 + Engine/source/gfx/gfxStateBlock.h | 2 ++ Engine/source/gfx/gl/gfxGLEnumTranslate.cpp | 2 +- Engine/source/gfx/gl/gfxGLTextureObject.cpp | 1 + Engine/source/gfx/sim/gfxStateBlockData.cpp | 2 ++ 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp b/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp index 23844665b3..f2197c9299 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11StateBlock.cpp @@ -186,10 +186,10 @@ GFXD3D11StateBlock::GFXD3D11StateBlock(const GFXStateBlockDesc& desc) else mSamplerDesc[i].Filter = comparison ? D3D11_FILTER_COMPARISON_ANISOTROPIC : D3D11_FILTER_ANISOTROPIC; - mSamplerDesc[i].BorderColor[0] = 1.0f; - mSamplerDesc[i].BorderColor[1] = 1.0f; - mSamplerDesc[i].BorderColor[2] = 1.0f; - mSamplerDesc[i].BorderColor[3] = 1.0f; + mSamplerDesc[i].BorderColor[0] = gfxSamplerState.borderColor.red; + mSamplerDesc[i].BorderColor[1] = gfxSamplerState.borderColor.green; + mSamplerDesc[i].BorderColor[2] = gfxSamplerState.borderColor.blue; + mSamplerDesc[i].BorderColor[3] = gfxSamplerState.borderColor.alpha; mSamplerDesc[i].ComparisonFunc = GFXD3D11CmpFunc[gfxSamplerState.samplerFunc]; hr = D3D11DEVICE->CreateSamplerState(&mSamplerDesc[i], &mSamplerStates[i]); diff --git a/Engine/source/gfx/gfxStateBlock.cpp b/Engine/source/gfx/gfxStateBlock.cpp index 61ff8958c4..80d3289ee7 100644 --- a/Engine/source/gfx/gfxStateBlock.cpp +++ b/Engine/source/gfx/gfxStateBlock.cpp @@ -278,6 +278,7 @@ GFXSamplerStateDesc::GFXSamplerStateDesc() samplerFunc = GFXCmpNever; maxAnisotropy = 1; mipLODBias = 0.0f; + borderColor = LinearColorF::WHITE; } GFXSamplerStateDesc GFXSamplerStateDesc::getWrapLinear() diff --git a/Engine/source/gfx/gfxStateBlock.h b/Engine/source/gfx/gfxStateBlock.h index f8f19f3605..5cefd381a3 100644 --- a/Engine/source/gfx/gfxStateBlock.h +++ b/Engine/source/gfx/gfxStateBlock.h @@ -49,6 +49,8 @@ struct GFXSamplerStateDesc GFXCmpFunc samplerFunc; + LinearColorF borderColor; + /// The maximum anisotropy used when one of the filter types /// is set to anisotropic. /// diff --git a/Engine/source/gfx/gl/gfxGLEnumTranslate.cpp b/Engine/source/gfx/gl/gfxGLEnumTranslate.cpp index 93c8ee57cb..b5b56fc6f5 100644 --- a/Engine/source/gfx/gl/gfxGLEnumTranslate.cpp +++ b/Engine/source/gfx/gl/gfxGLEnumTranslate.cpp @@ -93,7 +93,7 @@ void GFXGLEnumTranslate::init() GFXGLTextureAddress[GFXAddressWrap] = GL_REPEAT; GFXGLTextureAddress[GFXAddressMirror] = GL_REPEAT; GFXGLTextureAddress[GFXAddressClamp] = GL_CLAMP_TO_EDGE; - GFXGLTextureAddress[GFXAddressBorder] = GL_REPEAT; + GFXGLTextureAddress[GFXAddressBorder] = GL_CLAMP_TO_BORDER; GFXGLTextureAddress[GFXAddressMirrorOnce] = GL_REPEAT; // Stencil ops diff --git a/Engine/source/gfx/gl/gfxGLTextureObject.cpp b/Engine/source/gfx/gl/gfxGLTextureObject.cpp index 198292dbc8..9d60401cc7 100644 --- a/Engine/source/gfx/gl/gfxGLTextureObject.cpp +++ b/Engine/source/gfx/gl/gfxGLTextureObject.cpp @@ -220,6 +220,7 @@ void GFXGLTextureObject::initSamplerState(const GFXSamplerStateDesc &ssd) if(static_cast< GFXGLDevice* >( GFX )->supportsAnisotropic() ) glTexParameterf(mBinding, GL_TEXTURE_MAX_ANISOTROPY_EXT, ssd.maxAnisotropy); + glTexParameterfv(mBinding, GL_TEXTURE_BORDER_COLOR, ssd.borderColor); mNeedInitSamplerState = false; mSampler = ssd; } diff --git a/Engine/source/gfx/sim/gfxStateBlockData.cpp b/Engine/source/gfx/sim/gfxStateBlockData.cpp index 9b015559df..ffbd36f761 100644 --- a/Engine/source/gfx/sim/gfxStateBlockData.cpp +++ b/Engine/source/gfx/sim/gfxStateBlockData.cpp @@ -315,6 +315,8 @@ void GFXSamplerStateData::initPersistFields() endGroup( "Filter State" ); + addField("borderColor", TypeColorF, Offset(mState.borderColor, GFXSamplerStateData), ""); + addField("samplerFunc", TypeGFXCmpFunc, Offset(mState.samplerFunc, GFXSamplerStateData), "Compares sampled data against existing sampled data. The default is GFXCmpNever."); }