Yes! I actually took the ripple effect and other details from there. Thanks!al2950 wrote:Dont know if you have ever seen this;
https://seblagarde.wordpress.com/2012/1 ... s-effects/
but it is a great series on how to render rain and its effects, might be of help if you do want to take it further.
[2.1] Ocean
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
first they look all wrong, the problem was that I was using setFrustumExtents for my eye cameras, so I added this:
Code: Select all
Ogre::Vector4 frustumExtents;
camera->getFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w );
actorData->reflectionCamera->setFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w, Ogre::FET_PROJ_PLANE_POS);
And the second problem is that I need to omit rendering the ocean in the reflection pass or I get some visual glitches... so I set setVisibilityFlags( 0x00000001 ); on the ocean, and using visibility_mask 0xfffffffe on the PlanarReflectionsReflectiveRenderingNode it solves that problem.
BUT! for some reason when rendering in stereo, the ocean in the right eye is invisible!
If I remove setVisibilityFlags( 0x00000001 ); on the ocean, it shows, the reflecion looks good, but I get the visual glitch;
If I remove passSceneDefRight->mIdentifier = 25001; (and maintain the setVisibilityFlags ) for my right eye, it shows, I get no visual glitch but I get the same reflection from the left eye, which looks very very bad.
So the question is why the ocean is not visible in my right scene render pass?
-
- OGRE Team Member
- Posts: 5476
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1358
Re: [2.1] Ocean
- You can't render the object that uses the reflection (think infinite reflections problem) inside the reflection. Doing so can cause rendering artifacts. I think for PBS reflective surfaces we automatically handled that, but not for the rest (look at the sample carefully).
- A clipping plane prevents objects behind the plane to be rendered in the reflection pass (otherwise objects behind a mirror would appear in the reflection as well)
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
Is there another way I can omit the ocean object from the reflection pass? I can't just simply "move the actor a bit up" since the ocean can have large waves, its not just a plane.
and what about the first problem? I think the if I need should use mFrustumExtentsManuallySet, but its protected. Can you fix it for cameras with setFrustumExtents? please =D
-
- Gremlin
- Posts: 152
- Joined: Sat Aug 12, 2017 4:16 pm
- x 4
Re: [2.1] Ocean
- I try to figure what is reflection probe in Terrain project, but I haven't figured out yet
xrgo wrote: when you have a reflection probe, set it
Code: Select all
Ogre::HlmsOcean* hlmsOcean = static_cast<Ogre::HlmsOcean*>( Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms( Ogre::HLMS_USER2 ) ); hlmsOcean->setEnvProbe( probeTexture );
- I try to find object similar to mHlmsOcean but I haven't found it yet. Also there is oceanData.mOcean, I just replace this with mOcean and hope it work xrgo wrote: create the ocean object
Code: Select all
mOcean = new Ogre::Ocean( Ogre::Id::generateNewId<Ogre::MovableObject>(), &mSceneManager->_getEntityMemoryManager( Ogre::SCENE_STATIC ), mSceneManager, 0, mRoot->getCompositorManager2(), mCamera ); mOcean->setCastShadows( false ); mOcean->create( center, size ); Ogre::SceneNode *oceanNode = mSceneManager->getRootSceneNode( Ogre::SCENE_STATIC ); oceanNode->attachObject( oceanData.mOcean ); Ogre::String datablockName = "testOcean"; mDatablock = static_cast<Ogre::HlmsOceanDatablock*>( mHlmsOcean->createDatablock( datablockName, datablockName, Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec() ) ); mOcean->setDatablock( mDatablock );
Here is my attempt so far trying to add the Ocean. Please help

-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
probeTexture is jut a cubemap Ogre::TexturePtr you can load a file o capture it from scene123iamking wrote: ↑Fri Nov 03, 2017 10:34 am I try to figure what is reflection probe in Terrain project, but I haven't figured out yet
mHlmsOcean is:123iamking wrote: ↑Fri Nov 03, 2017 10:34 am I try to find object similar to mHlmsOcean but I haven't found it yet
Code: Select all
mHlmsOcean = OGRE_NEW Ogre::HlmsOcean( archiveOcean, &library );
Code: Select all
Ogre::HlmsOcean* mHlmsOcean = static_cast<Ogre::HlmsOcean*>( Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms( Ogre::HLMS_USER2 ) );
yes sorry, it should work123iamking wrote: ↑Fri Nov 03, 2017 10:34 am Also there is oceanData.mOcean, I just replace this with mOcean and hope it work
-
- Gremlin
- Posts: 152
- Joined: Sat Aug 12, 2017 4:16 pm
- x 4
Re: [2.1] Ocean

