problem with depth

nargil

25-03-2009 21:28:11

I can't get depth working

things far away are better visible than the one that are near (like the robot)

PS. The sword does not have the depth technique. Only the ground(terrain), robot, and grass has;

there is no smooth transition with the terrain


void EnviromentManager::createHydrax()
{
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Hydrax");
GameEngine* engine = GameEngine::getSingletonPtr();
mHydrax = new Hydrax::Hydrax(mEngine->getSceneMgr(), mEngine->getCamera(), mEngine->getWindow()->getViewport(0));

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


// Set our module
mHydrax->setModule(static_cast<Hydrax::Module::Module*>(mModule));
mHydrax->getRttManager()->setReflectionDisplacementError(1.8);
mHydrax->setUnderwaterCameraSwitchDelta(-.2);

// Load all parameters from config file
// Remarks: The config file must be in Hydrax resource group.
// All parameters can be set/updated directly by code(Like previous versions),
// but due to the high number of customizable parameters, Hydrax 0.4 allows save/load config files.
mHydrax->loadCfg("dembol3.hdx");
#if _DEBUG
Hydrax::Module::ProjectedGrid::Options opt = mModule->getOptions();
opt.Complexity = 16;
mModule->setOptions(opt);
#else
Hydrax::Module::ProjectedGrid::Options opt = mModule->getOptions();
opt.Complexity =64;
mModule->setOptions(opt);
#endif

mHydrax->getMaterialManager()->addDepthTextureTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("grass_GrassVS_anim_0_2_0.4_vp"))
->createTechnique(), "grass.png", "a");

// Create water
mHydrax->create();
Ogre::Vector3 tmpCol = mHydrax->getWaterColor();
mWaterColor.a = 1;
mWaterColor.r = tmpCol.x;
mWaterColor.g = tmpCol.y;
mWaterColor.b = tmpCol.z;
mWaterColor.getHSB(&baseHue,&baseSaturation,&baseBrightness);

}

bool EnviromentManager::frameStarted( double FrameTime )
{
#if MYHYDRAX
if(mEngine->getWindow()->isActive())
{
if(!CaelumAdded)
{
mEngine->getRoot()->addFrameListener(mCaelumSystem);
CaelumAdded=true;
}
#if CAELUM
Ogre::Real jdn = mCaelumSystem->getJulianDay();
Ogre::Vector3 dir = mCaelumSystem->getSunDirection(jdn);
Ogre::ColourValue sunColor = mCaelumSystem->getSunLightColour(jdn,dir);
mHydrax->setSunPosition(mCaelumSystem->getSun()->getSceneNode()->getPosition());
mHydrax->setSunColor(Ogre::Vector3(sunColor.r,sunColor.g,sunColor.b));
sunColor = mEngine->getSceneMgr()->getAmbientLight();
Ogre::Real tmp, bright;
sunColor.getHSB(&tmp,&tmp,&bright);
mWaterColor.setHSB(baseHue,baseSaturation,std::min(baseBrightness,bright));
mHydrax->setWaterColor(Ogre::Vector3(mWaterColor.r,mWaterColor.g,mWaterColor.b));
#endif
mHydrax->update(FrameTime);
}
else
{
mEngine->getRoot()->removeFrameListener(mCaelumSystem);
CaelumAdded=false;
}
#endif
return true;
}


Tried different hdx files. Here is the one the screens were taken with
#Hydrax cfg file.

#Hydrax version field
HydraxVersion=0.5.0

#Main options field
<vector3>Position=1500x2x1500
<float>PlanesError=0.5
#Shader mode: 0=HLSL, 1=CG, 2=GLSL
<int>ShaderMode=1
<float>FullReflectionDistance=1e+011
<float>GlobalTransparency=0
<float>NormalDistortion=0.075
<vector3>WaterColor=0.149x0.1922x0.3569

#Components field
Components=Sun|Foam|Depth|Smooth|Underwater|UnderwaterReflections|UnderwaterGodRays

#Sun parameters
<vector3>SunPosition=0x100x0
<float>SunStrength=1.75
<float>SunArea=70
<vector3>SunColor=1x0.9x0.6

#Foam parameters
<float>FoamMaxDistance=7.5e+007
<float>FoamScale=0.0075
<float>FoamStart=0
<float>FoamTransparency=0.5

#Depth parameters
<float>DepthLimit=1

#Smooth transitions parameters
<float>SmoothPower=5

#God rays parameters
<vector3>GodRaysExposure=0.76x2.46x2.29
<float>GodRaysIntensity=0.015
<float>GodRaysSpeed=5
<int>GodRaysNumberOfRays=100
<float>GodRaysRaysSize=0.03
<bool>GodRaysIntersections=false

#Rtt quality field(0x0 = Auto)
<size>Rtt_Quality_Reflection=0x0
<size>Rtt_Quality_Refraction=0x0
<size>Rtt_Quality_Depth=0x0
<size>Rtt_Quality_URDepth=0x0
<size>Rtt_Quality_GPUNormalMap=0x0

#Module options
Module=ProjectedGridVertex

<float>PG_ChoopyStrength=3.175
<bool>PG_ChoppyWaves=true
<int>PG_Complexity=128
<float>PG_Elevation=10.1
<bool>PG_ForceRecalculateGeometry=true
<bool>PG_Smooth=false
<float>PG_Strength=3.5

#Noise options
Noise=Perlin

<int>Perlin_Octaves=8
<float>Perlin_Scale=0.051045
<float>Perlin_Falloff=0.94
<float>Perlin_Animspeed=0.2
<float>Perlin_Timemulti=1.27
<float>Perlin_GPU_Strength=1000.7
<vector3>Perlin_GPU_LODParameters=0.05x50x150000



materials


material terrain
{
technique Default
{
pass Main
{
ambient 0.588235 0.588235 0.588235 1
specular 0.0 0.0 0.0 0 0.0

texture_unit
{
texture_alias diffuse
texture ground051.jpg
}
}

}
technique HydraxDepth
{
scheme HydraxDepth
pass
{
lighting off
texture_unit
{
colour_op_ex modulate src_manual src_current 0 0 0
}
}
}

}

material Examples/Robot
{

// Software blending technique
technique
{
pass
{

texture_unit
{
texture r2skin.jpg
}
}
}
technique HydraxDepth
{
scheme HydraxDepth
pass
{
lighting off
texture_unit
{
colour_op_ex modulate src_manual src_current 0 0 0
}
}
}
}

nargil

26-03-2009 00:30:05

I've fixed it by adding ingame

mHydrax->getMaterialManager()->addDepthTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("terrain"))
->createTechnique());


instead of the material files.
The same way as for the grass, and it looks good now.


Do I have to do it in the code ? Can't it be in the materials ?