mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
sky
This commit is contained in:
parent
b2313be6d7
commit
ad7383be43
13 changed files with 145 additions and 280 deletions
|
@ -63,6 +63,16 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
platform->setCacheFolder ("./");
|
platform->setCacheFolder ("./");
|
||||||
mFactory = new sh::Factory(platform);
|
mFactory = new sh::Factory(platform);
|
||||||
|
|
||||||
|
sh::Language lang;
|
||||||
|
std::string l = Settings::Manager::getString("shader mode", "General");
|
||||||
|
if (l == "glsl")
|
||||||
|
lang = sh::Language_GLSL;
|
||||||
|
else if (l == "hlsl")
|
||||||
|
lang = sh::Language_HLSL;
|
||||||
|
else
|
||||||
|
lang = sh::Language_CG;
|
||||||
|
mFactory->setCurrentLanguage (lang);
|
||||||
|
|
||||||
//The fog type must be set before any terrain objects are created as if the
|
//The fog type must be set before any terrain objects are created as if the
|
||||||
//fog type is set to FOG_NONE then the initially created terrain won't have any fog
|
//fog type is set to FOG_NONE then the initially created terrain won't have any fog
|
||||||
configureFog(1, ColourValue(1,1,1));
|
configureFog(1, ColourValue(1,1,1));
|
||||||
|
|
|
@ -91,16 +91,16 @@ void Shadows::recreate()
|
||||||
|
|
||||||
// Populate from split point 1, not 0, since split 0 isn't useful (usually 0)
|
// Populate from split point 1, not 0, since split 0 isn't useful (usually 0)
|
||||||
const PSSMShadowCameraSetup::SplitPointList& splitPointList = getPSSMSetup()->getSplitPoints();
|
const PSSMShadowCameraSetup::SplitPointList& splitPointList = getPSSMSetup()->getSplitPoints();
|
||||||
sh::Vector4* splitPoints = new sh::Vector4(splitPointList[1], splitPointList[2], splitPointList[3], 1.0);
|
sh::Vector3* splitPoints = new sh::Vector3(splitPointList[1], splitPointList[2], splitPointList[3]);
|
||||||
|
|
||||||
sh::Factory::getInstance ().setSharedParameter ("pssmSplitPoints", sh::makeProperty<sh::Vector4>(splitPoints));
|
sh::Factory::getInstance ().setSharedParameter ("pssmSplitPoints", sh::makeProperty<sh::Vector3>(splitPoints));
|
||||||
|
|
||||||
shadowCameraSetup = ShadowCameraSetupPtr(mPSSMSetup);
|
shadowCameraSetup = ShadowCameraSetupPtr(mPSSMSetup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LiSPSMShadowCameraSetup* lispsmSetup = new LiSPSMShadowCameraSetup();
|
LiSPSMShadowCameraSetup* lispsmSetup = new LiSPSMShadowCameraSetup();
|
||||||
lispsmSetup->setOptimalAdjustFactor(2);
|
lispsmSetup->setOptimalAdjustFactor(64);
|
||||||
//lispsmSetup->setCameraLightDirectionThreshold(Degree(0));
|
//lispsmSetup->setCameraLightDirectionThreshold(Degree(0));
|
||||||
//lispsmSetup->setUseAggressiveFocusRegion(false);
|
//lispsmSetup->setUseAggressiveFocusRegion(false);
|
||||||
shadowCameraSetup = ShadowCameraSetupPtr(lispsmSetup);
|
shadowCameraSetup = ShadowCameraSetupPtr(lispsmSetup);
|
||||||
|
@ -131,7 +131,7 @@ void Shadows::recreate()
|
||||||
Overlay* overlay;
|
Overlay* overlay;
|
||||||
|
|
||||||
// destroy if already exists
|
// destroy if already exists
|
||||||
if (overlay = mgr.getByName("DebugOverlay"))
|
if ((overlay = mgr.getByName("DebugOverlay")))
|
||||||
mgr.destroy(overlay);
|
mgr.destroy(overlay);
|
||||||
|
|
||||||
overlay = mgr.create("DebugOverlay");
|
overlay = mgr.create("DebugOverlay");
|
||||||
|
@ -155,10 +155,10 @@ void Shadows::recreate()
|
||||||
// destroy container if exists
|
// destroy container if exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (debugPanel =
|
if ((debugPanel =
|
||||||
static_cast<OverlayContainer*>(
|
static_cast<OverlayContainer*>(
|
||||||
mgr.getOverlayElement("Ogre/DebugTexPanel" + StringConverter::toString(i)
|
mgr.getOverlayElement("Ogre/DebugTexPanel" + StringConverter::toString(i)
|
||||||
)))
|
))))
|
||||||
mgr.destroyOverlayElement(debugPanel);
|
mgr.destroyOverlayElement(debugPanel);
|
||||||
}
|
}
|
||||||
catch (Ogre::Exception&) {}
|
catch (Ogre::Exception&) {}
|
||||||
|
@ -178,7 +178,7 @@ void Shadows::recreate()
|
||||||
OverlayManager& mgr = OverlayManager::getSingleton();
|
OverlayManager& mgr = OverlayManager::getSingleton();
|
||||||
Overlay* overlay;
|
Overlay* overlay;
|
||||||
|
|
||||||
if (overlay = mgr.getByName("DebugOverlay"))
|
if ((overlay = mgr.getByName("DebugOverlay")))
|
||||||
mgr.destroy(overlay);
|
mgr.destroy(overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <OgreOverlayManager.h>
|
#include <OgreOverlayManager.h>
|
||||||
#include <OgreOverlayContainer.h>
|
#include <OgreOverlayContainer.h>
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -50,7 +52,7 @@ void BillboardObject::setSize(const float size)
|
||||||
|
|
||||||
void BillboardObject::setVisibility(const float visibility)
|
void BillboardObject::setVisibility(const float visibility)
|
||||||
{
|
{
|
||||||
mMaterial->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, visibility);
|
//mMaterial->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillboardObject::setPosition(const Vector3& pPosition)
|
void BillboardObject::setPosition(const Vector3& pPosition)
|
||||||
|
@ -76,7 +78,7 @@ void BillboardObject::setVisibilityFlags(int flags)
|
||||||
|
|
||||||
void BillboardObject::setColour(const ColourValue& pColour)
|
void BillboardObject::setColour(const ColourValue& pColour)
|
||||||
{
|
{
|
||||||
mMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(pColour);
|
//mMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(pColour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillboardObject::setRenderQueue(unsigned int id)
|
void BillboardObject::setRenderQueue(unsigned int id)
|
||||||
|
@ -112,6 +114,12 @@ void BillboardObject::init(const String& textureName,
|
||||||
mBBSet->createBillboard(0,0,0);
|
mBBSet->createBillboard(0,0,0);
|
||||||
mBBSet->setCastShadows(false);
|
mBBSet->setCastShadows(false);
|
||||||
|
|
||||||
|
sh::MaterialInstance* m = sh::Factory::getInstance().createMaterialInstance ("BillboardMaterial"+StringConverter::toString(bodyCount), "openmw_sun");
|
||||||
|
m->setProperty("texture", sh::makeProperty<sh::StringValue>(new sh::StringValue(textureName)));
|
||||||
|
|
||||||
|
mBBSet->setMaterialName("BillboardMaterial"+StringConverter::toString(bodyCount));
|
||||||
|
|
||||||
|
/*
|
||||||
mMaterial = MaterialManager::getSingleton().create("BillboardMaterial"+StringConverter::toString(bodyCount), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
mMaterial = MaterialManager::getSingleton().create("BillboardMaterial"+StringConverter::toString(bodyCount), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||||
mMaterial->removeAllTechniques();
|
mMaterial->removeAllTechniques();
|
||||||
Pass* p = mMaterial->createTechnique()->createPass();
|
Pass* p = mMaterial->createTechnique()->createPass();
|
||||||
|
@ -123,7 +131,6 @@ void BillboardObject::init(const String& textureName,
|
||||||
p->setAmbient(0.0,0.0,0.0);
|
p->setAmbient(0.0,0.0,0.0);
|
||||||
p->setPolygonModeOverrideable(false);
|
p->setPolygonModeOverrideable(false);
|
||||||
p->createTextureUnitState(textureName);
|
p->createTextureUnitState(textureName);
|
||||||
mBBSet->setMaterialName("BillboardMaterial"+StringConverter::toString(bodyCount));
|
|
||||||
|
|
||||||
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
||||||
HighLevelGpuProgramPtr vshader;
|
HighLevelGpuProgramPtr vshader;
|
||||||
|
@ -183,7 +190,7 @@ void BillboardObject::init(const String& textureName,
|
||||||
fshader->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
|
fshader->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
|
||||||
fshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
fshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||||
mMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
mMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
||||||
|
*/
|
||||||
bodyCount++;
|
bodyCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +201,8 @@ Moon::Moon( const String& textureName,
|
||||||
{
|
{
|
||||||
init(textureName, initialSize, position, rootNode);
|
init(textureName, initialSize, position, rootNode);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
||||||
HighLevelGpuProgramPtr vshader;
|
HighLevelGpuProgramPtr vshader;
|
||||||
if (mgr.resourceExists("Moon_VP"))
|
if (mgr.resourceExists("Moon_VP"))
|
||||||
|
@ -261,6 +270,8 @@ Moon::Moon( const String& textureName,
|
||||||
fshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
fshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||||
mMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
mMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
setVisibility(1.0);
|
setVisibility(1.0);
|
||||||
|
|
||||||
mPhase = Moon::Phase_Full;
|
mPhase = Moon::Phase_Full;
|
||||||
|
@ -273,7 +284,7 @@ void Moon::setType(const Moon::Type& type)
|
||||||
|
|
||||||
void Moon::setSkyColour(const Ogre::ColourValue& colour)
|
void Moon::setSkyColour(const Ogre::ColourValue& colour)
|
||||||
{
|
{
|
||||||
mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("skyColour", colour);
|
//mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("skyColour", colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Moon::setPhase(const Moon::Phase& phase)
|
void Moon::setPhase(const Moon::Phase& phase)
|
||||||
|
@ -295,7 +306,7 @@ void Moon::setPhase(const Moon::Phase& phase)
|
||||||
|
|
||||||
textureName += ".dds";
|
textureName += ".dds";
|
||||||
|
|
||||||
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
|
//mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
|
||||||
|
|
||||||
mPhase = phase;
|
mPhase = phase;
|
||||||
}
|
}
|
||||||
|
@ -387,8 +398,6 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||||
, mSceneMgr(NULL)
|
, mSceneMgr(NULL)
|
||||||
, mAtmosphereDay(NULL)
|
, mAtmosphereDay(NULL)
|
||||||
, mAtmosphereNight(NULL)
|
, mAtmosphereNight(NULL)
|
||||||
, mCloudMaterial()
|
|
||||||
, mAtmosphereMaterial()
|
|
||||||
, mCloudFragmentShader()
|
, mCloudFragmentShader()
|
||||||
, mClouds()
|
, mClouds()
|
||||||
, mNextClouds()
|
, mNextClouds()
|
||||||
|
@ -406,6 +415,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||||
, mMasserEnabled(true)
|
, mMasserEnabled(true)
|
||||||
, mSecundaEnabled(true)
|
, mSecundaEnabled(true)
|
||||||
, mCreated(false)
|
, mCreated(false)
|
||||||
|
, mCloudAnimationTimer(0.f)
|
||||||
{
|
{
|
||||||
mSceneMgr = pMwRoot->getCreator();
|
mSceneMgr = pMwRoot->getCreator();
|
||||||
mRootNode = mCamera->getParentSceneNode()->createChildSceneNode();
|
mRootNode = mCamera->getParentSceneNode()->createChildSceneNode();
|
||||||
|
@ -415,7 +425,19 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||||
|
|
||||||
void SkyManager::create()
|
void SkyManager::create()
|
||||||
{
|
{
|
||||||
/// \todo preload all the textures and meshes that are used for sky rendering
|
sh::Factory::getInstance().setSharedParameter ("cloudBlendFactor",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudOpacity",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(1)));
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudColour",
|
||||||
|
sh::makeProperty<sh::Vector3>(new sh::Vector3(1,1,1)));
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudAnimationTimer",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("nightFade",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
|
||||||
|
|
||||||
|
sh::Factory::getInstance().setTextureAlias ("cloud_texture_1", "");
|
||||||
|
sh::Factory::getInstance().setTextureAlias ("cloud_texture_2", "");
|
||||||
|
|
||||||
// Create overlay used for thunderstorm
|
// Create overlay used for thunderstorm
|
||||||
MaterialPtr material = MaterialManager::getSingleton().create( "ThunderMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
MaterialPtr material = MaterialManager::getSingleton().create( "ThunderMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
||||||
|
@ -449,9 +471,6 @@ void SkyManager::create()
|
||||||
mSunGlare->setRenderQueue(RQG_SkiesLate);
|
mSunGlare->setRenderQueue(RQG_SkiesLate);
|
||||||
mSunGlare->setVisibilityFlags(RV_Glare);
|
mSunGlare->setVisibilityFlags(RV_Glare);
|
||||||
|
|
||||||
|
|
||||||
HighLevelGpuProgramManager& mgr = HighLevelGpuProgramManager::getSingleton();
|
|
||||||
|
|
||||||
// Stars
|
// Stars
|
||||||
MeshPtr mesh = NifOgre::NIFLoader::load("meshes\\sky_night_01.nif");
|
MeshPtr mesh = NifOgre::NIFLoader::load("meshes\\sky_night_01.nif");
|
||||||
Entity* night1_ent = mSceneMgr->createEntity("meshes\\sky_night_01.nif");
|
Entity* night1_ent = mSceneMgr->createEntity("meshes\\sky_night_01.nif");
|
||||||
|
@ -462,76 +481,18 @@ void SkyManager::create()
|
||||||
mAtmosphereNight = mRootNode->createChildSceneNode();
|
mAtmosphereNight = mRootNode->createChildSceneNode();
|
||||||
mAtmosphereNight->attachObject(night1_ent);
|
mAtmosphereNight->attachObject(night1_ent);
|
||||||
|
|
||||||
// Stars vertex shader
|
|
||||||
HighLevelGpuProgramPtr stars_vp = mgr.createProgram("Stars_VP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
||||||
"cg", GPT_VERTEX_PROGRAM);
|
|
||||||
stars_vp->setParameter("profiles", "vs_2_x arbvp1");
|
|
||||||
stars_vp->setParameter("entry_point", "main_vp");
|
|
||||||
StringUtil::StrStreamType outStream4;
|
|
||||||
outStream4 <<
|
|
||||||
"void main_vp( \n"
|
|
||||||
" float4 position : POSITION, \n"
|
|
||||||
" in float2 uv : TEXCOORD0, \n"
|
|
||||||
" out float2 oUV : TEXCOORD0, \n"
|
|
||||||
" out float oFade : TEXCOORD1, \n"
|
|
||||||
" out float4 oPosition : POSITION, \n"
|
|
||||||
" uniform float4x4 worldViewProj \n"
|
|
||||||
") \n"
|
|
||||||
"{ \n"
|
|
||||||
" oUV = uv; \n"
|
|
||||||
" oFade = (position.z > 50) ? 1.f : 0.f; \n"
|
|
||||||
" oPosition = mul( worldViewProj, position ); \n"
|
|
||||||
"}";
|
|
||||||
stars_vp->setSource(outStream4.str());
|
|
||||||
stars_vp->load();
|
|
||||||
stars_vp->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
|
||||||
|
|
||||||
// Stars fragment shader
|
|
||||||
HighLevelGpuProgramPtr stars_fp = mgr.createProgram("Stars_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
||||||
"cg", GPT_FRAGMENT_PROGRAM);
|
|
||||||
stars_fp->setParameter("profiles", "ps_2_x arbfp1");
|
|
||||||
stars_fp->setParameter("entry_point", "main_fp");
|
|
||||||
StringUtil::StrStreamType outStream5;
|
|
||||||
outStream5 <<
|
|
||||||
"void main_fp( \n"
|
|
||||||
" in float2 uv : TEXCOORD0, \n"
|
|
||||||
" out float4 oColor : COLOR, \n";
|
|
||||||
if (RenderingManager::useMRT()) outStream5 <<
|
|
||||||
" out float4 oColor1 : COLOR1, \n";
|
|
||||||
outStream5 <<
|
|
||||||
" in float fade : TEXCOORD1, \n"
|
|
||||||
" uniform sampler2D texture : TEXUNIT0, \n"
|
|
||||||
" uniform float opacity, \n"
|
|
||||||
" uniform float4 diffuse, \n"
|
|
||||||
" uniform float4 emissive \n"
|
|
||||||
") \n"
|
|
||||||
"{ \n"
|
|
||||||
" oColor = tex2D(texture, uv) * float4(emissive.xyz, 1) * float4(1,1,1,fade*diffuse.a); \n";
|
|
||||||
if (RenderingManager::useMRT()) outStream5 <<
|
|
||||||
" oColor1 = float4(1, 0, 0, 1); \n";
|
|
||||||
outStream5 <<
|
|
||||||
"}";
|
|
||||||
stars_fp->setSource(outStream5.str());
|
|
||||||
stars_fp->load();
|
|
||||||
stars_fp->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
|
||||||
stars_fp->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
|
|
||||||
|
|
||||||
/*
|
|
||||||
for (unsigned int i=0; i<night1_ent->getNumSubEntities(); ++i)
|
for (unsigned int i=0; i<night1_ent->getNumSubEntities(); ++i)
|
||||||
{
|
{
|
||||||
MaterialPtr mp = night1_ent->getSubEntity(i)->getMaterial();
|
std::string matName = "openmw_stars_" + boost::lexical_cast<std::string>(i);
|
||||||
mp->getTechnique(0)->getPass(0)->setSelfIllumination(1.0, 1.0, 1.0);
|
sh::MaterialInstance* m = sh::Factory::getInstance ().createMaterialInstance (matName, "openmw_stars");
|
||||||
mp->getTechnique(0)->getPass(0)->setAmbient(0.0, 0.0, 0.0);
|
|
||||||
mp->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, 1.0);
|
std::string textureName = sh::retrieveValue<sh::StringValue>(
|
||||||
mp->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
|
sh::Factory::getInstance().getMaterialInstance(night1_ent->getSubEntity (i)->getMaterialName ())->getProperty("diffuseMap"), NULL).get();
|
||||||
mp->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
|
|
||||||
mp->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
m->setProperty ("texture", sh::makeProperty<sh::StringValue>(new sh::StringValue(textureName)));
|
||||||
mp->getTechnique(0)->getPass(0)->setVertexProgram(stars_vp->getName());
|
|
||||||
mp->getTechnique(0)->getPass(0)->setFragmentProgram(stars_fp->getName());
|
night1_ent->getSubEntity(i)->setMaterialName (matName);
|
||||||
mp->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
|
||||||
mStarsMaterials[i] = mp;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Atmosphere (day)
|
// Atmosphere (day)
|
||||||
mesh = NifOgre::NIFLoader::load("meshes\\sky_atmosphere.nif");
|
mesh = NifOgre::NIFLoader::load("meshes\\sky_atmosphere.nif");
|
||||||
|
@ -545,11 +506,6 @@ void SkyManager::create()
|
||||||
mAtmosphereDay = mRootNode->createChildSceneNode();
|
mAtmosphereDay = mRootNode->createChildSceneNode();
|
||||||
mAtmosphereDay->attachObject(atmosphere_ent);
|
mAtmosphereDay->attachObject(atmosphere_ent);
|
||||||
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
|
atmosphere_ent->getSubEntity (0)->setMaterialName ("openmw_atmosphere");
|
||||||
//mAtmosphereMaterial = atmosphere_ent->getSubEntity(0)->getMaterial();
|
|
||||||
//mAtmosphereMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
|
||||||
// Atmosphere shader
|
|
||||||
// mAtmosphereMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(fshader->getName());
|
|
||||||
atmosphere_ent->getSubEntity (0)->setMaterialName("openmw_atmosphere");
|
|
||||||
|
|
||||||
// Clouds
|
// Clouds
|
||||||
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
||||||
|
@ -558,89 +514,11 @@ void SkyManager::create()
|
||||||
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
|
clouds_ent->setRenderQueueGroup(RQG_SkiesEarly+5);
|
||||||
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
SceneNode* clouds_node = mRootNode->createChildSceneNode();
|
||||||
clouds_node->attachObject(clouds_ent);
|
clouds_node->attachObject(clouds_ent);
|
||||||
//mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
|
||||||
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
clouds_ent->getSubEntity(0)->setMaterialName ("openmw_clouds");
|
||||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setPolygonModeOverrideable(false);
|
|
||||||
clouds_ent->setCastShadows(false);
|
clouds_ent->setCastShadows(false);
|
||||||
|
|
||||||
// Clouds vertex shader
|
|
||||||
HighLevelGpuProgramPtr vshader2 = mgr.createProgram("Clouds_VP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
||||||
"cg", GPT_VERTEX_PROGRAM);
|
|
||||||
vshader2->setParameter("profiles", "vs_2_x arbvp1");
|
|
||||||
vshader2->setParameter("entry_point", "main_vp");
|
|
||||||
StringUtil::StrStreamType outStream3;
|
|
||||||
outStream3 <<
|
|
||||||
"void main_vp( \n"
|
|
||||||
" float4 position : POSITION, \n"
|
|
||||||
" in float4 color : COLOR, \n"
|
|
||||||
" out float4 oColor : TEXCOORD1, \n"
|
|
||||||
" in float2 uv : TEXCOORD0, \n"
|
|
||||||
" out float2 oUV : TEXCOORD0, \n"
|
|
||||||
" out float4 oPosition : POSITION, \n"
|
|
||||||
" uniform float4x4 worldViewProj \n"
|
|
||||||
") \n"
|
|
||||||
"{ \n"
|
|
||||||
" oUV = uv; \n"
|
|
||||||
" oColor = color; \n"
|
|
||||||
" oPosition = mul( worldViewProj, position ); \n"
|
|
||||||
"}";
|
|
||||||
vshader2->setSource(outStream3.str());
|
|
||||||
vshader2->load();
|
|
||||||
vshader2->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
|
||||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader2->getName());
|
|
||||||
|
|
||||||
// Clouds fragment shader
|
|
||||||
mCloudFragmentShader = mgr.createProgram("Clouds_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
||||||
"cg", GPT_FRAGMENT_PROGRAM);
|
|
||||||
mCloudFragmentShader->setParameter("profiles", "ps_2_x arbfp1");
|
|
||||||
mCloudFragmentShader->setParameter("entry_point", "main_fp");
|
|
||||||
StringUtil::StrStreamType outStream2;
|
|
||||||
outStream2 <<
|
|
||||||
"void main_fp( \n"
|
|
||||||
" in float2 uv : TEXCOORD0, \n"
|
|
||||||
" in float4 color : TEXCOORD1, \n"
|
|
||||||
" out float4 oColor : COLOR, \n";
|
|
||||||
if (RenderingManager::useMRT()) outStream2 <<
|
|
||||||
" out float4 oColor1 : COLOR1, \n";
|
|
||||||
outStream2 <<
|
|
||||||
" uniform sampler2D texture : TEXUNIT0, \n"
|
|
||||||
" uniform sampler2D secondTexture : TEXUNIT1, \n"
|
|
||||||
" uniform float transitionFactor, \n"
|
|
||||||
" uniform float time, \n"
|
|
||||||
" uniform float speed, \n"
|
|
||||||
" uniform float opacity, \n"
|
|
||||||
" uniform float4 emissive \n"
|
|
||||||
") \n"
|
|
||||||
"{ \n"
|
|
||||||
" uv += float2(0,1) * time * speed * 0.003; \n" // Scroll in y direction
|
|
||||||
" float4 tex = lerp(tex2D(texture, uv), tex2D(secondTexture, uv), transitionFactor); \n"
|
|
||||||
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n";
|
|
||||||
if (RenderingManager::useMRT()) outStream2 <<
|
|
||||||
" oColor1 = float4(1, 0, 0, 1); \n";
|
|
||||||
outStream2 <<
|
|
||||||
"}";
|
|
||||||
mCloudFragmentShader->setSource(outStream2.str());
|
|
||||||
mCloudFragmentShader->load();
|
|
||||||
mCloudFragmentShader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
|
||||||
//mCloudMaterial->getTechnique(0)->getPass(0)->setFragmentProgram(mCloudFragmentShader->getName());
|
|
||||||
setCloudsOpacity(0.75);
|
|
||||||
|
|
||||||
ModVertexAlpha(clouds_ent, 1);
|
ModVertexAlpha(clouds_ent, 1);
|
||||||
|
|
||||||
// I'm not sure if the materials are being used by any other objects
|
|
||||||
// Make a unique "modifiable" copy of the materials to be sure
|
|
||||||
//mCloudMaterial = mCloudMaterial->clone("Clouds");
|
|
||||||
//clouds_ent->getSubEntity(0)->setMaterial(mCloudMaterial);
|
|
||||||
/*
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1.0, 1.0, 1.0);
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
|
||||||
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("textures\\tx_sky_cloudy.dds");
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("");
|
|
||||||
*/
|
|
||||||
|
|
||||||
mCreated = true;
|
mCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +547,10 @@ void SkyManager::update(float duration)
|
||||||
if (!mEnabled) return;
|
if (!mEnabled) return;
|
||||||
|
|
||||||
// UV Scroll the clouds
|
// UV Scroll the clouds
|
||||||
//mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
|
mCloudAnimationTimer += duration * mCloudSpeed * (MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f);
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudAnimationTimer",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(mCloudAnimationTimer)));
|
||||||
|
|
||||||
|
|
||||||
/// \todo improve this
|
/// \todo improve this
|
||||||
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
|
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
|
||||||
|
@ -678,15 +559,15 @@ void SkyManager::update(float duration)
|
||||||
|
|
||||||
if (mSunEnabled)
|
if (mSunEnabled)
|
||||||
{
|
{
|
||||||
// take 1/5 sec for fading the glare effect from invisible to full
|
// take 1/10 sec for fading the glare effect from invisible to full
|
||||||
if (mGlareFade > mGlare)
|
if (mGlareFade > mGlare)
|
||||||
{
|
{
|
||||||
mGlareFade -= duration*5;
|
mGlareFade -= duration*10;
|
||||||
if (mGlareFade < mGlare) mGlareFade = mGlare;
|
if (mGlareFade < mGlare) mGlareFade = mGlare;
|
||||||
}
|
}
|
||||||
else if (mGlareFade < mGlare)
|
else if (mGlareFade < mGlare)
|
||||||
{
|
{
|
||||||
mGlareFade += duration*5;
|
mGlareFade += duration*10;
|
||||||
if (mGlareFade > mGlare) mGlareFade = mGlare;
|
if (mGlareFade > mGlare) mGlareFade = mGlare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,39 +614,34 @@ void SkyManager::setMoonColour (bool red)
|
||||||
: ColourValue(1.0, 1.0, 1.0));
|
: ColourValue(1.0, 1.0, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyManager::setCloudsOpacity(float opacity)
|
|
||||||
{
|
|
||||||
if (!mCreated) return;
|
|
||||||
//mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("opacity", Real(opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
||||||
{
|
{
|
||||||
if (!mCreated) return;
|
if (!mCreated) return;
|
||||||
|
|
||||||
/*
|
|
||||||
if (mClouds != weather.mCloudTexture)
|
if (mClouds != weather.mCloudTexture)
|
||||||
{
|
{
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("textures\\"+weather.mCloudTexture);
|
sh::Factory::getInstance().setTextureAlias ("cloud_texture_1", "textures\\"+weather.mCloudTexture);
|
||||||
mClouds = weather.mCloudTexture;
|
mClouds = weather.mCloudTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNextClouds != weather.mNextCloudTexture)
|
if (mNextClouds != weather.mNextCloudTexture)
|
||||||
{
|
{
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName("textures\\"+weather.mNextCloudTexture);
|
sh::Factory::getInstance().setTextureAlias ("cloud_texture_2", "textures\\"+weather.mNextCloudTexture);
|
||||||
mNextClouds = weather.mNextCloudTexture;
|
mNextClouds = weather.mNextCloudTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCloudBlendFactor != weather.mCloudBlendFactor)
|
if (mCloudBlendFactor != weather.mCloudBlendFactor)
|
||||||
{
|
{
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("transitionFactor", Real(weather.mCloudBlendFactor));
|
|
||||||
mCloudBlendFactor = weather.mCloudBlendFactor;
|
mCloudBlendFactor = weather.mCloudBlendFactor;
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudBlendFactor",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(weather.mCloudBlendFactor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCloudOpacity != weather.mCloudOpacity)
|
if (mCloudOpacity != weather.mCloudOpacity)
|
||||||
{
|
{
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("opacity", Real(weather.mCloudOpacity));
|
|
||||||
mCloudOpacity = weather.mCloudOpacity;
|
mCloudOpacity = weather.mCloudOpacity;
|
||||||
|
sh::Factory::getInstance().setSharedParameter ("cloudOpacity",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(weather.mCloudOpacity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCloudColour != weather.mSunColor)
|
if (mCloudColour != weather.mSunColor)
|
||||||
|
@ -774,23 +650,21 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
||||||
weather.mSunColor.g*0.7 + weather.mAmbientColor.g*0.7,
|
weather.mSunColor.g*0.7 + weather.mAmbientColor.g*0.7,
|
||||||
weather.mSunColor.b*0.7 + weather.mAmbientColor.b*0.7);
|
weather.mSunColor.b*0.7 + weather.mAmbientColor.b*0.7);
|
||||||
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(clr);
|
sh::Factory::getInstance().setSharedParameter ("cloudColour",
|
||||||
|
sh::makeProperty<sh::Vector3>(new sh::Vector3(clr.r, clr.g, clr.b)));
|
||||||
|
|
||||||
mCloudColour = weather.mSunColor;
|
mCloudColour = weather.mSunColor;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if (mSkyColour != weather.mSkyColor)
|
if (mSkyColour != weather.mSkyColor)
|
||||||
{
|
{
|
||||||
mSkyColour = weather.mSkyColor;
|
mSkyColour = weather.mSkyColor;
|
||||||
sh::Factory::getInstance().setSharedParameter ("atmosphereColour", sh::makeProperty<sh::Vector4>(new sh::Vector4(
|
sh::Factory::getInstance().setSharedParameter ("atmosphereColour", sh::makeProperty<sh::Vector4>(new sh::Vector4(
|
||||||
weather.mSkyColor.r, weather.mSkyColor.g, weather.mSkyColor.b, 1.0)));
|
weather.mSkyColor.r, weather.mSkyColor.g, weather.mSkyColor.b, weather.mSkyColor.a)));
|
||||||
}
|
|
||||||
/*
|
|
||||||
if (mCloudSpeed != weather.mCloudSpeed)
|
|
||||||
{
|
|
||||||
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("speed", Real(weather.mCloudSpeed));
|
|
||||||
mCloudSpeed = weather.mCloudSpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCloudSpeed = weather.mCloudSpeed;
|
||||||
|
|
||||||
if (weather.mNight && mStarsOpacity != weather.mNightFade)
|
if (weather.mNight && mStarsOpacity != weather.mNightFade)
|
||||||
{
|
{
|
||||||
if (weather.mNightFade == 0)
|
if (weather.mNightFade == 0)
|
||||||
|
@ -798,12 +672,14 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mAtmosphereNight->setVisible(true);
|
mAtmosphereNight->setVisible(true);
|
||||||
for (int i=0; i<7; ++i)
|
|
||||||
mStarsMaterials[i]->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, weather.mNightFade);
|
sh::Factory::getInstance().setSharedParameter ("nightFade",
|
||||||
|
sh::makeProperty<sh::FloatValue>(new sh::FloatValue(weather.mNightFade)));
|
||||||
|
|
||||||
mStarsOpacity = weather.mNightFade;
|
mStarsOpacity = weather.mNightFade;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
float strength;
|
float strength;
|
||||||
float timeofday_angle = std::abs(mSunGlare->getPosition().z/mSunGlare->getPosition().length());
|
float timeofday_angle = std::abs(mSunGlare->getPosition().z/mSunGlare->getPosition().length());
|
||||||
|
|
|
@ -139,9 +139,6 @@ namespace MWRender
|
||||||
void setMoonColour (bool red);
|
void setMoonColour (bool red);
|
||||||
///< change Secunda colour to red
|
///< change Secunda colour to red
|
||||||
|
|
||||||
void setCloudsOpacity(float opacity);
|
|
||||||
///< change opacity of the clouds
|
|
||||||
|
|
||||||
void setWeather(const MWWorld::WeatherResult& weather);
|
void setWeather(const MWWorld::WeatherResult& weather);
|
||||||
|
|
||||||
Ogre::SceneNode* getSunNode();
|
Ogre::SceneNode* getSunNode();
|
||||||
|
@ -182,6 +179,8 @@ namespace MWRender
|
||||||
int mDay;
|
int mDay;
|
||||||
int mMonth;
|
int mMonth;
|
||||||
|
|
||||||
|
float mCloudAnimationTimer;
|
||||||
|
|
||||||
BillboardObject* mSun;
|
BillboardObject* mSun;
|
||||||
BillboardObject* mSunGlare;
|
BillboardObject* mSunGlare;
|
||||||
Moon* mMasser;
|
Moon* mMasser;
|
||||||
|
@ -194,11 +193,6 @@ namespace MWRender
|
||||||
Ogre::SceneNode* mAtmosphereDay;
|
Ogre::SceneNode* mAtmosphereDay;
|
||||||
Ogre::SceneNode* mAtmosphereNight;
|
Ogre::SceneNode* mAtmosphereNight;
|
||||||
|
|
||||||
Ogre::MaterialPtr mCloudMaterial;
|
|
||||||
Ogre::MaterialPtr mAtmosphereMaterial;
|
|
||||||
|
|
||||||
Ogre::MaterialPtr mStarsMaterials[7];
|
|
||||||
|
|
||||||
Ogre::HighLevelGpuProgramPtr mCloudFragmentShader;
|
Ogre::HighLevelGpuProgramPtr mCloudFragmentShader;
|
||||||
|
|
||||||
// remember some settings so we don't have to apply them again if they didnt change
|
// remember some settings so we don't have to apply them again if they didnt change
|
||||||
|
|
2
extern/shiny
vendored
2
extern/shiny
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 34e952bf3d5e09adfd3e5c0f6462d612e193e447
|
Subproject commit 7485a15c26f129084a1c264fa1a98dc2de86f298
|
|
@ -1,11 +1,11 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
#define MRT @shPropertyBool(mrt_output)
|
#define MRT @shGlobalSettingBool(mrt_output)
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
|
|
||||||
shColourInput(float4)
|
shColourInput(float4)
|
||||||
shOutput(float4, colourPassthrough)
|
shOutput(float4, colourPassthrough)
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
#if MRT
|
#if MRT
|
||||||
shDeclareMrtOutput(1)
|
shDeclareMrtOutput(1)
|
||||||
#endif
|
#endif
|
||||||
shUniform(float4 atmosphereColour) @shSharedParameter(atmosphereColour)
|
shUniform(float4, atmosphereColour) @shSharedParameter(atmosphereColour)
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
#define MRT @shPropertyBool(mrt_output)
|
#define MRT @shGlobalSettingBool(mrt_output)
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shInput(float2, uv0)
|
shInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
shColourInput(float4)
|
shColourInput(float4)
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
|
colourPassthrough = colour;
|
||||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||||
UV = uv0;
|
UV = uv0;
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,28 @@
|
||||||
#else
|
#else
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shSampler2D(diffuseMap)
|
|
||||||
shInput(float2, UV)
|
shInput(float2, UV)
|
||||||
|
shInput(float4, colourPassthrough)
|
||||||
#if MRT
|
#if MRT
|
||||||
shDeclareMrtOutput(1)
|
shDeclareMrtOutput(1)
|
||||||
#endif
|
#endif
|
||||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
|
||||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
shSampler2D(diffuseMap1)
|
||||||
|
shSampler2D(diffuseMap2)
|
||||||
|
|
||||||
|
shUniform(float, cloudBlendFactor) @shSharedParameter(cloudBlendFactor)
|
||||||
|
shUniform(float, cloudAnimationTimer) @shSharedParameter(cloudAnimationTimer)
|
||||||
|
shUniform(float, cloudOpacity) @shSharedParameter(cloudOpacity)
|
||||||
|
shUniform(float3, cloudColour) @shSharedParameter(cloudColour)
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputColour(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
// Scroll in y direction
|
||||||
|
float2 scrolledUV = UV + float2(0,1) * cloudAnimationTimer * 0.003;
|
||||||
|
|
||||||
|
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
|
||||||
|
|
||||||
|
shOutputColour(0) = colourPassthrough * float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity);
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shOutputColour(1) = float4(1,1,1,1);
|
shOutputColour(1) = float4(1,1,1,1);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#define shMatrixMult(m, v) mul(m, v)
|
#define shMatrixMult(m, v) mul(m, v)
|
||||||
|
|
||||||
#define shUniform(s) , uniform s
|
#define shUniform(type, name) , uniform type name
|
||||||
|
|
||||||
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
||||||
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
||||||
|
@ -59,13 +59,13 @@
|
||||||
#define float4 vec4
|
#define float4 vec4
|
||||||
#define int2 ivec2
|
#define int2 ivec2
|
||||||
#define int3 ivec3
|
#define int3 ivec3
|
||||||
#define int4 ivec4
|
#define int4 ivec4/
|
||||||
#define shTexture2D sampler2D
|
#define shTexture2D sampler2D
|
||||||
#define shSample(tex, coord) texture(tex, coord)
|
#define shSample(tex, coord) texture(tex, coord)
|
||||||
#define shLerp(a, b, t) mix(a, b, t)
|
#define shLerp(a, b, t) mix(a, b, t)
|
||||||
#define shSaturate(a) clamp(a, 0.0, 1.0)
|
#define shSaturate(a) clamp(a, 0.0, 1.0)
|
||||||
|
|
||||||
#define shUniform(s) uniform s;
|
#define shUniform(type, name) uniform type name;
|
||||||
|
|
||||||
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
|
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// ------------------------------------- VERTEX ---------------------------------------
|
// ------------------------------------- VERTEX ---------------------------------------
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shInput(float2, uv0)
|
shInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
shNormalInput(float4)
|
shNormalInput(float4)
|
||||||
|
@ -41,16 +41,16 @@
|
||||||
|
|
||||||
#if SHADOWS
|
#if SHADOWS
|
||||||
shOutput(float4, lightSpacePos0)
|
shOutput(float4, lightSpacePos0)
|
||||||
shUniform(float4x4 texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||||
shUniform(float4x4 worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SHADOWS_PSSM
|
#if SHADOWS_PSSM
|
||||||
@shForeach(3)
|
@shForeach(3)
|
||||||
shOutput(float4, lightSpacePos@shIterator)
|
shOutput(float4, lightSpacePos@shIterator)
|
||||||
shUniform(float4x4 texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||||
@shEndForeach
|
@shEndForeach
|
||||||
shUniform(float4x4 worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||||
#endif
|
#endif
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
|
@ -99,27 +99,27 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shUniform(float far) @shAutoConstant(far, far_clip_distance)
|
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LIGHTING
|
#if LIGHTING
|
||||||
shInput(float3, normalPassthrough)
|
shInput(float3, normalPassthrough)
|
||||||
shInput(float3, objSpacePositionPassthrough)
|
shInput(float3, objSpacePositionPassthrough)
|
||||||
shUniform(float4 lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||||
//shUniform(float passIteration) @shAutoConstant(passIteration, pass_iteration_number)
|
//shUniform(float, passIteration) @shAutoConstant(passIteration, pass_iteration_number)
|
||||||
shUniform(float4 materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||||
@shForeach(8)
|
@shForeach(8)
|
||||||
shUniform(float4 lightPosObjSpace@shIterator) @shAutoConstant(lightPosObjSpace@shIterator, light_position_object_space, @shIterator)
|
shUniform(float4, lightPosObjSpace@shIterator) @shAutoConstant(lightPosObjSpace@shIterator, light_position_object_space, @shIterator)
|
||||||
shUniform(float4 lightAttenuation@shIterator) @shAutoConstant(lightAttenuation@shIterator, light_attenuation, @shIterator)
|
shUniform(float4, lightAttenuation@shIterator) @shAutoConstant(lightAttenuation@shIterator, light_attenuation, @shIterator)
|
||||||
shUniform(float4 lightDiffuse@shIterator) @shAutoConstant(lightDiffuse@shIterator, light_diffuse_colour, @shIterator)
|
shUniform(float4, lightDiffuse@shIterator) @shAutoConstant(lightDiffuse@shIterator, light_diffuse_colour, @shIterator)
|
||||||
@shEndForeach
|
@shEndForeach
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FOG
|
#if FOG
|
||||||
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
|
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||||
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
|
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_VERTEXCOLOR
|
#ifdef HAS_VERTEXCOLOR
|
||||||
|
@ -129,19 +129,19 @@
|
||||||
#if SHADOWS
|
#if SHADOWS
|
||||||
shInput(float4, lightSpacePos0)
|
shInput(float4, lightSpacePos0)
|
||||||
shSampler2D(shadowMap0)
|
shSampler2D(shadowMap0)
|
||||||
shUniform(float2 invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, 1)
|
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, 1)
|
||||||
#endif
|
#endif
|
||||||
#if SHADOWS_PSSM
|
#if SHADOWS_PSSM
|
||||||
@shForeach(3)
|
@shForeach(3)
|
||||||
shInput(float4, lightSpacePos@shIterator)
|
shInput(float4, lightSpacePos@shIterator)
|
||||||
shSampler2D(shadowMap@shIterator)
|
shSampler2D(shadowMap@shIterator)
|
||||||
shUniform(float2 invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(1))
|
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(1))
|
||||||
@shEndForeach
|
@shEndForeach
|
||||||
shUniform(float4 pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SHADOWS || SHADOWS_PSSM
|
#if SHADOWS || SHADOWS_PSSM
|
||||||
shUniform(float4 shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||||
#endif
|
#endif
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
shInput(float2, uv0)
|
shInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
#endif
|
#endif
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shOutput(float2, depth)
|
shOutput(float2, depth)
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float depthShadowPCF (shTexture2D shadowMap, float4 shadowMapPos, float2 offset)
|
float depthShadowPCF (shTexture2D shadowMap, float4 shadowMapPos, float2 offset)
|
||||||
{
|
{
|
||||||
shadowMapPos /= shadowMapPos.w;
|
shadowMapPos /= shadowMapPos.w;
|
||||||
|
@ -31,7 +29,7 @@ float pssmDepthShadow (
|
||||||
shTexture2D shadowMap2,
|
shTexture2D shadowMap2,
|
||||||
|
|
||||||
float depth,
|
float depth,
|
||||||
float4 pssmSplitPoints)
|
float3 pssmSplitPoints)
|
||||||
|
|
||||||
{
|
{
|
||||||
float shadow;
|
float shadow;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
material openmw_moon
|
material openmw_moon
|
||||||
{
|
{
|
||||||
allow_fixed_function false
|
allow_fixed_function false
|
||||||
mrt_output true
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
vertex_program moon_vertex
|
vertex_program moon_vertex
|
||||||
|
@ -9,11 +8,6 @@ material openmw_moon
|
||||||
|
|
||||||
polygon_mode_overrideable off
|
polygon_mode_overrideable off
|
||||||
|
|
||||||
shader_properties
|
|
||||||
{
|
|
||||||
mrt_output $mrt_output
|
|
||||||
}
|
|
||||||
|
|
||||||
texture_unit diffuseMap
|
texture_unit diffuseMap
|
||||||
{
|
{
|
||||||
texture $diffuseMap
|
texture $diffuseMap
|
||||||
|
@ -25,7 +19,6 @@ material openmw_moon
|
||||||
material openmw_clouds
|
material openmw_clouds
|
||||||
{
|
{
|
||||||
allow_fixed_function false
|
allow_fixed_function false
|
||||||
mrt_output true
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
vertex_program clouds_vertex
|
vertex_program clouds_vertex
|
||||||
|
@ -36,11 +29,6 @@ material openmw_clouds
|
||||||
scene_blend alpha_blend
|
scene_blend alpha_blend
|
||||||
depth_write off
|
depth_write off
|
||||||
|
|
||||||
shader_properties
|
|
||||||
{
|
|
||||||
mrt_output $mrt_output
|
|
||||||
}
|
|
||||||
|
|
||||||
// second diffuse map is used for weather transitions
|
// second diffuse map is used for weather transitions
|
||||||
texture_unit diffuseMap1
|
texture_unit diffuseMap1
|
||||||
{
|
{
|
||||||
|
@ -58,7 +46,6 @@ material openmw_clouds
|
||||||
material openmw_atmosphere
|
material openmw_atmosphere
|
||||||
{
|
{
|
||||||
allow_fixed_function false
|
allow_fixed_function false
|
||||||
mrt_output true
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
vertex_program atmosphere_vertex
|
vertex_program atmosphere_vertex
|
||||||
|
@ -68,18 +55,12 @@ material openmw_atmosphere
|
||||||
|
|
||||||
scene_blend alpha_blend
|
scene_blend alpha_blend
|
||||||
depth_write off
|
depth_write off
|
||||||
|
|
||||||
shader_properties
|
|
||||||
{
|
|
||||||
mrt_output $mrt_output
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
material openmw_stars
|
material openmw_stars
|
||||||
{
|
{
|
||||||
allow_fixed_function false
|
allow_fixed_function false
|
||||||
mrt_output true
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
vertex_program stars_vertex
|
vertex_program stars_vertex
|
||||||
|
@ -87,14 +68,13 @@ material openmw_stars
|
||||||
|
|
||||||
polygon_mode_overrideable off
|
polygon_mode_overrideable off
|
||||||
|
|
||||||
shader_properties
|
depth_check off
|
||||||
{
|
depth_write off
|
||||||
mrt_output $mrt_output
|
scene_blend alpha_blend
|
||||||
}
|
|
||||||
|
|
||||||
texture_unit diffuseMap
|
texture_unit diffuseMap
|
||||||
{
|
{
|
||||||
diffuseMap $diffuseMap
|
direct_texture $texture
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +83,6 @@ material openmw_stars
|
||||||
material openmw_sun
|
material openmw_sun
|
||||||
{
|
{
|
||||||
allow_fixed_function false
|
allow_fixed_function false
|
||||||
mrt_output true
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
vertex_program sun_vertex
|
vertex_program sun_vertex
|
||||||
|
@ -111,14 +90,9 @@ material openmw_sun
|
||||||
|
|
||||||
polygon_mode_overrideable off
|
polygon_mode_overrideable off
|
||||||
|
|
||||||
shader_properties
|
texture_unit diffuseMap
|
||||||
{
|
{
|
||||||
mrt_output $mrt_output
|
direct_texture $texture
|
||||||
}
|
|
||||||
|
|
||||||
texture unit diffuseMap
|
|
||||||
{
|
|
||||||
diffuseMap $diffuseMap
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
#define MRT @shPropertyBool(mrt_output)
|
#define MRT @shGlobalSettingBool(mrt_output)
|
||||||
|
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shInput(float2, uv0)
|
shInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
|
|
||||||
|
@ -24,13 +24,15 @@
|
||||||
#if MRT
|
#if MRT
|
||||||
shDeclareMrtOutput(1)
|
shDeclareMrtOutput(1)
|
||||||
#endif
|
#endif
|
||||||
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||||
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||||
|
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputColour(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
shOutputColour(0) = float4(1,1,1,materialDiffuse.a) * float4(materialEmissive.xyz, 1) * shSample(diffuseMap, UV);
|
||||||
|
|
||||||
|
shOutputColour(0) = shSample(diffuseMap, UV);
|
||||||
|
|
||||||
#if MRT
|
#if MRT
|
||||||
shOutputColour(1) = float4(1,1,1,1);
|
shOutputColour(1) = float4(1,1,1,1);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue