HydraX & Ogre 1.9 - Water completely opaque

xjum52

07-08-2014 20:15:46

I have compiled "HydraX 0.5.4"/Demo1 after updating its use of terrain in addition to integrating HydraX into my own project. In both, everything works as it should except the ability to see through the water.

The following image illustrates what I am talking about,
i.imgur.com/dHzImHL.jpg

Any suggestions are welcome, but really, I just want to know if anyone using Ogre 1.9 has been able to implement HydraX entirely & successfully, or if it is entirely incompatible. Thanks in advance.

Max98

01-09-2014 01:54:38

Hello there, i had the same problem and i've been seaching for a long time and i found the problem.
There are two ways to fix it:
1/ Add this to your hdx file and set the correct value for your needs

<float>DistLimit=90


2/ Use the ->setDistLimit() code sided way.

This might be late for you, but might save headaches like the ones i had.

xelfe

05-10-2014 04:48:33

I have the same problem but the DistLismit trick dont work. Without depth technique the water is not opaque but its like to be too bright. When I add the depth technique the water is opaque. I really dont understand what happen. This is the code that I use for my hydrax class;


/*
* \file GraphicsWater.cpp
*
* Created on: \date 25 sept. 2014
* Author: \author joda xelfe
* \brief : Fichier source de la classe GraphicsWater
*/
#include "GraphicsWater.h"

namespace Engine {

GraphicsWater::GraphicsWater(Ogre::SceneManager *sm, Ogre::Root* m_pRoot, Ogre::RenderWindow* m_pRenderWnd) {
m_pHydrax = 0;
m_pSceneMgr = sm;
this->m_pRoot = m_pRoot;
this->m_pRenderWnd = m_pRenderWnd;
m_pCamera = m_pSceneMgr->getCamera("CamPrincipal");

}

GraphicsWater::~GraphicsWater() {
// TODO Auto-generated destructor stub
}

void GraphicsWater::initHydrax() {

LogManager::getInstance()->setLogMessage("Initialisation de Hydrax", NORMAL);

// Create Hydrax object
m_pHydrax = new Hydrax::Hydrax(m_pSceneMgr, m_pCamera, m_pRenderWnd->getViewport(0));

// Create our projected grid module
Hydrax::Module::ProjectedGrid *mModule
= new Hydrax::Module::ProjectedGrid(// Hydrax parent pointer
m_pHydrax,
// Noise module
new Hydrax::Noise::Perlin(/*Generic one*/),
// Base plane
//Ogre::Plane(Ogre::Vector3(0, 1, 0), Ogre::Vector3(0, 0, 0)),
Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Real(0.0f)),
// Normal mode
Hydrax::MaterialManager::NM_VERTEX,
// Projected grid options
Hydrax::Module::ProjectedGrid::Options(/*264 /*Generic one*/));

// Set our module
m_pHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));

// Load all parameters from config file
// Remarks: The config file must be in Hydrax resource group.
m_pHydrax->loadCfg("Hydrax.hdx");

// Create water
m_pHydrax->create();

m_pHydrax->getRttManager()->addRttListener(new GraphicsHydraxRttListener(m_pHydrax));

}

void GraphicsWater::addDepthTechnique(Ogre::StringVector materialNames)
{
for(unsigned int i = 0;i < materialNames.size();i++)
{
m_pHydrax->getMaterialManager()->addDepthTechnique(static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(materialNames))->createTechnique());
}
}


void GraphicsWater::update(float dt)
{
if(m_pHydrax)
m_pHydrax->update(dt);
}

} /* namespace Engine */


and the materialNames is inerith from the sceneloader;

Ogre::StringVector GraphicsSceneLoader::getMaterialNames()
{
Ogre::StringVector list;
Ogre::String matName;

if (!mTerrainGroup)
return list;

Ogre::TerrainGroup::TerrainIterator it = mTerrainGroup->getTerrainIterator();

while (it.hasMoreElements())
{
Ogre::TerrainGroup::TerrainSlot *terrain = it.getNext();
if (terrain->instance && terrain->instance->isLoaded())
{
matName = terrain->instance->getMaterialName();
if (matName != "")
list.push_back(matName);
}

}

return list;
}


Anybody have a idea ? Things is that I use a terrain from Ogitor so I cannot get easily the material of that terrain but I think that my getMaterialName() method work great and I dont think that the problem is there. Any help would be nice !

Anthea

27-12-2014 10:01:31

Hey xelfe,

did you solve that issue? Xavyiy posted in this old thread that you don't add the terrain Technique to Hydrax,
but you add the hydrax depth technique to your terrain material. So it's reverse. I am not sure how to do so, as I asked here.

Best wishes,
Anthea