Water in base game - covers everything (solved)

Howdy!



I've managed to get water working in basegame, I'm having 2 models, skybox and a water on my scene now, it's getting late and I have to go to wake up early, so I thought I'll ask what might be the reason of error I'm getting and try to fixing it tomorrow after reading your ideas of what I did wrong.

So, the problem is that water covers everything in scene, as if everything was rendered and then the water at top of everything.

What might be wrong? I'll try your suggestions as soon as I wake up :smiley:

Thanks & good night!

You can try rendering the water before everything else by using render passes, or just attach the water to the root node before everything else.



Some code or a simple test showing your problem will get you more specific and useful help.

I can just picture the post tomorrow . . .



  nymon appeared to me in a dream and explained everything  :smiley:

Hah I wish!

Anyway, before I post any code I'll try to solve this by myself, so far my water looks great! But entire geometry except for skybox dissapeared :frowning:


JOC said:

I can just picture the post tomorrow . . .

   nymon appeared to me in a dream and explained everything  :D

If I were to make a guess I'd say either your Zbuffer state is set up incorrectly or the water height (i.e. WaterRenderPass::setWaterHeight()) is set too high.

That was my guess as well, but it wasnt that, seems that my problem (as problem of most of people trying to make water) was incorrect order of node attachements, passes etc.

I managed to get it working after some hours but I felt like a blind man trying to do puzzles. I'll post how I got it working once I'm back to dorm in case anyone finds it useful.

Thanks & cheers!



Edit.

Okay, that's the order I used:


  try
        {

            GameTaskQueueManager.getManager().update(new Callable<Object>()
            {

                @Override
                public Object call() throws Exception
                {
                    waterEffectRenderPass = new WaterRenderPass(cam, 4, false, true);
                    bloomRenderPass = new BloomRenderPass(cam, 4);
                    motionBlurRenderPass = new MotionBlurRenderPass(cam);
                    rPass = new RenderPass();
                    return null;
                }
            }).get();
        } catch (InterruptedException e)
        {
            e.printStackTrace();
        } catch (ExecutionException e)
        {
            e.printStackTrace();
        }

 waterEffectRenderPass.setWaterPlane(new Plane(new Vector3f(0.0f, 0.0f, 1.0f), 0.0f));
 waterQuad = new Quad("waterQuad", 100, 100);
  FloatBuffer normBuf = waterQuad.getNormalBuffer();
        normBuf.clear();
        normBuf.put(0).put(0).put(1);
        normBuf.put(0).put(0).put(1);
        normBuf.put(0).put(0).put(1);
        normBuf.put(0).put(0).put(1);

 _passManager = new BasicPassManager();
 rootNode.attachChild(waterQuad);
 waterEffectRenderPass.setWaterEffectOnSpatial(waterQuad);
        waterEffectRenderPass.addReflectedScene(shipNode);
        waterEffectRenderPass.addReflectedScene(bg);
        waterEffectRenderPass.addReflectedScene(bg_node);
   waterEffectRenderPass.setSkybox(m_skybox);
        _passManager.add(waterEffectRenderPass);
   rPass.add(rootNode);
        _passManager.add(rPass);
   rootNode.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
        System.out.println("Loader: " + Main.loader);