Skip to content

Commit

Permalink
simple water without shaders that uses original MW textures
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Apr 3, 2012
1 parent c1693a0 commit b3a186e
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 341 deletions.
1 change: 1 addition & 0 deletions apps/openmw/mwrender/localmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ void LocalMap::render(const float x, const float y,
vp->setShadowsEnabled(false);
vp->setBackgroundColour(ColourValue(0, 0, 0));
vp->setVisibilityMask(RV_Map);
vp->setMaterialScheme("Map");

rtt->update();

Expand Down
30 changes: 29 additions & 1 deletion apps/openmw/mwrender/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Water::Water (Ogre::Camera *camera, const ESM::Cell* cell) :

mWater = mSceneManager->createEntity("water");
mWater->setVisibilityFlags(RV_Water);
mWater->setMaterialName("Examples/Water0");

mWater->setMaterial(createMaterial());

mVisibilityFlags = RV_Terrain * Settings::Manager::getBool("reflect terrain", "Water")
+ RV_Statics * Settings::Manager::getBool("reflect statics", "Water")
Expand Down Expand Up @@ -163,4 +164,31 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt)
}
}

Ogre::MaterialPtr Water::createMaterial()
{
MaterialPtr mat = MaterialManager::getSingleton().create("Water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mat->removeAllTechniques();

// fallback technique without shaders
// also used for minimap (because it can't have reflecting water)
Technique* old = mat->createTechnique();
old->setSchemeName("Map");
Pass* oldpass = old->createPass();
oldpass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
oldpass->setDepthWriteEnabled(false);
oldpass->setDiffuse(0,0,0,1);
oldpass->setSelfIllumination(0.6, 0.7, 1.0);
oldpass->setAmbient(0,0,0);
TextureUnitState* oldtus = oldpass->createTextureUnitState();
std::string textureNames[32];
for (int i=0; i<32; ++i)
{
textureNames[i] = "textures\\water\\water" + StringConverter::toString(i, 2, '0') + ".dds";
}
oldtus->setAnimatedTextureName(textureNames, 32, 2);
oldtus->setTextureScale(0.1, 0.1);
oldtus->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.7);
return mat;
}

} // namespace
2 changes: 2 additions & 0 deletions apps/openmw/mwrender/water.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace MWRender {
void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);

Ogre::MaterialPtr createMaterial();

Ogre::RenderTarget* mReflectionTarget;
Ogre::RenderTarget* mRefractionTarget;

Expand Down
4 changes: 1 addition & 3 deletions files/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
project(resources)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/caustic_0.png "${OpenMW_BINARY_DIR}/resources/water/caustic_0.png" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Example_Fresnel.cg "${OpenMW_BINARY_DIR}/resources/water/Example_Fresnel.cg" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Example_FresnelPS.asm "${OpenMW_BINARY_DIR}/resources/water/Example_FresnelPS.asm" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/GlassFP.cg "${OpenMW_BINARY_DIR}/resources/water/GlassFP.cg" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/GlassVP.cg "${OpenMW_BINARY_DIR}/resources/water/GlassVP.cg" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/perlinvolume.dds "${OpenMW_BINARY_DIR}/resources/water/perlinvolume.dds" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Water02.jpg "${OpenMW_BINARY_DIR}/resources/water/Water02.jpg" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.compositor "${OpenMW_BINARY_DIR}/resources/water/water.compositor" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/waves2.dds "${OpenMW_BINARY_DIR}/resources/water/waves2.dds" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/Examples-Water.material "${OpenMW_BINARY_DIR}/resources/water/Examples-Water.material" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/water.material "${OpenMW_BINARY_DIR}/resources/water/water.material" COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/water/WaterNormal1.tga "${OpenMW_BINARY_DIR}/resources/water/WaterNormal1.tga" COPYONLY)
116 changes: 0 additions & 116 deletions files/water/Example_Fresnel.cg

This file was deleted.

72 changes: 0 additions & 72 deletions files/water/Example_FresnelPS.asm

This file was deleted.

Loading

0 comments on commit b3a186e

Please sign in to comment.