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 166
Re: [2.1] Ocean
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 166
Re: [2.1] Ocean
Hello!! I am integrating planar reflections into my ocean, it was working great in mono, but in stereo VR I noticed a few problems:
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.
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?
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?
Last edited by xrgo on Mon Mar 05, 2018 3:22 pm, edited 1 time in total.
- dark_sylinc
- OGRE Team Member
- Posts: 4596
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 970
- Contact:
Re: [2.1] Ocean
Planar Reflections has a few requirements:
- 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 166
Re: [2.1] Ocean
thanks, I am doing it like unlit, just passing the texture.
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
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 3
Re: [2.1] Ocean
Sorry but I have difficulty in setting up this ocean.
Here is my attempt so far trying to add the Ocean. Please help
- 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 166
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 amI 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 amI 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 amAlso 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 3
Re: [2.1] Ocean
Thank xrgo, I don't have compile error anymore
Here is my update code:
But now I got run-time error
it is so diddly doodly hard

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

-
- Orc
- Posts: 493
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 30
Re: [2.1] Ocean
Hi,
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:
Is It because Ocean is no more up to date with ogre?
Or has somebody an example how to use it properly?
Thanks in advance
Regards
Lax
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 166
Re: [2.1] Ocean
ohh I am really sorry, please wait until tomorrow and I will look in to it =) I am just leaving the office
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 166
Re: [2.1] Ocean
I just tried and its working fine with me, before looking deeply in to your specific problem, I am going to try to integrate/pullrequest the Ocean as an official sample =), please hold on a little bit
btw:
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); }
-
- Orc
- Posts: 493
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 30
Re: [2.1] Ocean
Hi,
thanks for the response and the hint. I will take a breath and wait
.
Regards
Lax
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

- dark_sylinc
- OGRE Team Member
- Posts: 4596
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 970
- Contact:
Re: [2.1] Ocean
A few tips: Based on experience with other Hlms extensions, it looks like the problem lies in how the Hlms Library (the pieces) was initialized. Which would explain why passBuf is an undeclared identifier (there's likely an insertpiece but the piece is never defined due to incorrect initialization)
-
- Halfling
- Posts: 73
- Joined: Tue Jun 14, 2016 12:26 pm
- x 19
Re: [2.1] Ocean
I have a question to xrgo about how he came up with the .dds and as it might be interesting to others I thought I'd ask here.
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.
Green channel in the displacement seems to be answering for the height, but the rest of the data doesn't add up in my head, especially normals (why the image is so one-channeled?)...
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.
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 166
Re: [2.1] Ocean
Hello! At first I tried to use the displacement generated by blender's ocean modifier, it was textures like this one:

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!!!!

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
Thanks for the details! For me the main problem with displacement maps from the ocean modifier was their awkward scale (16 bit floats with way too much black in low areas and in general wave form was different from what I see in blender if I just apply that map as a displacement). Seems like instead of linear function they use squares or whatnot...
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?
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 166
Re: [2.1] Ocean
tangent space normals are usually just two channels, and if you need information in the third channel you can calculate it out of the other 2. The normals texture I generated in blender was a 3 channel png, in after effects when I composited everything I just used 2 channels
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 166
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 pmfirst 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);
- dark_sylinc
- OGRE Team Member
- Posts: 4596
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 970
- Contact:
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 pmfirst 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 166
Re: [2.1] Ocean
included in this PR https://bitbucket.org/sinbad/ogre/pull- ... hadow/diffdark_sylinc wrote: ↑Mon Dec 17, 2018 6:12 pmPR or it didn't happen![]()
I'm lacking a lot of context. I don't know where to add that.
-
- Orc
- Posts: 493
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 30
Re: [2.1] Ocean
Hi,
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
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 166
Re: [2.1] Ocean
Hi! not more progress besides porting it to Ogre 2.2 and hlsl, I am going to try to update the repo with that in the next few days, I have to make sure it works without the context of my engine
-
- Orc
- Posts: 493
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 30
Re: [2.1] Ocean
Hi xrgo,
I just wanted to ping you, if you have any progress porting Ocean to Ogre 2.2?
Best Regards
Lax
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
