Merge branch 'master' into 'master'
Some checks failed
Build and test / Ubuntu (push) Has been cancelled
Build and test / MacOS (push) Has been cancelled
Build and test / Read .env file and expose it as output (push) Has been cancelled
Build and test / Windows (2019) (push) Has been cancelled
Build and test / Windows (2022) (push) Has been cancelled

GL4ES check by extension

See merge request OpenMW/openmw!4335
This commit is contained in:
Jared Davenport 2025-04-24 16:06:24 +00:00
commit ac0f851a35
7 changed files with 51 additions and 10 deletions

View file

@ -27,6 +27,7 @@
#include <components/misc/strings/format.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
@ -635,6 +636,10 @@ namespace MWGui
void SettingsWindow::onMaxLightsChanged(MyGUI::ComboBox* _sender, size_t pos)
{
if (osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
Settings::shaders().mMaxLights.set(8 * (pos + 1));
apply();
configureWidgets(mMainWidget, false);

View file

@ -19,6 +19,7 @@
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/keyframe.hpp>
#include <components/sceneutil/lightcommon.hpp>
#include <components/sceneutil/visitor.hpp>
@ -344,7 +345,8 @@ namespace MWRender
auto primaryFBO = postProcessor->getPrimaryFbo(frameId);
primaryFBO->apply(*state);
postProcessor->getFbo(PostProcessor::FBO_OpaqueDepth, frameId)->apply(*state);
if (!osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
postProcessor->getFbo(PostProcessor::FBO_OpaqueDepth, frameId)->apply(*state);
// depth accumulation pass
osg::ref_ptr<osg::StateSet> restore = bin->getStateSet();

View file

@ -17,6 +17,7 @@
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/color.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/nodecallback.hpp>
#include <components/settings/values.hpp>
#include <components/shader/shadermanager.hpp>
@ -301,7 +302,12 @@ namespace MWRender
mCanvases[frameId]->setCalculateAvgLum(mHDR);
mCanvases[frameId]->setTextureScene(getTexture(Tex_Scene, frameId));
mCanvases[frameId]->setTextureDepth(getTexture(Tex_OpaqueDepth, frameId));
if (osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
mCanvases[frameId]->setTextureDepth(getTexture(Tex_Depth, frameId));
else
mCanvases[frameId]->setTextureDepth(getTexture(Tex_OpaqueDepth, frameId));
mCanvases[frameId]->setTextureDistortion(getTexture(Tex_Distortion, frameId));
mTransparentDepthPostPass->mFbo[frameId] = mFbos[frameId][FBO_Primary];

View file

@ -35,6 +35,7 @@
#include <components/sceneutil/cullsafeboundsvisitor.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/lightmanager.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/sceneutil/rtt.hpp>
@ -509,9 +510,19 @@ namespace MWRender
rootNode->addCullCallback(mPerViewUniformStateUpdater);
mPostProcessor = new PostProcessor(*this, viewer, mRootNode, resourceSystem->getVFS());
resourceSystem->getSceneManager()->setOpaqueDepthTex(
mPostProcessor->getTexture(PostProcessor::Tex_OpaqueDepth, 0),
mPostProcessor->getTexture(PostProcessor::Tex_OpaqueDepth, 1));
mPostProcessor->getTexture(
osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint")
? PostProcessor::Tex_Depth
: PostProcessor::Tex_OpaqueDepth,
0),
mPostProcessor->getTexture(
osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint")
? PostProcessor::Tex_Depth
: PostProcessor::Tex_OpaqueDepth,
1));
resourceSystem->getSceneManager()->setSoftParticles(Settings::shaders().mSoftParticles);
resourceSystem->getSceneManager()->setSupportsNormalsRT(mPostProcessor->getSupportsNormalsRT());
resourceSystem->getSceneManager()->setWeatherParticleOcclusion(Settings::shaders().mWeatherParticleOcclusion);
@ -1562,7 +1573,8 @@ namespace MWRender
lightManager->processChangedSettings(Settings::shaders().mLightBoundsMultiplier,
Settings::shaders().mMaximumLightDistance, Settings::shaders().mLightFadeStart);
if (it->second == "max lights" && !lightManager->usingFFP())
if (it->second == "max lights" && !lightManager->usingFFP()
&& !osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
{
mViewer->stopThreading();

View file

@ -9,6 +9,7 @@
#include <osgUtil/RenderStage>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/shader/shadermanager.hpp>
#include <components/stereo/multiview.hpp>
#include <components/stereo/stereomanager.hpp>
@ -92,8 +93,12 @@ namespace MWRender
else
{
opaqueFbo->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER);
ext->glBlitFramebuffer(0, 0, tex->getTextureWidth(), tex->getTextureHeight(), 0, 0, tex->getTextureWidth(),
tex->getTextureHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
if (!osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
ext->glBlitFramebuffer(0, 0, tex->getTextureWidth(), tex->getTextureHeight(), 0, 0,
tex->getTextureWidth(), tex->getTextureHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
else
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
msaaFbo ? msaaFbo->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER)
@ -105,7 +110,8 @@ namespace MWRender
if (!mPostPass)
return;
opaqueFbo->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER);
if (!osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
opaqueFbo->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER);
// draw transparent post-pass to populate a postprocess friendly depth texture with alpha-clipped geometry

View file

@ -22,6 +22,7 @@
#include <components/misc/osguservalues.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/resource/imagemanager.hpp>
#include <components/sceneutil/depth.hpp>
#include <components/sceneutil/glextensions.hpp>
#include <components/sceneutil/morphgeometry.hpp>
#include <components/sceneutil/riggeometry.hpp>
@ -29,6 +30,7 @@
#include <components/sceneutil/texturetype.hpp>
#include <components/sceneutil/util.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include <components/stereo/stereomanager.hpp>
#include <components/vfs/manager.hpp>
@ -755,6 +757,14 @@ namespace Shader
updateRemovedState(*writableUserData, removedState);
}
if (reqs.mAlphaBlend && Settings::postProcessing().mTransparentPostpass && Settings::postProcessing().mEnabled
&& osg::isGLExtensionSupported(SceneUtil::getGLExtensions().contextID, "GL_GL4ES_hint"))
{
osg::ref_ptr<osg::Depth> depth = new SceneUtil::AutoDepth;
depth->setWriteMask(false);
writableStateSet->setAttributeAndModes(depth, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
defineMap["softParticles"] = reqs.mSoftParticles ? "1" : "0";
Stereo::shaderStereoDefines(defineMap);

View file

@ -16,7 +16,7 @@ vec4 applyFogAtDist(vec4 color, float euclideanDist, float linearDist, float far
#else
float fogValue = clamp((dist - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
#endif
#ifdef ADDITIVE_BLENDING
#if defined(ADDITIVE_BLENDING)
color.xyz *= 1.0 - fogValue;
#else
color.xyz = mix(color.xyz, gl_Fog.color.xyz, fogValue);
@ -25,7 +25,7 @@ vec4 applyFogAtDist(vec4 color, float euclideanDist, float linearDist, float far
#if @skyBlending
float fadeValue = clamp((far - dist) / (far - skyBlendingStart), 0.0, 1.0);
fadeValue *= fadeValue;
#ifdef ADDITIVE_BLENDING
#if defined(ADDITIVE_BLENDING)
color.xyz *= fadeValue;
#else
color.xyz = mix(sampleSkyColor(gl_FragCoord.xy / screenRes), color.xyz, fadeValue);