backport CLAMP_TO_EDGE fix to 0.48

backport_gl_clamp_removal
Bret Curtis 11 months ago
parent 00831a80fb
commit 3925903ad5

@ -289,6 +289,8 @@ namespace MWGui
if (!mTexture)
{
mTexture = new osg::Texture2D;
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mTexture->setInternalFormat(GL_RGB);
mTexture->setResizeNonPowerOfTwoHint(false);
}

@ -275,6 +275,8 @@ namespace MWRender
noBlendAlphaEnv->setCombine_RGB(osg::TexEnvCombine::REPLACE);
noBlendAlphaEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
osg::ref_ptr<osg::Texture2D> dummyTexture = new osg::Texture2D();
dummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
dummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
dummyTexture->setInternalFormat(GL_DEPTH_COMPONENT);
dummyTexture->setTextureSize(1, 1);
// This might clash with a shadow map, so make sure it doesn't cast shadows

@ -44,6 +44,8 @@ namespace MWRender
buffer.mipmappedSceneLuminanceTex->setInternalFormat(GL_R16F);
buffer.mipmappedSceneLuminanceTex->setSourceFormat(GL_RED);
buffer.mipmappedSceneLuminanceTex->setSourceType(GL_FLOAT);
buffer.mipmappedSceneLuminanceTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
buffer.mipmappedSceneLuminanceTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
buffer.mipmappedSceneLuminanceTex->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR_MIPMAP_NEAREST);
buffer.mipmappedSceneLuminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
buffer.mipmappedSceneLuminanceTex->setTextureSize(mWidth, mHeight);
@ -53,11 +55,15 @@ namespace MWRender
buffer.luminanceTex->setInternalFormat(GL_R16F);
buffer.luminanceTex->setSourceFormat(GL_RED);
buffer.luminanceTex->setSourceType(GL_FLOAT);
buffer.luminanceTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
buffer.luminanceTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
buffer.luminanceTex->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST);
buffer.luminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
buffer.luminanceTex->setTextureSize(1, 1);
buffer.luminanceProxyTex = new osg::Texture2D(*buffer.luminanceTex);
buffer.luminanceProxyTex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
buffer.luminanceProxyTex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
buffer.resolveFbo = new osg::FrameBufferObject;
buffer.resolveFbo->setAttachment(osg::FrameBufferObject::BufferComponent::COLOR_BUFFER0, osg::FrameBufferAttachment(buffer.luminanceTex));

@ -160,6 +160,8 @@ namespace MWRender
mTextures[i][Tex_OpaqueDepth] = new osg::Texture2DArray;
else
mTextures[i][Tex_OpaqueDepth] = new osg::Texture2D;
mTextures[i][Tex_OpaqueDepth]->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mTextures[i][Tex_OpaqueDepth]->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
}
}

@ -318,6 +318,8 @@ namespace MWRender
texture->setResizeNonPowerOfTwoHint(false);
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
camera->attach(osg::Camera::COLOR_BUFFER,texture);
image->setDataType(GL_UNSIGNED_BYTE);

@ -482,7 +482,10 @@ namespace MWRender
: mColor(osg::Vec4f(0,0,0,0))
, mTexture(new osg::Texture2D(imageManager->getWarningImage()))
, mForceShaders(forceShaders)
{ }
{
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
}
void AtmosphereNightUpdater::setFade(float fade)
{

@ -25,6 +25,8 @@ namespace MWRender
image->setColor(osg::Vec4(1,1,1,1), 0, 0);
osg::ref_ptr<osg::Texture2D> dummyTexture = new osg::Texture2D(image);
dummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
dummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
constexpr osg::StateAttribute::OverrideValue modeOff = osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE;
constexpr osg::StateAttribute::OverrideValue modeOn = osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE;

@ -82,8 +82,7 @@ namespace fx
{"s3tc_dxt1a" , osg::Texture::USE_S3TC_DXT1a_COMPRESSION}
}};
constexpr std::array<std::pair<std::string_view, osg::Texture::WrapMode>, 6> WrapMode = {{
{"clamp" , osg::Texture::CLAMP},
constexpr std::array<std::pair<std::string_view, osg::Texture::WrapMode>, 4> WrapMode = {{
{"clamp_to_edge" , osg::Texture::CLAMP_TO_EDGE},
{"clamp_to_border", osg::Texture::CLAMP_TO_BORDER},
{"repeat" , osg::Texture::REPEAT},

@ -273,6 +273,8 @@ namespace fx
rt.mTarget->setSourceFormat(GL_RGB);
rt.mTarget->setInternalFormat(GL_RGB);
rt.mTarget->setSourceType(GL_UNSIGNED_BYTE);
rt.mTarget->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
rt.mTarget->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
while (!isNext<Lexer::Close_bracket>() && !isNext<Lexer::Eof>())
{

@ -187,6 +187,8 @@ public:
mDummyTexture = new osg::Texture2D;
mDummyTexture->setInternalFormat(GL_RGB);
mDummyTexture->setTextureSize(1,1);
mDummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mDummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
// need to flip tex coords since MyGUI uses DirectX convention of top left image origin
osg::Matrix flipMat;

@ -86,6 +86,8 @@ namespace SceneUtil
fakeShadowMapImage->allocateImage(1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
*(float*)fakeShadowMapImage->data() = std::numeric_limits<float>::infinity();
osg::ref_ptr<osg::Texture> fakeShadowMapTexture = new osg::Texture2D(fakeShadowMapImage);
fakeShadowMapTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
fakeShadowMapTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
fakeShadowMapTexture->setShadowComparison(true);
fakeShadowMapTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS);
for (int i = baseShadowTextureUnit; i < baseShadowTextureUnit + numberOfShadowMapsPerLight; ++i)

@ -235,6 +235,8 @@ namespace Stereo
}
osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D;
texture2d->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
texture2d->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
texture2d->setSubloadCallback(new Texture2DViewSubloadCallback(textureArray, layer));
texture2d->setTextureSize(textureArray->getTextureWidth(), textureArray->getTextureHeight());
texture2d->setBorderColor(textureArray->getBorderColor());
@ -414,12 +416,16 @@ namespace Stereo
auto tex = new osg::Texture2DMultisample();
tex->setTextureSize(width, height);
tex->setNumSamples(samples);
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
return tex;
}
else
{
auto tex = new osg::Texture2D();
tex->setTextureSize(width, height);
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
return tex;
}
}

@ -853,8 +853,6 @@ Types
+------------------+---------------------+
| .omwfx | OpenGL |
+==================+=====================+
| clamp | GL_CLAMP |
+------------------+---------------------+
| clamp_to_edge | GL_CLAMP_TO_EDGE |
+------------------+---------------------+
| clamp_to_border | GL_CLAMP_TO_BORDER |

Loading…
Cancel
Save