Here is my update code:
Code: Select all
//Create ocean
mOcean = new Ogre::Ocean(Ogre::Id::generateNewId<Ogre::MovableObject>(),
&sceneManager->_getEntityMemoryManager(Ogre::SCENE_STATIC),
sceneManager, 0, root->getCompositorManager2(),
mGraphicsSystem->getCamera());
mOcean->setCastShadows(false);
Ogre::Vector3 center;
center = 0;
Ogre::Vector2 size;
size = 2;
mOcean->create(center, size);
Ogre::SceneNode *oceanNode = sceneManager->getRootSceneNode(Ogre::SCENE_STATIC);
oceanNode->attachObject(mOcean);
Ogre::TexturePtr probeTexture = Ogre::TextureManager::getSingletonPtr()->getByName("oceanData.dds");
if (probeTexture.isNull()) {
probeTexture = Ogre::TextureManager::getSingleton().load("oceanData.dds", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_3D);
}
Ogre::HlmsOcean* hlmsOcean = static_cast<Ogre::HlmsOcean*>(
Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms(Ogre::HLMS_USER2)
);
hlmsOcean->setEnvProbe(probeTexture);
Ogre::String datablockName = "testOcean";
Ogre::HlmsDatablock *datablockOcean = static_cast<Ogre::HlmsOceanDatablock*>(hlmsOcean->createDatablock(datablockName, datablockName, Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec()));
mOcean->setDatablock(datablockOcean);

And I update the code into this projectAssertion failed!
Program: ...\bin\Debug\TestOcean.exe
File: ...\src\Ocean\Hlms\OgreHlmsOcean.cpp
Line: 747
Expression: (size_t)(passBufferPtr - startupPtr) * 4u == mapSize
it is so diddly doodly hard

-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
I would also like to try out the wonderful ocean feature. But I get the same assert. When I deactivate the assert I get further errors:
Code: Select all
23:21:30: GLSL compile log: 3221226112VertexShader_vs
0(144) : error C1008: undefined variable "passBuf"
...
Or has somebody an example how to use it properly?
Thanks in advance
Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
btw:
you're not suppose to use the "oceanData.dds" as the probe, the idea is to use a reflection cubemap, either captured by you in engine or a fileCode: Select all
Ogre::TexturePtr probeTexture = Ogre::TextureManager::getSingletonPtr()->getByName("oceanData.dds"); if (probeTexture.isNull()) { probeTexture = Ogre::TextureManager::getSingleton().load("oceanData.dds", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_3D); }
-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
thanks for the response and the hint. I will take a breath and wait

Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- OGRE Team Member
- Posts: 5476
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1358
Re: [2.1] Ocean
-
- Halfling
- Posts: 73
- Joined: Tue Jun 14, 2016 12:26 pm
- x 19
Re: [2.1] Ocean
So, blender ocean modifier can bake its output into a set of images (displacement, normals and foam separately). The only thing which is more or less clear to me straight away is foam. The displacement and normals - not so much.

