From a33ae35e9487913454e87797425307375dc8aefb Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 13 Apr 2012 13:28:31 +0200 Subject: [PATCH 1/4] some fixes --- apps/openmw/mwrender/renderingmanager.cpp | 3 ++- apps/openmw/mwrender/terrainmaterial.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ee60407b24..984b7ddc91 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -56,6 +56,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities(); if (caps->getNumMultiRenderTargets() < 2) Settings::Manager::setBool("shader", "Water", false); + if (!caps->isShaderProfileSupported("fp40") && !caps->isShaderProfileSupported("ps_4_0")) + Settings::Manager::setBool("enabled", "Shadows", false); // note that the order is important here if (useMRT()) @@ -108,7 +110,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const RenderingManager::~RenderingManager () { - //TODO: destroy mSun? delete mPlayer; delete mSkyManager; delete mDebugging; diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 57bea5388e..c69ed3a613 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -1339,7 +1339,13 @@ namespace Ogre // diffuse lighting for (int i=0; igetNumberOfLightsSupported(); ++i) + { + // shadows only for first light (directional) + if (i==0) outStream << " outputCol.rgb += litRes"<isLayerSpecularMappingEnabled()) From e04d127f30817dfbe02eebe9cc65f358515cfe59 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 Apr 2012 15:10:26 +0200 Subject: [PATCH 2/4] terrain shader fixes --- apps/openmw/mwrender/terrainmaterial.cpp | 68 +++++++++--------------- 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 331bb47e32..7ed2a703b3 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -540,7 +540,6 @@ namespace Ogre params->setNamedAutoConstant("viewProjMatrix", GpuProgramParameters::ACT_VIEWPROJ_MATRIX); params->setNamedAutoConstant("lodMorph", GpuProgramParameters::ACT_CUSTOM, Terrain::LOD_MORPH_CUSTOM_PARAM); - params->setNamedAutoConstant("fogParams", GpuProgramParameters::ACT_FOG_PARAMS); if (prof->isShadowingEnabled(tt, terrain)) { @@ -576,7 +575,7 @@ namespace Ogre { params->setNamedAutoConstant("lightPosObjSpace"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_POSITION_OBJECT_SPACE, i); params->setNamedAutoConstant("lightDiffuseColour"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR, i); - if (prof->getNumberOfLightsSupported() > 1) + if (i > 0) params->setNamedAutoConstant("lightAttenuation"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_ATTENUATION, i); //params->setNamedAutoConstant("lightSpecularColour"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR, i); } @@ -586,6 +585,7 @@ namespace Ogre params->setNamedAutoConstant("eyePosObjSpace", GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE); params->setNamedAutoConstant("fogColour", GpuProgramParameters::ACT_FOG_COLOUR); + params->setNamedAutoConstant("fogParams", GpuProgramParameters::ACT_FOG_PARAMS); if (prof->isShadowingEnabled(tt, terrain)) { @@ -813,11 +813,11 @@ namespace Ogre outStream << "out float4 oPos : POSITION,\n" - "out float4 oPosObj : COLOR \n"; + "out float4 oPosObj : TEXCOORD0 \n"; - uint texCoordSet = 0; + uint texCoordSet = 1; outStream << - ", out float4 oUVMisc : TEXCOORD" << texCoordSet++ <<" // xy = uv, z = camDepth\n"; + ", out float4 oUVMisc : COLOR0 // xy = uv, z = camDepth\n"; // layer UV's premultiplied, packed as xy/zw uint numUVSets = numLayers / 2; @@ -837,14 +837,6 @@ namespace Ogre outStream << ", out float2 lodInfo : TEXCOORD" << texCoordSet++ << "\n"; } - bool fog = terrain->getSceneManager()->getFogMode() != FOG_NONE && tt != RENDER_COMPOSITE_MAP; - if (fog) - { - outStream << - ", uniform float4 fogParams\n"; - //", out float fogVal : COLOR\n"; - } - if (prof->isShadowingEnabled(tt, terrain)) { texCoordSet = generateVpDynamicShadowsParams(texCoordSet, prof, terrain, tt, outStream); @@ -940,11 +932,11 @@ namespace Ogre outStream << "void main_fp(\n" - "float4 position : COLOR,\n"; + "float4 position : TEXCOORD0,\n"; - uint texCoordSet = 0; + uint texCoordSet = 1; outStream << - "float4 uvMisc : TEXCOORD" << texCoordSet++ << ",\n"; + "float4 uvMisc : COLOR0,\n"; // UV's premultiplied, packed as xy/zw uint maxLayers = prof->getMaxLayers(terrain); @@ -971,8 +963,8 @@ namespace Ogre if (fog) { outStream << + "uniform float4 fogParams, \n" "uniform float3 fogColour, \n"; - //"float fogVal : COLOR,\n"; } uint currentSamplerIdx = 0; @@ -991,7 +983,7 @@ namespace Ogre //"uniform float3 lightSpecularColour"<getNumberOfLightsSupported() > 1) + if (i > 0) outStream << "uniform float4 lightAttenuation"<getNumberOfLightsSupported() > 1) + if (i > 0) outStream << // pre-multiply light color with attenuation factor "d = length( lightDir"<getSceneManager()->getFogMode() != FOG_NONE && tt != RENDER_COMPOSITE_MAP; - if (fog) - { - if (terrain->getSceneManager()->getFogMode() == FOG_LINEAR) - { - outStream << - " float fogVal = saturate((oPos.z - fogParams.y) * fogParams.w);\n"; - } - else - { - outStream << - " float fogVal = saturate(1 / (exp(oPos.z * fogParams.x)));\n"; - } - outStream << - " oPosObj.w = fogVal; \n"; - } + " oPosObj.w = oPos.z;\n"; if (prof->isShadowingEnabled(tt, terrain)) generateVpDynamicShadows(prof, terrain, tt, outStream); @@ -1369,6 +1343,16 @@ namespace Ogre bool fog = terrain->getSceneManager()->getFogMode() != FOG_NONE && tt != RENDER_COMPOSITE_MAP; if (fog) { + if (terrain->getSceneManager()->getFogMode() == FOG_LINEAR) + { + outStream << + " float fogVal = saturate((position.w - fogParams.y) * fogParams.w);\n"; + } + else + { + outStream << + " float fogVal = saturate(1 / (exp(position.w * fogParams.x)));\n"; + } outStream << " outputCol.rgb = lerp(outputCol.rgb, fogColour, fogVal);\n"; } @@ -1376,7 +1360,7 @@ namespace Ogre outStream << " oColor = outputCol;\n"; if (MWRender::RenderingManager::useMRT()) outStream << - " oColor1 = float4(uvMisc.z / far, 0, 0, 1); \n"; + " oColor1 = float4(position.w / far, 0, 0, 1); \n"; outStream << "}\n"; @@ -1585,7 +1569,7 @@ namespace Ogre { uint numTextures = prof->getReceiveDynamicShadowsPSSM()->getSplitCount(); outStream << - " float camDepth = uvMisc.z;\n"; + " float camDepth = position.w;\n"; if (prof->getReceiveDynamicShadowsDepth()) { @@ -1629,8 +1613,8 @@ namespace Ogre outStream << " float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y; \n" - " float fade = 1-((uvMisc.z - shadowFar_fadeStart.y) / fadeRange); \n" - " rtshadow = (uvMisc.z > shadowFar_fadeStart.x) ? 1 : ((uvMisc.z > shadowFar_fadeStart.y) ? 1-((1-rtshadow)*fade) : rtshadow); \n" + " float fade = 1-((position.w - shadowFar_fadeStart.y) / fadeRange); \n" + " rtshadow = (position.w > shadowFar_fadeStart.x) ? 1 : ((position.w > shadowFar_fadeStart.y) ? 1-((1-rtshadow)*fade) : rtshadow); \n" " rtshadow = (1-(1-rtshadow)*0.6); \n" // make the shadow a little less intensive " shadow = min(shadow, rtshadow);\n"; From fa5a1432c9817238245be20ec3ee17ec3107c3f9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 Apr 2012 15:58:58 +0200 Subject: [PATCH 3/4] map lighting tweak, default settings tweak --- apps/openmw/mwrender/renderingmanager.cpp | 2 ++ files/settings-default.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 984b7ddc91..c1462807fc 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -482,11 +482,13 @@ void RenderingManager::preCellChange(MWWorld::Ptr::CellStore* cell) void RenderingManager::disableLights() { mObjects.disableLights(); + sunDisable(); } void RenderingManager::enableLights() { mObjects.enableLights(); + sunEnable(); } const bool RenderingManager::useMRT() diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 4d2d46fca1..553a82e497 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -93,7 +93,7 @@ rtt size = 512 reflect terrain = true reflect statics = false reflect small statics = false -reflect actors = true +reflect actors = false reflect misc = false # Enable underwater effect. It is not resource intensive, so only disable it if you have problems. From 4b0099fb5b1c90214a14e0d387d52a2ed2668c0f Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 Apr 2012 16:10:47 +0200 Subject: [PATCH 4/4] npc visibility flags fix --- apps/openmw/mwrender/npcanimation.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 9de5705e3f..a231e8fe77 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -240,6 +240,7 @@ Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::stri NIFLoader::load(mesh); Entity* ent = mRend.getScene()->createEntity(mesh); + ent->setVisibilityFlags(RV_Actors); base->attachObjectToBone(bonename, ent); return ent; @@ -249,9 +250,7 @@ void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suf NIFLoader::load(meshNumbered); Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered); - - - + ent->setVisibilityFlags(RV_Actors); insert->attachObject(ent); entityparts.push_back(ent);