Tracking Camera and Wrong Reflection

Illidanz

10-12-2008 12:53:53

Hi, I have a couple of problems with Hydrax and I'll try to explain them. My english is not the best but I hope you understand

1) My main camera node is attached to another node like this
mCameraNode->setAutoTracking(true, mTargetNode);
I'm sure that I'm updating hydrax AFTER all the inputs and possible changes (by physics for example), but still the water doesn't follow the camera when i'm turning it, see that screenshot as an example.


The only thing that I'm doing in the main loop after the hydrax update is this:
Ogre::WindowEventUtilities::messagePump();
root->renderOneFrame();


2) This is best explained by the screenshot:


3) I've noticed another problem. If i go a lot high (let's say Y = 2000.0), I can se a circle in the horizon in the middle of the water. I can see this circle also at Y = 100.0, but it's almost not noticeable (you can see it in the previous screenshot). Screenshot:


I can't attach files, so I'll paste the hydrax cfg
#Hydrax cfg file.

#Hydrax version field
HydraxVersion=0.4.0

#Main options field
<vector3>Position=-5000x100x-5000
<float>PlanesError=10.5
#Shader mode: 0=HLSL, 1=CG, 2=GLSL
<int>ShaderMode=0
<float>FullReflectionDistance=1e+011
#<float>FullReflectionDistance=99999997952.0
<float>GlobalTransparency=0
<float>NormalDistortion=0.075
#<vector3>WaterColor=0.126652x0.628499x0.985075
<vector3>WaterColor=0.058209x0.535822x0.679105

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

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

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

#Depth parameters
<float>DepthLimit=90

#Smooth transitions parameters
<float>SmoothPower=5

#Caustics parameters
<float>CausticsScale=80
<float>CausticsPower=10.5
<float>CausticsEnd=0.8

#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=2.9
<bool>PG_ChoppyWaves=false
<int>PG_Complexity=150
<float>PG_Elevation=50
<bool>PG_ForceRecalculateGeometry=false
<bool>PG_Smooth=false
<float>PG_Strength=10

#Noise options
Noise=Perlin

<int>Perlin_Octaves=8
<float>Perlin_Scale=0.185
<float>Perlin_Falloff=0.49
<float>Perlin_Animspeed=1.4
<float>Perlin_Timemulti=1.27
<float>Perlin_GPU_Strength=2
<vector3>Perlin_GPU_LODParameters=0.5x50x150000

Illidanz

11-12-2008 13:05:21

Update:

I've tried to set the Y of the water to 0, so now it's
<vector3>Position=-5000x0x-5000

Problems 2 and 3 are disappeared and everything works flawlessy. No more circle at horizon, and reflections are ok

There's any way to fix this? I have a couple of cases where I would like to set it to something more than 0, but for now I'm ok

Other infos I've not wrote in the post before:
Using Ogre 1.6.0 final with Hydrax 0.4

--- EDIT - Update2
I applied the fix in that thread: http://www.ogre3d.org/phpBB2addons/view ... c&start=15
and problem 2 disappeared also with water Y = 100

Problems 1 and 3 are still there though

Xavyiy

11-12-2008 17:21:58

Sorry for not reply quickly, i've to check some things on Hydrax code and post my opinion about the first and third problem.

Xavi

Nodrev

11-12-2008 19:11:55

For the first problem, i had the same problem before cause i was updating hydrax in the frameEnded event, instead of frameStarted.
The second problem is explained in another post, it's due to the order the render group are agenced.

Illidanz

11-12-2008 19:24:58

For the first problem, i had the same problem before cause i was updating hydrax in the frameEnded event, instead of frameStarted.
I'm not using exampleapplication or frame listeners but my own loop, and I'm updating Hydrax before rendering so I think it's like frameStarted

That's my code, maybe I'm doing something wrong (Not the actual code, but just to let you understand)

while(loop)
{
//Update all other modules, like input, physx, particles, etc ...
//Update Hydrax ...

Ogre::WindowEventUtilities::messagePump();
root->renderOneFrame();

delta = timer.getMilliseconds() / 1000.0f;
timer.reset();
}

Illidanz

29-12-2008 09:47:19

Any update on this? I still have the same problems

khawkins

01-01-2009 23:46:07

I'm actually seeing all of the same issues and have the same setup where I'm running my own loop.

My terrain is a modified version of the ETM, and I'm running Caelum (HEAD from sometime in October/November timeframe). I've followed all the directions here on this forum for Caelum integration, but there's still artifacts. I'm positive my camera is updated prior to Hydrax.

I've also noticed that if I change the water height via the Hydrax::setPosition() function, then more often than not the water plane rendering stops working correctly when I move the camera (also don't like that I have to move the camera to see any of my runtime settings changes). Typically it only renders as long as the camera is facing the direction it was in when I changed the height.

For #1, it isn't that the water isn't following, but that something is wrong with the depth map and it's getting clipped out. I *think* it's a Caelum issue, though, when you are using a small near clip plane and a large far clip plane value. If you load up your system with Caelum only, no stencil shadows to prevent infinite far clip, and a 1.0 near clip, 99999.0 far clip (as suggested here in the Hydrax forum - I strongly disagree with this as a "fix"), then rotate the camera around to view the skydome, and you'll see flashes. I'm not entirely sure why other than that I've seen this with Caelum before where the near/far clip plane values are extremely different in size. I actually never noticed this until I turned off stencil shadows, which I use by default for most testing since I haven't implemented the texture shadows.

Anyway, I had to turn off stencil shadows because of Hydrax. It would be nice if this wasn't a Hydrax requirement.

For #2, my terrain is a modification of ETM, and since it's not an Ogre::Entity like the Ogre TerrainManager I added the depth technique - but this didn't fix the problem either. I've tried several tweaks to the materials, but no luck yet. I'm not entirely sure why it's happening.

For #3, as mentioned, any Hydrax setPosition() changes seem to screw up the system unless it's done immediately at load time - problem is I can and want to modify such properties at runtime. But even then, after seeing this thread I set the Position.Y to 100.0 and saw the same "ring" as shown in the screenshot.

I also see issues with the Caelum sun and moon when they are setting/rising around the horizon and my camera view is high up in the sky. I think it's related to Caelum's CameraBoundElements and Hydrax's water height not being coordinated, so that may be something that needs to be handled on the engine side.

Anyway, just wanted to let the OP know he/she is not alone. I have the same problems and more.

Azatoth

02-01-2009 12:52:13

Regarding your issues with how the hydrax projected grid is always lagging one frame behind, this is caused by the way Ogre tries to cache node positions and only update them when necessary. Unfortunately it can in some cases result in the derived orientation or position of a node to be incorrect.
Whenever the whole node tree is traversed the correct positions and orientations will be calculated, but unfortunately that traversal happens after the frameStarted events, and thus you get this effect.

I'm guessing that you're moving or reorienting a Node instead of the actual camera. (That's at least how my error was caused.)
The solution as I've found it is to manually call

theNode->_update(true, false);

after you've moved your node. This will force a recalculation of all derived positions and orientations.
Note that I first tried with calling Node::needUpdate(...) on the affected nodes, but that didn't help.

Illidanz

02-01-2009 20:44:17

Thanks for the answers.

@Azatoth: that indeed was the problem. I've added that line of code after all the node modifications and it worked, so it wasn't hydrax fault :)
@khawkins: have you tried what I've mentioned in one of my previous posts? It fixed problem #2 for me
And yes, I have the same problems when I move water, and the annoying circle is still there

Thanks again