From eb67afe5528aae8fdb288e20db5f13d2959625bd Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 4 Apr 2012 20:18:08 +0200 Subject: [PATCH] added MRT output to terrain material --- apps/openmw/mwrender/terrainmaterial.cpp | 42 ++++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 922ea2280..867ec8e1f 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -557,7 +557,10 @@ namespace Ogre params->setNamedAutoConstant("lightAttenuation"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_ATTENUATION, i); //params->setNamedAutoConstant("lightSpecularColour"+StringConverter::toString(i), GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR, i); } - + + if (Settings::Manager::getBool("multiple render targets", "Render")) + params->setNamedAutoConstant("far", GpuProgramParameters::ACT_FAR_CLIP_DISTANCE); + params->setNamedAutoConstant("eyePosObjSpace", GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE); params->setNamedAutoConstant("fogColour", GpuProgramParameters::ACT_FOG_COLOUR); @@ -753,12 +756,7 @@ namespace Ogre ret->unload(); } - if(prof->isLayerNormalMappingEnabled() || prof->isLayerParallaxMappingEnabled()) - ret->setParameter("profiles", "ps_3_0 ps_2_x fp40 arbfp1"); - //else - //ret->setParameter("profiles", "ps_3_0 ps_2_0 fp30 arbfp1"); - else // fp30 doesn't work (black terrain) - ret->setParameter("profiles", "ps_3_0 ps_2_x fp40 arbfp1"); + ret->setParameter("profiles", "ps_3_0 ps_2_x fp40 arbfp1"); ret->setParameter("entry_point", "main_fp"); return ret; @@ -917,7 +915,7 @@ namespace Ogre outStream << - "float4 main_fp(\n" + "void main_fp(\n" "float4 position : TEXCOORD0,\n"; uint texCoordSet = 1; @@ -1034,8 +1032,15 @@ namespace Ogre __FUNCTION__); } + if (Settings::Manager::getBool("multiple render targets", "Render")) outStream << + " , out float4 oColor : COLOR \n" + " , out float4 oColor1 : COLOR1 \n" + " , uniform float far \n"; + else outStream << + " , out float4 oColor : COLOR \n"; + outStream << - ") : COLOR\n" + ")\n" "{\n" " float4 outputCol;\n" " float shadow = 1.0;\n" @@ -1241,6 +1246,10 @@ namespace Ogre " oPos = mul(viewProjMatrix, worldPos);\n" " oUVMisc.xy = uv.xy;\n"; + outStream << + " // pass cam depth\n" + " oUVMisc.z = oPos.z;\n"; + bool fog = terrain->getSceneManager()->getFogMode() != FOG_NONE && tt != RENDER_COMPOSITE_MAP; if (fog) { @@ -1337,7 +1346,12 @@ namespace Ogre } // Final return - outStream << " return outputCol;\n" + outStream << " oColor = outputCol;\n"; + + if (Settings::Manager::getBool("multiple render targets", "Render")) outStream << + " oColor1 = float4(uvMisc.z / far, 0, 0, 1); \n"; + + outStream << "}\n"; } @@ -1511,14 +1525,6 @@ namespace Ogre } } - - if (prof->getReceiveDynamicShadowsPSSM()) - { - outStream << - " // pass cam depth\n" - " oUVMisc.z = oPos.z;\n"; - } - } //--------------------------------------------------------------------- void TerrainMaterialGeneratorB::SM2Profile::ShaderHelperCg::generateFpDynamicShadowsParams(