So, the question - did you find a description of what on Earth the colors mean there (I've tried to google but failed so far) or manage to guess it yourself?

Update: after staring onto those hdr exrs produced by ocean modifer for half a day I came to conclusion that you most probably baked displacement map from the animation in blender. Still not 100% sure so will leave the question as it was.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean

this includes a displacement in all axis, XYZ as RGB, the vertical axis is obvious (basically a heightmap) but the other two axis are for the choppiness, which is something really importan for the looks. But I failed at using this because there was something that wasn't working... I don't remember very well, but I think it was something to do about problems at tiling the texture. So I decided to use just the vertical axis, but as I mentioned before, choppiness is really important so it looked really bad xD.
I ended up just rendering a heightmap that includes the choppiness, this also have the benefit that I now use just one channel, so it actually doesn't move the vertex horizontally, the choppiness is just a visual effect of the good hightmap.
Using the heightmap I could render a normal map directly in blender using compositor nodes.
And the foam was baked the ocean modifier as you mentioned.
Lastly I composited everything in after effects, to put every map in the corresponding channel (rg normal, b height, a foam), and exported all the frames and converted to volume dds in GIMP ( or photoshop? don't remember)
As you can see is not magic, just a lot of guessing, testing and tweeking.
here is the blend file if you want to check it:
https://www.dropbox.com/s/cl2a95tpztm4v ... blend?dl=0
if you press F12 you will render a frame of the height map, the height map is just an ocean object, with a white shadeless material, and a black mist/fog applied to the scene (the most simple way of making a depth map)
In the compositor node editor in blender... if you connect the Gamma node output in to the Image input of the Composite node you will see the normal map.
The ocean is tiled both on UV coords and time, for tiling the time I used two ocean modifiers and animated the time and scale so they blend nicely
If you want to scroll thought the time I recommend you to decrease the Preview value on the Multires modifier applied to the ocean object.
Cheers!!!!
-
- Halfling
- Posts: 73
- Joined: Tue Jun 14, 2016 12:26 pm
- x 19
Re: [2.1] Ocean
So, yeah, I guessed already that if you see the wave in blender you can just get all the info from there (was a good push for me to finally figure out how to bake displacement maps).
Another question if you don't mind - how you transformed normals to two channels? Just ignored the blue (it's mostly at 1.0 for everything but the choppiest wave tips anyway) or found a way to rescale it properly? I know texconv can create a two channel .dds out of three-colored tangent space image, but maybe there are more convenient tools?
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
Hello, can this fix be integrated in ogre? in my experience doesn't break anything in mono, so no if neededxrgo wrote: ↑Tue Oct 24, 2017 6:58 pm first they look all wrong, the problem was that I was using setFrustumExtents for my eye cameras, so I added this:to the line ~690 of OgrePlanarReflections.cpp, and that fixed it! but I guess I have to wrap it around some if but not sure how.Code: Select all
Ogre::Vector4 frustumExtents; camera->getFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w ); actorData->reflectionCamera->setFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w, Ogre::FET_PROJ_PLANE_POS);
-
- OGRE Team Member
- Posts: 5476
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1358
Re: [2.1] Ocean
PR or it didn't happenxrgo wrote: ↑Mon Dec 17, 2018 4:03 pmHello, can this fix be integrated in ogre? in my experience doesn't break anything in mono, so no if neededxrgo wrote: ↑Tue Oct 24, 2017 6:58 pm first they look all wrong, the problem was that I was using setFrustumExtents for my eye cameras, so I added this:to the line ~690 of OgrePlanarReflections.cpp, and that fixed it! but I guess I have to wrap it around some if but not sure how.Code: Select all
Ogre::Vector4 frustumExtents; camera->getFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w ); actorData->reflectionCamera->setFrustumExtents( frustumExtents.x, frustumExtents.y, frustumExtents.z, frustumExtents.w, Ogre::FET_PROJ_PLANE_POS);

I'm lacking a lot of context. I don't know where to add that.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
included in this PR https://bitbucket.org/sinbad/ogre/pull- ... hadow/diffdark_sylinc wrote: ↑Mon Dec 17, 2018 6:12 pm PR or it didn't happen![]()
I'm lacking a lot of context. I don't know where to add that.
-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
I just wanted to ask if there is any progress with Ocean?
It would be nice, if it could be integrated to Ogre samples.
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Ocean
-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
I just wanted to ping you, if you have any progress porting Ocean to Ogre 2.2?
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
is there any updated Ocean implemtation? Also Form directX shading?
Best regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Gnoll
- Posts: 665
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 64
Re: [2.1] Ocean
Hi dark_sylinc,
are there any plans to integrate ocean to Ogre and samples?
That would form a great combination with the atmosphere component!
Best regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Gnoblar
- Posts: 1
- Joined: Sat Aug 13, 2022 4:01 am
- x 1
Re: [2.1] Ocean
Hello !
I'm a programmer of the sunday but with some effort, i succeeded to port the code for Ogre 2.3. It works also with the 3.0.0unstable.
This is less beautiful than dark_sylinc did but it works.
You can see a picture here.
The code can be downloaded here : https://file.io/wVtGhGSYlvcB
I hope someone who has better experience than me with HLMS and shaders will do better than me, but i wanted to share with you this because it's better than nothing !
Have a good day !
HulkRomain.