Issue With Two Cameras and Reflections/Water effects

Hello I am working on a group project for a class and we are trying to get realistic looking water to work in a game. For this project we have Panda3D opening in two windows.

This is the function that was created for setting up the camera in our World class:

    def setupCamera(self):
        self.myRender2d = NodePath('myRender2d')
        self.myCamera2d = base.makeCamera2d(

We are basically using the code from the Yet another roaming Ralph that has been posted by gskfreenet here.

This is basically all the code for setting up the water taken from that example with minor alteration:

        world.waterNP = render.attachNewNode(maker.generate())
        world.waterNP.setTransparency(TransparencyAttrib.MAlpha )
        world.waterNP.setShader(loader.loadShader( 'shaders/water1.sha' ))
        world.waterNP.setShaderInput('wateranim', Vec4( 0.03, -0.015, 64.0, 0 )) # vx, vy, scale, skip
        # offset, strength, refraction factor (0=perfect mirror, 1=total refraction), refractivity
        world.waterNP.setShaderInput('waterdistort', Vec4( 0.4, 4.0, 0.4, 0.45 ))    

        # Reflection plane
        world.waterPlane = Plane( Vec3( 0, 0, z+1 ), Point3( 0, 0, z ) )
        planeNode = PlaneNode( 'waterPlane' )
        planeNode.setPlane( world.waterPlane )
        # Buffer and reflection camera
        buffer = 'waterBuffer', 512, 512 )
        buffer.setClearColor( Vec4( 0, 0, 0, 1 ) )

        cfa = CullFaceAttrib.makeReverse( )
        rs = RenderState.make(cfa)
        world.watercamNP1 = base.makeCamera( buffer )
        world.watercamNP2 = base.makeCamera( buffer )
        sa = ShaderAttrib.make()
        sa = sa.setShader(loader.loadShader('shaders/splut3Clipped.sha') )

        cam1 = world.watercamNP1.node()
        cam1.getLens( ).setFov( base.camLens.getFov( ) )
        cam1.setInitialState( rs )
        cam1.setTagState('True', RenderState.make(sa)) 
        cam2 = world.watercamNP2.node()
        cam2.getLens( ).setFov( base.camLens.getFov( ) )
        cam2.setInitialState( rs )
        cam2.setTagState('True', RenderState.make(sa)) 

        # ---- water textures ---------------------------------------------
        # reflection texture, created in realtime by the 'water camera'
        tex0 = buffer.getTexture( )
        ts0 = TextureStage( 'reflection' )
        world.waterNP.setTexture( ts0, tex0 ) 
        # distortion texture
        tex1 = loader.loadTexture('textures/water.png')
        ts1 = TextureStage('distortion')
        world.waterNP.setTexture(ts1, tex1)

At the moment the water shows up on the first screen and the reflections for both the first and second screen show up on the first screen. The second screen has neither water nor reflections show up. We’d appreciate it if anyone could shed some light on this issue.

Welcome to the forums! :slight_smile:

Are the windows opened using the same GSG? Can you show us the code you use to open the windows?

I am not entirely sure but I think this was the code used to open the windows.

  wp = WindowProperties()
        wp.setSize(800, 600)
        wp.setOrigin(870, 50) = base.openWindow(props=wp)

And it is from the World classes constructor.

You should try using the same GSG by passing the previous window to base.openWindow, like:

win2 = base.openWindow(props=wp, gsg=win1)

Okay, at the moment trying to implement it and so far have just gotten a third screen duplicating the first screen. How do I specify to only display things to certain windows?

Each window has its own camera; you can find the list of cameras in base.camList. By default, all cameras are parented to the same node (, so they all see the same thing. If you want the windows to look in different directions, or see different things, you can rotate the individual cameras, or parent one of them to a different node.

If you want the windows to look at the same scene but each view it in different states, that’s possible too, though it’s more complicated.