Be more explicit about use of CLAMP_TO_EDGE instead of defaulting to GL CLAMP

revert-6246b479
Bret Curtis 2 years ago
parent 44c3c40058
commit ff6944701f

@ -295,6 +295,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);
}

@ -268,6 +268,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

@ -35,6 +35,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);
@ -45,11 +47,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,

@ -164,6 +164,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);
}
}
@ -598,13 +600,18 @@ namespace MWRender
// user-defined samplers
for (const osg::Texture* texture : technique->getTextures())
{
osg::ref_ptr<osg::Texture> sample;
if (const auto* tex1D = dynamic_cast<const osg::Texture1D*>(texture))
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture1D(*tex1D));
sample = new osg::Texture1D(*tex1D);
else if (const auto* tex2D = dynamic_cast<const osg::Texture2D*>(texture))
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture2D(*tex2D));
sample = new osg::Texture2D(*tex2D);
else if (const auto* tex3D = dynamic_cast<const osg::Texture3D*>(texture))
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture3D(*tex3D));
sample= new osg::Texture3D(*tex3D);
sample->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
sample->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
node.mRootStateSet->setTextureAttribute(texUnit, sample);
node.mRootStateSet->addUniform(new osg::Uniform(texture->getName().c_str(), texUnit++));
}
@ -637,6 +644,8 @@ namespace MWRender
const auto [w, h] = rt.mSize.get(renderWidth(), renderHeight());
subPass.mRenderTexture = new osg::Texture2D(*rt.mTarget);
subPass.mRenderTexture ->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
subPass.mRenderTexture ->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
renderTargetCache[rt.mTarget] = subPass.mRenderTexture;
subPass.mRenderTexture->setTextureSize(w, h);
subPass.mRenderTexture->setName(std::string(pass->getTarget()));

@ -48,6 +48,8 @@ namespace
: mDummyTexture(new osg::Texture2D)
{
mDummyTexture->setInternalFormat(GL_RGB);
mDummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mDummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mDummyTexture->setTextureSize(1, 1);
Shader::ShaderManager& shaderMgr

@ -315,6 +315,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,6 +482,8 @@ namespace MWRender
, 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)

@ -26,6 +26,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;

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

@ -62,7 +62,11 @@ namespace fx
if (other.mRenderTarget)
mRenderTarget = new osg::FrameBufferObject(*other.mRenderTarget, copyOp);
if (other.mRenderTexture)
{
mRenderTexture = new osg::Texture2D(*other.mRenderTexture, copyOp);
mRenderTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mRenderTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
}
}
};

@ -184,6 +184,8 @@ namespace osgMyGUI
mStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
mDummyTexture = new osg::Texture2D;
mDummyTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
mDummyTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mDummyTexture->setInternalFormat(GL_RGB);
mDummyTexture->setTextureSize(1, 1);

@ -93,6 +93,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)

@ -243,6 +243,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());
@ -429,12 +431,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;
}
}

Loading…
Cancel
Save