Tuesday, April 14, 2009

Hydrax + Caelum

I have integrated the Hydrax 0.5 and Caelum 0.4 in my project.  Thanks for Xavyiy and Cdleonard's great work. And the topic HOW TO: Integrate Hydrax V0.4 with Caemum in Ogre forum also give me a great favor.
First some screen shot of my recenly work. All of them are rendered by OpenGL and CG. Some detail information can be found in my previous post.

Except for the problems metioned in forum topic, I also solved some new problems
1. I found PointStarFiled can not reflect on ocean surface. This problem can be solved by changing material StarPoint's atrribute cull_hardwar as none.

material Caelum/StarPoint
{
...........................

            // Works with default culling:
            cull_hardware clockwise
            
...........................
}

2. I'm very pleased with the visual effect of Hydrax. However, using Hydrax has been a very large perfomance hit for us.  I test the project grid with perlin noise. I found noise calculation is the bottleneck of the CPU. So I excute void Perlin::_calculeNoise() in another thread. The modification is very small, only take care about memory protection is enough.

3. The water doesn't follow the camera expecially when rotate the camera horizontally, see the screeshot as example. 

The project grid's lagging can be solved by streching the projected water area. The project area is determinde by four conner point, so the code is changed as red color shows:
bool ProjectedGrid::_renderGeometry(const Ogre::Matrix4& m,const Ogre::Matrix4& _viewMat, const Ogre::Vector3& WorldPos)
{
t_corners0 = _calculeWorldPosition(Ogre::Vector2( 0.0f, 0.0f),m,_viewMat);
t_corners1 = _calculeWorldPosition(Ogre::Vector2(+1.0f, 0.0f),m,_viewMat);
t_corners2 = _calculeWorldPosition(Ogre::Vector2(-0.2f,+1.0f),m,_viewMat);
t_corners3 = _calculeWorldPosition(Ogre::Vector2(+1.2f,+1.0f),m,_viewMat);
                ........................
       }

7 comments:

  1. Thank you for your work.
    I am trying to speed up hydrax also.
    Could you post some code example on how you multithreaded perlin noise?
    I would appreciate it a lot.
    Thank you.

    ReplyDelete
  2. For ironas:
    1. Declare a Base Class "TimerListener" for managing Window Multimedia Timer.
    2. Make the Hydrax::Noise::Perlin derived frome the class "TimerListener".
    3. Move the function Perlin::_calculeNoise() from Perlin::update(const Ogre::Real &timeSinceLastFrame) to timer callback funtion TimeListener::Timer_Event().
    4. Don't forget the data protection.

    ReplyDelete
  3. For ironas:
    Could you give me your email, i'll send the source of TimerListener to you.

    ReplyDelete
  4. Hi Little Bin.
    Thank you very much for replying!

    My mail is elias_ts (at) hotmail.com

    Thank you again!

    ReplyDelete
  5. hello, thanks for your great work. i am following your blogentries about caelum and hydrax and they are very interesting for me. it helped me dealing with the exact same problems that i had!

    the only problem that is left over is the speeding up (threading) of the perlin noise.
    could you explain this a bit more how you did it? this would be very kind! thanks in advance

    my mail is "suoch /*at*/ gmx.at"

    ReplyDelete
  6. COuld you post code to me too! my email is amerkoleci /*at*/ hotmail.it

    Thanks

    ReplyDelete
  7. Hi can u please provide me with complete code as I'm having trouble with integration. I want rain in our project and water be accumulated as result of rain. I'm using caelum for rain and snow effects.

    Thanks in advanc

    ReplyDelete