Page 2 of 3

Re: [2.1] Ocean

Posted: Fri Oct 13, 2017 11:50 am
by xrgo
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.
Yes! I actually took the ripple effect and other details from there. Thanks!

Re: [2.1] Ocean

Posted: Tue Oct 24, 2017 6:58 pm
by xrgo
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:

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);
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?

Re: [2.1] Ocean

Posted: Tue Oct 24, 2017 7:10 pm
by dark_sylinc
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)
Could be that whatever VR voodoo is going on is not being accounted for the clipping plane, and thus the clipping plane is cutting off geometry at a random location.

Re: [2.1] Ocean

Posted: Tue Oct 24, 2017 7:56 pm
by xrgo
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

Re: [2.1] Ocean

Posted: Fri Nov 03, 2017 10:34 am
by 123iamking
Sorry but I have difficulty in setting up this 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 :oops:
    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 );
    
I have separated Terrain project from OGRE solution with hope to learn how to control terrain.
Here is my attempt so far trying to add the Ocean. Please help :(

Re: [2.1] Ocean

Posted: Sat Nov 04, 2017 6:58 pm
by xrgo
123iamking 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
probeTexture is jut a cubemap Ogre::TexturePtr you can load a file o capture it from scene
123iamking wrote: Fri Nov 03, 2017 10:34 am I try to find object similar to mHlmsOcean but I haven't found it yet
mHlmsOcean is:

Code: Select all

    mHlmsOcean = OGRE_NEW Ogre::HlmsOcean( archiveOcean, &library );
see the fisrt post, or you can later obtain it like this:

Code: Select all

Ogre::HlmsOcean* mHlmsOcean = static_cast<Ogre::HlmsOcean*>( Ogre::Root::getSingletonPtr()->getHlmsManager()->getHlms( Ogre::HLMS_USER2 ) );
123iamking wrote: Fri Nov 03, 2017 10:34 am Also there is oceanData.mOcean, I just replace this with mOcean and hope it work
yes sorry, it should work

Re: [2.1] Ocean

Posted: Mon Nov 06, 2017 4:10 am
by 123iamking
Thank xrgo, I don't have compile error anymore :D
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);
But now I got run-time error :oops:
Assertion failed!

Program: ...\bin\Debug\TestOcean.exe
File: ...\src\Ocean\Hlms\OgreHlmsOcean.cpp
Line: 747

Expression: (size_t)(passBufferPtr - startupPtr) * 4u == mapSize
And I update the code into this project

it is so diddly doodly hard :evil:

Re: [2.1] Ocean

Posted: Wed Apr 11, 2018 10:23 pm
by Lax
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:

Code: Select all

23:21:30: GLSL compile log: 3221226112VertexShader_vs
0(144) : error C1008: undefined variable "passBuf"
...
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

Re: [2.1] Ocean

Posted: Wed Apr 11, 2018 11:30 pm
by xrgo
ohh I am really sorry, please wait until tomorrow and I will look in to it =) I am just leaving the office

Re: [2.1] Ocean

Posted: Thu Apr 12, 2018 3:28 pm
by xrgo
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:

Code: 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);
		}
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 file

Re: [2.1] Ocean

Posted: Thu Apr 12, 2018 9:15 pm
by Lax
Hi,

thanks for the response and the hint. I will take a breath and wait :D .

Regards
Lax

Re: [2.1] Ocean

Posted: Thu Apr 12, 2018 9:37 pm
by dark_sylinc
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)

Re: [2.1] Ocean

Posted: Tue Nov 13, 2018 4:57 pm
by Hrenli
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.

Re: [2.1] Ocean

Posted: Wed Nov 14, 2018 12:12 am
by xrgo
Hello! At first I tried to use the displacement generated by blender's ocean modifier, it was textures like this one:
Image
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!!!!

Re: [2.1] Ocean

Posted: Wed Nov 14, 2018 11:55 am
by Hrenli
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?

Re: [2.1] Ocean

Posted: Wed Nov 14, 2018 1:26 pm
by xrgo
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

Re: [2.1] Ocean

Posted: Mon Dec 17, 2018 4:03 pm
by xrgo
xrgo 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:

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);
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.
Hello, can this fix be integrated in ogre? in my experience doesn't break anything in mono, so no if needed

Re: [2.1] Ocean

Posted: Mon Dec 17, 2018 6:12 pm
by dark_sylinc
xrgo wrote: Mon Dec 17, 2018 4:03 pm
xrgo 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:

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);
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.
Hello, can this fix be integrated in ogre? in my experience doesn't break anything in mono, so no if needed
PR or it didn't happen :lol:
I'm lacking a lot of context. I don't know where to add that.

Re: [2.1] Ocean

Posted: Sun Feb 17, 2019 11:17 pm
by xrgo
dark_sylinc wrote: Mon Dec 17, 2018 6:12 pm PR or it didn't happen :lol:
I'm lacking a lot of context. I don't know where to add that.
included in this PR https://bitbucket.org/sinbad/ogre/pull- ... hadow/diff

Re: [2.1] Ocean

Posted: Fri Dec 27, 2019 11:41 am
by Lax
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

Re: [2.1] Ocean

Posted: Sat Dec 28, 2019 8:58 pm
by xrgo
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

Re: [2.1] Ocean

Posted: Sat May 09, 2020 10:09 pm
by Lax
Hi xrgo,

I just wanted to ping you, if you have any progress porting Ocean to Ogre 2.2?

Best Regards
Lax

Re: [2.1] Ocean

Posted: Sun Sep 19, 2021 12:32 pm
by Lax
Hi all,

is there any updated Ocean implemtation? Also Form directX shading?

Best regards
Lax

Re: [2.1] Ocean

Posted: Sun Jul 17, 2022 5:58 pm
by Lax

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


Re: [2.1] Ocean

Posted: Sat Aug 13, 2022 4:21 am
by HulkRomain

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.
Image

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.