mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 03:59:56 +00:00
Be more explicit about use of CLAMP_TO_EDGE instead of defaulting to GL CLAMP
This commit is contained in:
parent
44c3c40058
commit
ff6944701f
13 changed files with 47 additions and 7 deletions
|
@ -295,6 +295,8 @@ namespace MWGui
|
||||||
if (!mTexture)
|
if (!mTexture)
|
||||||
{
|
{
|
||||||
mTexture = new osg::Texture2D;
|
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->setInternalFormat(GL_RGB);
|
||||||
mTexture->setResizeNonPowerOfTwoHint(false);
|
mTexture->setResizeNonPowerOfTwoHint(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,8 @@ namespace MWRender
|
||||||
noBlendAlphaEnv->setCombine_RGB(osg::TexEnvCombine::REPLACE);
|
noBlendAlphaEnv->setCombine_RGB(osg::TexEnvCombine::REPLACE);
|
||||||
noBlendAlphaEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
|
noBlendAlphaEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
|
||||||
osg::ref_ptr<osg::Texture2D> dummyTexture = new osg::Texture2D();
|
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->setInternalFormat(GL_DEPTH_COMPONENT);
|
||||||
dummyTexture->setTextureSize(1, 1);
|
dummyTexture->setTextureSize(1, 1);
|
||||||
// This might clash with a shadow map, so make sure it doesn't cast shadows
|
// 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->setInternalFormat(GL_R16F);
|
||||||
buffer.mipmappedSceneLuminanceTex->setSourceFormat(GL_RED);
|
buffer.mipmappedSceneLuminanceTex->setSourceFormat(GL_RED);
|
||||||
buffer.mipmappedSceneLuminanceTex->setSourceType(GL_FLOAT);
|
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(
|
buffer.mipmappedSceneLuminanceTex->setFilter(
|
||||||
osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR_MIPMAP_NEAREST);
|
osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR_MIPMAP_NEAREST);
|
||||||
buffer.mipmappedSceneLuminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
|
buffer.mipmappedSceneLuminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
|
||||||
|
@ -45,11 +47,15 @@ namespace MWRender
|
||||||
buffer.luminanceTex->setInternalFormat(GL_R16F);
|
buffer.luminanceTex->setInternalFormat(GL_R16F);
|
||||||
buffer.luminanceTex->setSourceFormat(GL_RED);
|
buffer.luminanceTex->setSourceFormat(GL_RED);
|
||||||
buffer.luminanceTex->setSourceType(GL_FLOAT);
|
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::MIN_FILTER, osg::Texture2D::NEAREST);
|
||||||
buffer.luminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
|
buffer.luminanceTex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
|
||||||
buffer.luminanceTex->setTextureSize(1, 1);
|
buffer.luminanceTex->setTextureSize(1, 1);
|
||||||
|
|
||||||
buffer.luminanceProxyTex = new osg::Texture2D(*buffer.luminanceTex);
|
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 = new osg::FrameBufferObject;
|
||||||
buffer.resolveFbo->setAttachment(osg::FrameBufferObject::BufferComponent::COLOR_BUFFER0,
|
buffer.resolveFbo->setAttachment(osg::FrameBufferObject::BufferComponent::COLOR_BUFFER0,
|
||||||
|
|
|
@ -164,6 +164,8 @@ namespace MWRender
|
||||||
mTextures[i][Tex_OpaqueDepth] = new osg::Texture2DArray;
|
mTextures[i][Tex_OpaqueDepth] = new osg::Texture2DArray;
|
||||||
else
|
else
|
||||||
mTextures[i][Tex_OpaqueDepth] = new osg::Texture2D;
|
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
|
// user-defined samplers
|
||||||
for (const osg::Texture* texture : technique->getTextures())
|
for (const osg::Texture* texture : technique->getTextures())
|
||||||
{
|
{
|
||||||
if (const auto* tex1D = dynamic_cast<const osg::Texture1D*>(texture))
|
osg::ref_ptr<osg::Texture> sample;
|
||||||
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture1D(*tex1D));
|
|
||||||
else if (const auto* tex2D = dynamic_cast<const osg::Texture2D*>(texture))
|
|
||||||
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture2D(*tex2D));
|
|
||||||
else if (const auto* tex3D = dynamic_cast<const osg::Texture3D*>(texture))
|
|
||||||
node.mRootStateSet->setTextureAttribute(texUnit, new osg::Texture3D(*tex3D));
|
|
||||||
|
|
||||||
|
if (const auto* tex1D = dynamic_cast<const osg::Texture1D*>(texture))
|
||||||
|
sample = new osg::Texture1D(*tex1D);
|
||||||
|
else if (const auto* tex2D = dynamic_cast<const osg::Texture2D*>(texture))
|
||||||
|
sample = new osg::Texture2D(*tex2D);
|
||||||
|
else if (const auto* tex3D = dynamic_cast<const osg::Texture3D*>(texture))
|
||||||
|
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++));
|
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());
|
const auto [w, h] = rt.mSize.get(renderWidth(), renderHeight());
|
||||||
|
|
||||||
subPass.mRenderTexture = new osg::Texture2D(*rt.mTarget);
|
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;
|
renderTargetCache[rt.mTarget] = subPass.mRenderTexture;
|
||||||
subPass.mRenderTexture->setTextureSize(w, h);
|
subPass.mRenderTexture->setTextureSize(w, h);
|
||||||
subPass.mRenderTexture->setName(std::string(pass->getTarget()));
|
subPass.mRenderTexture->setName(std::string(pass->getTarget()));
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace
|
||||||
: mDummyTexture(new osg::Texture2D)
|
: mDummyTexture(new osg::Texture2D)
|
||||||
{
|
{
|
||||||
mDummyTexture->setInternalFormat(GL_RGB);
|
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);
|
mDummyTexture->setTextureSize(1, 1);
|
||||||
|
|
||||||
Shader::ShaderManager& shaderMgr
|
Shader::ShaderManager& shaderMgr
|
||||||
|
|
|
@ -315,6 +315,8 @@ namespace MWRender
|
||||||
texture->setResizeNonPowerOfTwoHint(false);
|
texture->setResizeNonPowerOfTwoHint(false);
|
||||||
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||||
texture->setFilter(osg::Texture::MAG_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);
|
camera->attach(osg::Camera::COLOR_BUFFER, texture);
|
||||||
|
|
||||||
image->setDataType(GL_UNSIGNED_BYTE);
|
image->setDataType(GL_UNSIGNED_BYTE);
|
||||||
|
|
|
@ -482,6 +482,8 @@ namespace MWRender
|
||||||
, mTexture(new osg::Texture2D(imageManager->getWarningImage()))
|
, mTexture(new osg::Texture2D(imageManager->getWarningImage()))
|
||||||
, mForceShaders(forceShaders)
|
, 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)
|
void AtmosphereNightUpdater::setFade(float fade)
|
||||||
|
|
|
@ -26,6 +26,8 @@ namespace MWRender
|
||||||
image->setColor(osg::Vec4(1, 1, 1, 1), 0, 0);
|
image->setColor(osg::Vec4(1, 1, 1, 1), 0, 0);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> dummyTexture = new osg::Texture2D(image);
|
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 modeOff = osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE;
|
||||||
constexpr osg::StateAttribute::OverrideValue modeOn = osg::StateAttribute::ON | 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 = { {
|
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_edge", osg::Texture::CLAMP_TO_EDGE },
|
||||||
{ "clamp_to_border", osg::Texture::CLAMP_TO_BORDER },
|
{ "clamp_to_border", osg::Texture::CLAMP_TO_BORDER },
|
||||||
{ "repeat", osg::Texture::REPEAT },
|
{ "repeat", osg::Texture::REPEAT },
|
||||||
|
|
|
@ -62,7 +62,11 @@ namespace fx
|
||||||
if (other.mRenderTarget)
|
if (other.mRenderTarget)
|
||||||
mRenderTarget = new osg::FrameBufferObject(*other.mRenderTarget, copyOp);
|
mRenderTarget = new osg::FrameBufferObject(*other.mRenderTarget, copyOp);
|
||||||
if (other.mRenderTexture)
|
if (other.mRenderTexture)
|
||||||
|
{
|
||||||
mRenderTexture = new osg::Texture2D(*other.mRenderTexture, copyOp);
|
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);
|
mStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||||
|
|
||||||
mDummyTexture = new osg::Texture2D;
|
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->setInternalFormat(GL_RGB);
|
||||||
mDummyTexture->setTextureSize(1, 1);
|
mDummyTexture->setTextureSize(1, 1);
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ namespace SceneUtil
|
||||||
fakeShadowMapImage->allocateImage(1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
|
fakeShadowMapImage->allocateImage(1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT);
|
||||||
*(float*)fakeShadowMapImage->data() = std::numeric_limits<float>::infinity();
|
*(float*)fakeShadowMapImage->data() = std::numeric_limits<float>::infinity();
|
||||||
osg::ref_ptr<osg::Texture> fakeShadowMapTexture = new osg::Texture2D(fakeShadowMapImage);
|
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->setShadowComparison(true);
|
||||||
fakeShadowMapTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS);
|
fakeShadowMapTexture->setShadowCompareFunc(osg::Texture::ShadowCompareFunc::ALWAYS);
|
||||||
for (int i = baseShadowTextureUnit; i < baseShadowTextureUnit + numberOfShadowMapsPerLight; ++i)
|
for (int i = baseShadowTextureUnit; i < baseShadowTextureUnit + numberOfShadowMapsPerLight; ++i)
|
||||||
|
|
|
@ -243,6 +243,8 @@ namespace Stereo
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D;
|
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->setSubloadCallback(new Texture2DViewSubloadCallback(textureArray, layer));
|
||||||
texture2d->setTextureSize(textureArray->getTextureWidth(), textureArray->getTextureHeight());
|
texture2d->setTextureSize(textureArray->getTextureWidth(), textureArray->getTextureHeight());
|
||||||
texture2d->setBorderColor(textureArray->getBorderColor());
|
texture2d->setBorderColor(textureArray->getBorderColor());
|
||||||
|
@ -429,12 +431,16 @@ namespace Stereo
|
||||||
auto tex = new osg::Texture2DMultisample();
|
auto tex = new osg::Texture2DMultisample();
|
||||||
tex->setTextureSize(width, height);
|
tex->setTextureSize(width, height);
|
||||||
tex->setNumSamples(samples);
|
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;
|
return tex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tex = new osg::Texture2D();
|
auto tex = new osg::Texture2D();
|
||||||
tex->setTextureSize(width, height);
|
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;
|
return tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue