WaterFilter reflection is now correctly rendered when the up axis of the cam is not Y

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7567 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent c4270ad91f
commit c95c656a55
  1. 5
      engine/src/core/com/jme3/post/FilterPostProcessor.java
  2. 2
      engine/src/desktop-fx/com/jme3/post/filters/TranslucentBucketFilter.java
  3. 12
      engine/src/desktop-fx/com/jme3/water/WaterFilter.java

@ -194,7 +194,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
public void renderFilterChain(Renderer r, FrameBuffer sceneFb) {
Texture2D tex = filterTexture;
FrameBuffer buff = null;
FrameBuffer buff = sceneFb;
boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1;
for (int i = 0; i < filters.size(); i++) {
Filter filter = filters.get(i);
@ -260,6 +260,9 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
sceneBuffer = renderFrameBufferMS;
}
renderFilterChain(renderer, sceneBuffer);
renderManager.setCamera(viewPort.getCamera(), false);
renderer.setFrameBuffer(outputBuffer);
}

@ -49,7 +49,9 @@ public final class TranslucentBucketFilter extends Filter {
@Override
public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
renderManager.setCamera(viewPort.getCamera(), false);
if(prevFilterBuffer != sceneBuffer){
renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false);
}
renderManager.getRenderer().setFrameBuffer(sceneBuffer);
viewPort.getQueue().renderQueue(RenderQueue.Bucket.Translucent, renderManager, viewPort.getCamera());
}

@ -53,6 +53,7 @@ import com.jme3.scene.Spatial;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.texture.Texture2D;
import com.jme3.util.TempVars;
import java.io.IOException;
/**
@ -166,7 +167,16 @@ public class WaterFilter extends Filter {
sceneCam.getFrustumRight(),
sceneCam.getFrustumTop(),
sceneCam.getFrustumBottom());
reflectionCam.lookAt(targetLocation, Vector3f.UNIT_Y);
TempVars vars = TempVars.get();
assert vars.lock();
vars.vect1.set(sceneCam.getLocation()).addLocal(sceneCam.getUp());
float planeDistance = plane.pseudoDistance(vars.vect1);
vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
reflectionCam.lookAt(targetLocation, vars.vect3);
assert vars.unlock();
if (inv) {
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());
}

Loading…
Cancel
Save