Simply reflections?

updateRenderState() ?

Maybe i lost some piece of codeā€¦



that is what i can seeā€¦



yes, if you see characters, theres usualy a updateRenderstate() missing.


wooyay said:

don't do it! You could create a fluctuation in the space-time-continuum!!!

Its all good, als long as you have a Flux Capacitor at hand.

which one of the many i use?



My code:


        reflectRenderPass = new ReflectRenderPass( cam, 4, true, true);
        Quad quad = new Quad("quad", 20, 50);
        reflectRenderPass.setReflectPlane( new Plane( new Vector3f( 0.0f, 0.0f, 1.0f ), 0.0f ) );
        reflectRenderPass.setTangent( new Vector3f( 1.0f, 0.0f, 0.0f ) );
        reflectRenderPass.setBinormal( new Vector3f( 0.0f, 1.0f, 0.0f ) );
              
        reflectRenderPass.setPlaneHeight(0);
              
        Vector3f tmpVec = new Vector3f(0,0,1);
        quad.getLocalRotation().multLocal( tmpVec );
        reflectRenderPass.getNormal().set( tmpVec );

        float dist = reflectRenderPass.getNormal().dot( quad.getLocalTranslation() );      
        reflectRenderPass.setPlaneHeight( dist );
        reflectRenderPass.setReflectEffectOnSpatial(quad);
        quad.updateRenderState();
        rootNode.attachChild(quad);

did you try to call it on the root Node after you attached everything?

at the end of my simpleUpdate() method:



protected void simpleUpdate()

{

        super.simpleUpdate();

        ā€¦

        rootNode.updateRenderState();

}



is't it enough? 

don't call updaterenderstate every update, that's just a performance killerā€¦



have you set the scene to be reflected with setReflectedScene? also the quad should not be part of that reflected scene(graph).

Actually I reflect only the model with the plain in it with



        reflectRenderPass.setReflectedScene(model);



model is a node with the teapot you see in the previous screenshotā€¦

Is better put it in a new "scene" node?

Hey, I know this is a long dead topic, but I'm really frustrated trying to understand how the fragment shader works. Using bits from WaterRenderPass, reflections are working as perfectly as I could have hoped, but I can't make heads or tails of the math. In particular, these three lines in the fragment shader do almost all the work:



vec4 projCoord = viewCoords / viewCoords.q;
projCoord = (projCoord + 1.0) * 0.5;
projCoord.x = 1.0 - projCoord.x;



My current understanding is that the viewCoords are the position on the screen. But the way this works it appears that the projCoords will always be the upper-right texture coordinates and then the x coordinate is flipped around the middle, but why would this correctly map the texture? It the reflecting plane is on the left half of the screen, shouldn't the corresponding points in the texture indeed be on the right half? And shouldn't some of the texture coordinates be on the bottom half of the texture? Am I incorrect in believing both the screen and the texture coordinates to be from 0 to 1 with (0,0) in the bottom left corner?

If anyone responds to this I'd really appreciate it, I've been trying to understand this for hours and hours.

So how was this done back in 2011?

I want that material, but I canā€™t make it workā€¦

https://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/core-data/?r=6462#core-data%2FCommon%2FMatDefs%2FLight%253Fstate%253Dclosed

I only seem to be able to get individual filesā€¦ Can I get that whole folder maybe ?

Its already included in the engine, you donā€™t need to download anything to use it.
Just follow the instructions in the thread to activate it.

Hi Momoko_Fan,

I do not see any instructionsā€¦

I canā€™t get it to work, my lighting material does not contain:

ReflectionPower : the spec map is raised to that power, the higher this value the more the shiny part will reflect and the less the not shiny part will do

And

ReflectionIntensity : the higher the value the more the reflection is visible (max is 1).

Could you please post an example ? Say just to get a geometry to reflect ?

Thereā€™s an example that shows how to do this:

1 Like

You can also use PBRLighting.j3md with the 3.1 nightly to make reflections.

1 Like

Ok, this looks nice. Only problem is that it will only reflect the static skybox, not a dynamic sky with day/night. Plus, other objects in the scene will not be reflected. I will try out 3.1 nightly. Thanks for the info !